JuliaArrays / JuliaArrays/AxisArrays.jl

AxisArrays: maximum not working on Julia 1.10

Open
#226 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
207
Forks
41
PR merge metrics
No merged PRs in 30d

Description

We observed that AxisArrays has issues with Julia 1.10, that were not present in Julia 1.9. The code:

using AxisArrays, Unitful
B = AxisArray(randn(3,3), (:x,:y),(0.1u"mm",0.2u"mm"),(-0.1u"mm",-0.2u"mm"));
maximum(B, dims = 2)

results in an error

ERROR: DimensionError: 1.0 and 1.0 mm are not dimensionally compatible.
Stacktrace:
  [1] -(x::Quantity{Float64, NoDims, Unitful.FreeUnits{(), NoDims, nothing}}, y::Quantity{Float64, 𝐋, Unitful.FreeUnits{(mm,), 𝐋, nothing}})
    @ Unitful ~/.julia/packages/Unitful/R4J37/src/quantities.jl:137
  [2] -(x::Int64, y::Quantity{Float64, 𝐋, Unitful.FreeUnits{(mm,), 𝐋, nothing}})
    @ Base ./promotion.jl:424
  [3] Base.TwicePrecision{Quantity{Float64, 𝐋, Unitful.FreeUnits{(mm,), 𝐋, nothing}}}(x::Int64)
    @ Base ./twiceprecision.jl:207
  [4] StepRangeLen{Quantity{…}, Base.TwicePrecision{…}, Base.TwicePrecision{…}, Int64}(r::Base.OneTo{Int64})
    @ Base ./range.jl:1342
  [5] convert(::Type{StepRangeLen{Quantity{…}, Base.TwicePrecision{…}, Base.TwicePrecision{…}, Int64}}, r::Base.OneTo{Int64})
    @ Base ./range.jl:265
  [6] oftype(x::StepRangeLen{Quantity{…}, Base.TwicePrecision{…}, Base.TwicePrecision{…}, Int64}, y::Base.OneTo{Int64})
    @ Base ./essentials.jl:517
  [7] reduced_axis(ax::Axis{:y, StepRangeLen{Quantity{…}, Base.TwicePrecision{…}, Base.TwicePrecision{…}, Int64}})
    @ AxisArrays ~/.julia/packages/AxisArrays/CtyI0/src/core.jl:404
  [8] #19
    @ ~/.julia/packages/AxisArrays/CtyI0/src/core.jl:365 [inlined]
  [9] map
    @ ./tuple.jl:319 [inlined]
 [10] reduced_indices
    @ ~/.julia/packages/AxisArrays/CtyI0/src/core.jl:364 [inlined]
 [11] reduced_indices
    @ ~/.julia/packages/AxisArrays/CtyI0/src/core.jl:359 [inlined]
 [12] reduced_indices
    @ ~/.julia/packages/AxisArrays/CtyI0/src/core.jl:354 [inlined]
 [13] reducedim_init(f::Function, op::typeof(max), A::AxisMatrix{Float64, Matrix{Float64}, Tuple{Axis{…}, Axis{…}}}, region::Int64)
    @ Base ./reducedim.jl:131
 [14] _mapreduce_dim
    @ Base ./reducedim.jl:371 [inlined]
 [15] mapreduce
    @ Base ./reducedim.jl:357 [inlined]
 [16] _maximum
    @ Base ./reducedim.jl:1039 [inlined]
 [17] _maximum
    @ Base ./reducedim.jl:1038 [inlined]
 [18] #maximum#836
    @ Base ./reducedim.jl:1010 [inlined]
 [19] top-level scope
    @ REPL[6]:1
Some type information was truncated. Use `show(err)` to see complete types.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the Julia 1.10 failure with the AxisArrays and Unitful example in the issue. Inspect src/core.jl around reduced_indices and reduced_axis (lines 354-404), then verify that maximum(B, dims=2) works with Unitful-valued axes without the DimensionError.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.