-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Deprecate similar(f, …) in favor of just dispatching directly on f(…) #26733
Conversation
Just a note that I first attempted to coalesce all these functions around an The biggest reason not to couple it with this change was simply that it became quite disruptive — it meant that |
the tightening of signatures for zeros and ones.
I've added NEWS and deprecations for the newly-tighter ones and zeros methods… but now I'm running into a test failure I don't quite understand: f5575() = zeros(Type[Float64][1], 1)
@test Base.return_types(f5575, ())[1] == Vector With these additional deprecations, I'm now getting julia> methods(zeros, Tuple{Type, Int})
# 1 method for generic function "zeros":
[1] zeros(::Type{T}, dims::Union{Integer, AbstractUnitRange}...) where T in Base at array.jl:401 So I'm not sure what to do with that... |
The zeros function (currently) recurses aggressively. The test is there to make sure the compile stops trying to follow the possible branches in a reasonable time, without losing accuracy. |
Thanks. So the fact that I broke this test by adding these deprecations is expected? Should I just copy the previous zeros method tree (without deprecations) onto a new function that gets defined in the test and whose sole purpose is this one test? |
that has the known properties that we want to test. The important thing is not necessarily zeros -- it is a relatively complex function. The `Base.zeros` method tree temporarily breaks this test due to its numerous deprecations, but this will be resolved in the future.
* Update in anticipation of deprecating similar(f, ...) Requires JuliaLang/julia#26733 * Add VERSIONing
Fixes #26433.
Previously, OffsetArrays used
similar(dims->zeros(dims), axes)
to add offset support for the base functions that created arrays:zeros
,ones
,trues
,falses
, andfill
. It was a bit of a strange construct — the function specified the "internal" array around whichOffsetArray
s would wrap. This deprecates that similar method in favor just structuring the method tables of those five functions in a manner that is conducive for overloading with offset axis argument(s). Paired with JuliaArrays/OffsetArrays.jl#43 to match the changes in test/TestHelpers.jl.