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

Towards 0.7 support #143

Merged
merged 29 commits into from
Aug 17, 2018
Merged

Towards 0.7 support #143

merged 29 commits into from
Aug 17, 2018

Conversation

Evizero
Copy link
Member

@Evizero Evizero commented Aug 5, 2018

Not even the core.jl tests pass, but its fixes some of the more obvious warnings at least

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

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))
Copy link
Member Author

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))
Copy link
Member Author

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

@mbauman
Copy link
Member

mbauman commented Aug 7, 2018

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.

@tknopp
Copy link

tknopp commented Aug 8, 2018

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.

@mbauman
Copy link
Member

mbauman commented Aug 8, 2018

My current thought is to get a patched-up AxisArrays out the door with axes defined, and then later refactor the name and/or package.

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.

mbauman added 2 commits August 8, 2018 19:48
the squeeze deprecation will need some more work to be type-stable using a varargs kwarg
@tknopp
Copy link

tknopp commented Aug 9, 2018

I am fine with that as well, just wanted to bring this to attention.

@iamed2
Copy link
Collaborator

iamed2 commented Aug 11, 2018

@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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Evizero: If you do this, you also need to bump REQUIRE to 0.7. I recommend that since a lot of packages drop 0.6 support on master. (@mbauman for attention)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right

@Evizero
Copy link
Member Author

Evizero commented Aug 16, 2018

note I am just doing some small changes to help along. like updating travis and removing a couple of depwarns around sum.

I'd like to help more but I feel like chances are I'd end up working against you

@mbauman
Copy link
Member

mbauman commented Aug 16, 2018

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!

@tknopp
Copy link

tknopp commented Aug 16, 2018

@mbauman: Why should we export axes? If this is not done, there would not be the conflict dropping also the Base axes

@tknopp
Copy link

tknopp commented Aug 16, 2018

julia> module MyModule
         axes() = println("axes called")
       end
         
julia> MyModule.axes()
axes called

@mbauman
Copy link
Member

mbauman commented Aug 17, 2018

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 axes, precisely at the point at which it is called. It's not as graceful as a deprecation mechanism, but it's an error that will serve as the same. The section I added in the README is designed to serve as google-fodder for that error and help folks upgrade.

Once dependencies are upgraded, we can then change the name or unexport it.

I still favor this path.

@tknopp
Copy link

tknopp commented Aug 17, 2018

I see, fine with that as a stopgap solution!

@RalphAS
Copy link

RalphAS commented Aug 17, 2018

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

@mbauman
Copy link
Member

mbauman commented Aug 17, 2018

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!

@mbauman mbauman merged commit 8cb003b into JuliaArrays:master Aug 17, 2018
@mbauman mbauman mentioned this pull request Aug 17, 2018
@Evizero Evizero deleted the update07 branch August 18, 2018 06:34
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

Successfully merging this pull request may close these issues.

5 participants