larray-project / larray

N-dimensional labelled arrays in Python
https://larray.readthedocs.io/
GNU General Public License v3.0
8 stars 6 forks source link

comparison between Array and None (or an Axis) returns False (single value) #988

Closed gdementen closed 2 years ago

gdementen commented 2 years ago

This is a regression in 0.33 (39ced81f9a335f47bbf512c50139e35f1ff86705) because None is not a scalar for np.isscalar

Test case:

>>> arr = full("a=a0..a2", None)
>>> arr == None
False

One workaround is (we can use is too but it is farther from the original code):

>>> arr.apply(lambda v: v == None)
a    a0    a1    a2
   True  True  True
gdementen commented 2 years ago

A variant of this bug/regression found by another user: Array + Axis returns False

>>> arr = ndtest("time=2010..2012")
>>> arr + arr.time
False

The workaround in that case is:

>>> arr = ndtest("time=2010..2012")
>>> arr + asarray(arr.time)
time  2010  2011  2012
      2010  2012  2014