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] == VectorWith 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:401So 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 whichOffsetArrays 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.