Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AxisArrays: maximum not working on Julia 1.10 #226

Open
tknopp opened this issue Jan 16, 2024 · 2 comments
Open

AxisArrays: maximum not working on Julia 1.10 #226

tknopp opened this issue Jan 16, 2024 · 2 comments

Comments

@tknopp
Copy link

tknopp commented Jan 16, 2024

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.
@timholy
Copy link
Member

timholy commented Jan 17, 2024

1.10 might be correct, given

reduced_axis( ax::Axis{name,<:AbstractArray{T}}) where {name,T<:Number} = ax(oftype(ax.val, Base.OneTo(1)))
. I suspect we need a more dimensionally-aware way of allocating a range of length 1. It's been a while since I've done much Unitful stuff, care to take a crack at that?

@tknopp
Copy link
Author

tknopp commented Jan 18, 2024

care to take a crack at that?
Thats way beyond my knowledge. My Unitful experience is mostly try and error until things work.

Independent of fixing it: Should we be worried that Julia 1.10 did change behavior? It is totally unclear what has happened here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants