rafaqz / DimensionalData.jl

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

Fix `show` and implement `iterate` for `ShowWith` #527

Closed kahaaga closed 1 year ago

kahaaga commented 1 year ago

Fixes #525.

Changes:

I also took the freedom to bump the patch version - hoping that a new version with the bug fix can be released in the near future 😁

EDIT:

I couldn't get the test suite to run locally, so I have no idea if this breaks anything (errors with something related to Aqua.jl). However, the following example demonstrates that the error in #525 is gone. Both 1D and higher-dimensional arrays are now shown correctly:


julia> using StaticArrays, DimensionalData

julia> outs_x = = SVector.([(1, 1), (1, 2), (2, 1), (2,2)]);

julia> outs_y = ['a', 2];

julia> outs_z = SVector.([(i/10,) for i = 1:9]);

julia> r = DimArray(rand(4, 2, 9), (x = outs_x, y = outs_y, z = outs_z))
4×2×9 DimArray{Float64,3} with dimensions:
  Dim{:x} Sampled{SVector{2, Int64}} SVector{2, Int64}[[1, 1], [1, 2], [2, 1], [2, 2]] ForwardOrdered Irregular Points,
  Dim{:y} Categorical{Any} Any['a', 2] Unordered,
  Dim{:z} Sampled{SVector{1, Float64}} SVector{1, Float64}[[0.1], [0.2], …, [0.8], [0.9]] ForwardOrdered Irregular Points
[:, :, 1]
           'a'       2
  [1, 1]  0.287179   0.632268
  [1, 2]  0.0466436  0.984726
  [2, 1]  0.620585   0.0815738
  [2, 2]  0.545003   0.826741

julia> r[:, 2, 3]
4-element DimArray{Float64,1} with dimensions:
  Dim{:x} Sampled{SVector{2, Int64}} SVector{2, Int64}[[1, 1], [1, 2], [2, 1], [2, 2]] ForwardOrdered Irregular Points
and reference dimensions:
  Dim{:y} Categorical{Any} Any[2] Unordered,
  Dim{:z} Sampled{SVector{1, Float64}} SVector{1, Float64}[[0.3]] ForwardOrdered Irregular Points
 [1, 1]  0.814599
 [1, 2]  0.922612
 [2, 1]  0.319535
 [2, 2]  0.620675
codecov-commenter commented 1 year ago

Codecov Report

Merging #527 (f5cab76) into main (6af9c1e) will decrease coverage by 0.15%. The diff coverage is 0.00%.

@@            Coverage Diff             @@
##             main     #527      +/-   ##
==========================================
- Coverage   89.38%   89.24%   -0.15%     
==========================================
  Files          39       39              
  Lines        2874     2882       +8     
==========================================
+ Hits         2569     2572       +3     
- Misses        305      310       +5     
Files Changed Coverage Δ
src/array/show.jl 90.74% <0.00%> (-4.41%) :arrow_down:

... and 3 files with indirect coverage changes

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

rafaqz commented 1 year ago

Thanks

Actually best if you dont bump the version.

There is code we decided is breaking on master so we need to bump a major version, or revert (which I personally dont have time for)

Im waiting on the two other breaking PRs before bumping the minor version, to minimise downstream work.

kahaaga commented 1 year ago

Actually best if you dont bump the version. There is code we decided is breaking on master so we need to bump a major version, or revert (which I personally dont have time for) Im waiting on the two other breaking PRs before bumping the minor version, to minimise downstream work.

Ok, no problem! I reverted the version bump.