-
Notifications
You must be signed in to change notification settings - Fork 4
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
Better document floating point indexing #40
Comments
Hey @grahamas, master now has |
Hey @Tokazama , sorry I didn't see this. This seems like a great solution, but it doesn't work in a case I'd expect: A = AxisArray(3:6, 0.3:0.1:0.6)
A[closest(0.6)] edit: though it looks like this is just a bug? It also doesn't work for AxisIndices.Axis(0.3:0.1:0.6)[0.6 |> closest]
ERROR: MethodError: no method matching one(::Nothing)
Closest candidates are:
one(::Union{Type{T}, T}) where T<:AbstractString at strings/basic.jl:262
one(::Union{Type{P}, P}) where P<:Dates.Period at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Dates/src/periods.jl:54
one(::NamedDims.NamedDimsArray{L, T, N, A} where {T, N, A<:AbstractArray{T, N}}, ::Any...) where L at /home/graham/.julia/packages/NamedDims/OBqS7/src/functions.jl:99
...
Stacktrace:
[1] oneunit(x::Nothing)
@ Base ./number.jl:318
[2] _closest_number_forward(collection::StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}}, x::Float64)
@ AxisIndices ~/.julia/packages/AxisIndices/Eb16j/src/closest.jl:31
[3] closest_number
@ ~/.julia/packages/AxisIndices/Eb16j/src/closest.jl:18 [inlined]
[4] closest
@ ~/.julia/packages/AxisIndices/Eb16j/src/closest.jl:10 [inlined]
[5] Fix2
@ ./operators.jl:1002 [inlined]
[6] to_index(#unused#::AxisIndices.IndexAxis, axis::AxisIndices.Axis{Float64, Int64, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}}, SimpleAxis{Int64, ArrayInterface.OptionallyStaticUnitRange{ArrayInterface.StaticInt{1}, Int64}}}, arg::Base.Fix2{typeof(closest), Float64})
@ AxisIndices ~/.julia/packages/AxisIndices/Eb16j/src/closest.jl:69
[7] to_index
@ ~/.julia/packages/ArrayInterface/hIHGL/src/indexing.jl:283 [inlined]
[8] getindex(axis::AxisIndices.Axis{Float64, Int64, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}}, SimpleAxis{Int64, ArrayInterface.OptionallyStaticUnitRange{ArrayInterface.StaticInt{1}, Int64}}}, arg::Function)
@ AxisIndices ~/.julia/packages/AxisIndices/Eb16j/src/getindex.jl:15
[9] top-level scope
@ REPL[7]:1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This came up as part of #35.
The text was updated successfully, but these errors were encountered: