-
Notifications
You must be signed in to change notification settings - Fork 42
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
Towards 0.7 support #143
Towards 0.7 support #143
Conversation
@@ -43,17 +43,13 @@ struct CategoricalVector{T, A<:AbstractVector{T}} <: AbstractVector{T} | |||
data::A | |||
end | |||
|
|||
function CategoricalVector(data::AbstractVector{T}) where T | |||
CategoricalVector{T, typeof(data)}(data) | |||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the default constructor takes care of this. so this caused a redefinition warning.
@@ -1,3 +1,4 @@ | |||
# FIXME: type stability broken. The following should NOT error | |||
A = @inferred(AxisArray(reshape(1:24, 2,3,4), .1:.1:.2, .1:.1:.3, .1:.1:.4)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type instability comes from default_axes
which i tried to fix, but couldn't
Its quite strange that the type instability usually happens for the last tuple element
julia> @code_warntype AxisArrays.default_axes(reshape(1:24, 2,3,4), (.1:.1:.2, .1:.1:.3, .1:.1:.4))
Body::Tuple{Axis,Axis,Axis}
172 1 ─ %1 = (getfield)(args, 2)::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}} │╻╷ _default_axes
│ %2 = (getfield)(args, 3)::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}} ││┃ tail
│ %3 = (Base.getfield)(args, 1, true)::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}} ││╻ getindex
│ %4 = %new(Axis{:row,StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}}, %3)::Axis{:row,StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}}
│ %5 = (Core.tuple)(%2)::Tuple{StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}} │││╻ tail
│ %6 = %new(Axis{:col,StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}}, %1)::Axis{:col,StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}}
│ %7 = (Core.tuple)(%4, %6)::Tuple{Axis{:row,StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}},Axis{:col,StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}}}
│ %8 = invoke AxisArrays._default_axes(_2::Base.ReshapedArray{Int64,3,UnitRange{Int64},Tuple{}}, %5::Tuple{StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}}, %7::Tuple{Axis{:row,StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}},Axis{:col,StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}}})::Tuple{Axis,Axis,Axis}
└── return %8
@@ -106,6 +107,7 @@ A = @inferred(AxisArray(1:3, .1:.1:.3)) | |||
@test axisnames(A) == (:row,) | |||
@inferred(axisnames(A)) | |||
@test axisvalues(A) == (.1:.1:.3,) | |||
# FIXME: reintroduce inferred | |||
A = @inferred(AxisArray(reshape(1:16, 2,2,2,2), .5:.5:1)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above. type stability breaks with last tuple element for defaul_axes
julia> @code_warntype AxisArrays.default_axes(reshape(1:16, 2,2,2,2), (.5:.5:1,))
Body::NTuple{4,Axis}
172 1 ─ %1 = (Base.getfield)(args, 1, true)::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}} │╻╷ _default_axes
│ %2 = %new(Axis{:row,StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}}, %1)::Axis{:row,StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}}
│ %3 = (Base.getfield)(A, :dims)::NTuple{4,Int64} │││╻╷╷╷ axes
│ %4 = (Base.getfield)(%3, 1, true)::Int64 ││││╻ axes
│ %22 = (getfield)(%18, 2)::Int64 │││││││╻ tail
[...]
│ (Base.ifelse)(%30, 0, %24) ││││││││││┃ max
│ %32 = %new(Axis{:page,Base.OneTo{Int64}}, %29)::Axis{:page,Base.OneTo{Int64}} │││││╻ Type
│ %33 = (Core.tuple)(%2, %17, %32)::Tuple{Axis{:row,StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}},Axis{:col,Base.OneTo{Int64}},Axis{:page,Base.OneTo{Int64}}}
│ %34 = invoke AxisArrays._default_axes(_2::Base.ReshapedArray{Int64,4,UnitRange{Int64},Tuple{}}, ()::Tuple{}, %33::Tuple{Axis{:row,StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}},Axis{:col,Base.OneTo{Int64}},Axis{:page,Base.OneTo{Int64}}})::NTuple{4,Axis}
└── return %34
it works if you only reshape to only 3 dimensions
julia> @code_warntype AxisArrays.default_axes(reshape(1:16, 2,2,4), (.5:.5:1,))
Body::Tuple{Axis{:row,StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}},Axis{:col,Base.OneTo{Int64}},Axis{:page,Base.OneTo{Int64}}}
172 1 ─ %1 = (Base.getfield)(args, 1, true)::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}} │╻╷ _default_axes
│ %2 = %new(Axis{:row,StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}}, %1)::Axis{:row,StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}}
│ %3 = (Base.getfield)(A, :dims)::Tuple{Int64,Int64,Int64} │││╻╷╷╷ axes
│ %4 = (Base.getfield)(%3, 1, true)::Int64 ││││╻ axes
│ %5 = (Base.slt_int)(%4, 0)::Bool │││││╻╷╷ map
[...]
│ %25 = %new(Base.OneTo{Int64}, %24)::Base.OneTo{Int64} │││││││││
│ %26 = %new(Axis{:page,Base.OneTo{Int64}}, %25)::Axis{:page,Base.OneTo{Int64}} │││││╻ Type
│ %27 = (Core.tuple)(%2, %14, %26)::Tuple{Axis{:row,StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}},Axis{:col,Base.OneTo{Int64}},Axis{:page,Base.OneTo{Int64}}}
└── return %27
Thank you so much! I had started in much the same direction on the plane, but I think we can work around this PR here. I'll start pushing commits here. |
What about renaming axes to prevent the name clash with Julia base? @timholy was in favor here JuliaImages/ImageAxes.jl#25 (comment) and I kind of agree. Unfortunately I don't have a better idea right now. |
My current thought is to get a patched-up AxisArrays out the door with There's not really a good transition option for AA's dependencies here, at least as far as I've been able to see. So at least continuing to export the name is an obvious fix. And then once the uses are qualified, it's a much easier rename. |
the squeeze deprecation will need some more work to be type-stable using a varargs kwarg
I am fine with that as well, just wanted to bring this to attention. |
@mbauman Did you get further on this past the commits you've pushed? |
@@ -3,19 +3,30 @@ os: | |||
- linux | |||
- osx | |||
julia: | |||
- 0.6 | |||
- 0.7 | |||
- 1.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right
note I am just doing some small changes to help along. like updating travis and removing a couple of depwarns around I'd like to help more but I feel like chances are I'd end up working against you |
That's awesome, thanks! I'm trying to push my work as soon as I achieve a small bit of progress, so don't worry too much about conflicts. I'm back at this now, trying to wrap it up today! |
… AxisArray constructor. Simplify make_axes_match.
* More axes qualifiers * Fixup an earlier findall replacement * Simplify reaxis and explicitly implement linear indexing there
@mbauman: Why should we export |
|
Yes, we could of course do that. The thought behind the error is that it should make it easier for dependencies to identify the need to change their usages of Once dependencies are upgraded, we can then change the name or unexport it. I still favor this path. |
I see, fine with that as a stopgap solution! |
I encountered a couple of surviving deprecations while trying this out: ┌ Warning: using `A[I...] = x` to implicitly broadcast `x` across many locations is deprecated. Use `A[I...] .= x` instead.
│ caller = setindex! at indexing.jl:108 [inlined]
└ @ Core ~/.julia/dev/AxisArrays/src/indexing.jl:108 ┌ Warning: `String(io::GenericIOBuffer)` is deprecated, use `String(take!(copy(io)))` instead.
│ caller = summary(::AxisArray{Gray{Normed{UInt8,8}},2,Array{Gray{Normed{UInt8,8}},2},Tuple{Axis{:y,Base.OneTo{Int64}},Axis{:x,Base.OneTo{Int64}}}}) at core.jl:493
└ @ AxisArrays ~/.julia/dev/AxisArrays/src/core.jl:493 |
That's great, @RalphAS, thanks! I've fixed the second deprecation you found. The first is an example where we're simply deferring to (and mirroring) Base's implementation. So it behaves as we want on 1.0, and it does throw a deprecation warning on 0.7 (albeit with the incorrect caller information). I gave a quick shot at deprecating it properly but failed... it's a complicated one. I'm inclined to just merge and tag once tests pass here so we can start upgrading dependencies! |
Not even the core.jl tests pass, but its fixes some of the more obvious warnings at least