I basically want to write a vectorized function in Numpy that will element-wise compare the binary representations and the data types of involved arrays.
For example,
f(np.nan, np.nan)
should beTrue
.f(np.datetime64('NaT'), np.nan)
should beFalse
.f(np.datetime64('NaT'), np.datetime64('NaT'))
should beTrue
.f(np.NZERO, np.PZERO)
should beTrue
on platforms that have an identical binary representation for both butFalse
otherwise.- Any other weird exceptions (?)
Also, the function should be vectorized, fast (C speed) and at least "look like" a ufunc
in the sense that it should support broadcasting and stringing over arrays.
I've tried this, but it doesn't work for NaT
, etc: Comparing NumPy arrays so that NaNs compare equal
The following require Pandas, which I don't want to do, and they'll make NaN == NaT
. Numpy: Checking if a value is NaT
I could add np.isnat
to problem 1, but that wouldn't compare the precision of the object.
And none of these can do the NZERO
/PZERO
thing.