larray-project / larray-editor

Graphical User Interface for LArray
GNU General Public License v3.0
2 stars 2 forks source link

compare() background wrong for integer arrays when arrays are equal #246

Closed gdementen closed 1 year ago

gdementen commented 1 year ago

It is all red even though it should be white like for floats when there is no difference. The problem is the same when the comparison is done via two sessions.

from larray import Session, compare, ndtest

a = ndtest(3, dtype=float)
b = ndtest(3, dtype=int)

compare(a, a)          # white background like it should
compare(a, a + 1)      # blue background like it should
compare(b, b)          # red background even if diff is 0
compare(b, b + 1)      # blue background like it should
ses = Session(a=a, b=b)
compare(ses, ses)      # red background for b even if diff is 0
gdementen commented 1 year ago

It's all due to the full_like(array) calls in ComparatorWidget.update_isequal which should be full(array.axes) instead to avoid copying the dtype of the array. full_like(int_array, 0.5) gives an integer array full of 0 !