IDSIA/sacred

is_different behavior differs with numpy vs without numpy

thequilo opened this issue · 6 comments

In #928 the issue came up that the behavior of is_different in custom_containers differs if numpy is installed vs when it is not installed. Here is an example:

>>> import sacred

>>> sacred.config.custom_containers.is_different([1, [1,2]], [1, [1,2]])
True

>>> sacred.optional.has_numpy = False

>>> sacred.config.custom_containers.is_different([1, [1,2]], [1, [1,2]])
False

This looks like undesired behavior, but I have to investigate further what impact this issue has before I fix it.

@thequilo I just noticed that #928 did introduce some unintended changes. With numpy haven released fixes to restore the old array_equal functionality, could we revert these changes?

This one breaks now:

from sacred import Experiment

ex = Experiment()


@ex.config
def config():
    a = dict(b=[])


@ex.automain
def main(a):
    return a

python test.py with a.b='["hello", "world"]':

Exception originated from within Sacred.
Traceback (most recent calls):
  File "/ceph/ssd/staff/gaoni/repos/sparse_wf/.venv/lib/python3.11/site-packages/sacred/config/custom_containers.py", line 312, in is_different
    result = old_value != new_value
             ^^^^^^^^^^^^^^^^^^^^^^
ValueError: operands could not be broadcast together with shapes (0,) (2,)

Yeah, I forgot the if old_value.shape != new_value.shape: return True part in #928