def is_different(old_value, new_value):
    """Numpy aware comparison between two values."""
    if opt.has_numpy:
        # Reproduces np.array_equal from numpy<2
        # np.array_equal raises an exception when the arguments are scalar and
        # differ in type (e.g. int and str) in numpy>=2.0
        try:
            old_value = opt.np.asarray(old_value)
            new_value = opt.np.asarray(new_value)
            if old_value.shape != new_value.shape:
                return True
            result = old_value != new_value
            if isinstance(result, bool):
                return result
            else:
                return result.all()
        except:  # if anything goes wrong, it is not equal
            return True

    return old_value != new_value
Numpy aware comparison between two values.
sacred/config/custom_containers.py