rafaqz / DimensionalData.jl

Named dimensions and indexing for julia arrays and other data
https://rafaqz.github.io/DimensionalData.jl/stable/
MIT License
262 stars 38 forks source link

Where and isnan issues #693

Closed lazarusA closed 2 months ago

lazarusA commented 2 months ago
using DimensionalData
ar = rand(5,1)
ar[[1,4],1] .= NaN
ar_d = DimArray(ar, (a = 1:5, b=1:1))

ar_d[a=Where(x->!isnan(x))]

no change

╭─────────────────────────╮
│ 5×1 DimArray{Float64,2} │
├─────────────────────────┴───────────────────────────────────── dims ┐
  ↓ a Sampled{Int64} [1, 2, 3, 4, 5] ForwardOrdered Irregular Points,
  → b Sampled{Int64} 1:1 ForwardOrdered Regular Points
└─────────────────────────────────────────────────────────────────────┘
 ↓ →    1
 1    NaN
 2      0.837744
 3      0.475405
 4    NaN
 5      0.0664782

and wrong/error

ar_d[a=Where(x->isnan(x))]
╭─────────────────────────╮
│ 0×1 DimArray{Float64,2} │
├─────────────────────────┴──────────────────────── dims ┐
  ↓ a Sampled{Int64} [] ForwardOrdered Irregular Points,
  → b Sampled{Int64} 1:1 ForwardOrdered Regular Points
└────────────────────────────────────────────────────────┘
 ↓ →  1

Edit:

This works on the array level,

ar_d[.!isnan.(ar_d)]
filter(!isnan,ar_d)

but then the nice dim names are gone.

Weird, now I can see the names.

rafaqz commented 2 months ago

Where works on lookup values!