DimensionalData.jl icon indicating copy to clipboard operation
DimensionalData.jl copied to clipboard

implement `isequal` and clarify `==` for DimArrays with missing values

Open tiemvanderdeure opened this issue 2 months ago • 2 comments

As of now:

using DimensionalData
da = DimArray([1, missing], X(1:2))
da2 = DimArray([1, missing], Y(1:2))
da == da2 # errors!
isequal(da, da2) # true

The error is because == is defined as parent(A1) == parent(A2) && dims(A1) == dims(A2) - if the first returns missing than this errors, so we should just swap the order here.

The point of isequal is that it handles missing values well - which is really neat because Rasters tend to have lots of missing values. Here it returns true because it uses the fallback definition and so never checks the dimensions.

If we implement these properly then probably we don't need additional definitions in e.g. Rasters.jl

tiemvanderdeure avatar Oct 06 '25 11:10 tiemvanderdeure

Yeah, definately shouldn't error. But if base gives missing then we should return missing too. So check if == returns missing, if not do the dims comparison?

And yes we just forgot isequal

rafaqz avatar Oct 07 '25 21:10 rafaqz

If we swap, we will return missing. This should also be faster for the same data and different dims case.

felixcremer avatar Oct 08 '25 02:10 felixcremer