-
-
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
RFC: Deprecate Array(T, dims...) #19989
Conversation
Array{T}(::Type{T}, d::Integer...) = Array(T, convert(Tuple{Vararg{Int}}, d)) | ||
Array{T}(::Type{T}, m::Integer) = Array{T,1}(Int(m)) | ||
Array{T}(::Type{T}, m::Integer,n::Integer) = Array{T,2}(Int(m),Int(n)) | ||
Array{T}(::Type{T}, m::Integer,n::Integer,o::Integer) = Array{T,3}(Int(m),Int(n),Int(o)) |
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.
move these to deprecations.jl?
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.
Good catch, thanks.
@@ -2242,7 +2242,7 @@ | |||
,.(map (lambda (v r) `(= ,v (call (top length) ,r))) lengths rv) | |||
(scope-block | |||
(block | |||
(= ,result (call (core Array) ,atype ,@lengths)) | |||
(= ,result (call (curly Array ,atype) ,@lengths)) |
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.
can also add ,(length lengths)
to the (curly
, if I'm not mistaken, to splice in the number of dimensions also
2b086fe
to
fdc945a
Compare
@nanosoldier |
...huh. Well, the fact that this works on Linux and macOS but not on Windows is rather concerning. Looks like it's failing on |
I think this line is the offender. |
Excellent catch, @quinnj, thanks! I didn't even realize that
|
fdc945a
to
91f7cb9
Compare
@@ -277,7 +277,7 @@ if is_windows() | |||
const FORMAT_MESSAGE_FROM_SYSTEM = UInt32(0x1000) | |||
const FORMAT_MESSAGE_IGNORE_INSERTS = UInt32(0x200) | |||
const FORMAT_MESSAGE_MAX_WIDTH_MASK = UInt32(0xFF) | |||
lpMsgBuf = Array(Ptr{UInt16}) | |||
lpMsgBuf = Array{Ptr{UInt16},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.
isn't this the same as lpMsgBuf = Array{Ptr{UInt16},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.
No, that's actually a MethodError
.
julia> Array{Ptr{UInt16},0}()
ERROR: MethodError: no method matching Array{Ptr{UInt16},0}()
Closest candidates are:
Array{Ptr{UInt16},0}{T,N}(::Tuple{Vararg{Int64,N}}) at boot.jl:310
Array{Ptr{UInt16},0}{T}(::Any) at sysimg.jl:53
(The above is from Julia 0.5; that behavior wasn't introduced in this PR)
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.
Strange I don't get a method error (Commit db4aaa3* (3 days old master))
julia> Array{Ptr{UInt16},0}()
0-dimensional Array{Ptr{UInt16},0}:
Ptr{UInt16} @0x0000000000000003
julia> versioninfo()
Julia Version 0.6.0-dev.2005
Commit db4aaa3* (2017-01-09 10:16 UTC)
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: Intel(R) Core(TM) i7-4510U CPU @ 2.00GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
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.
Oh yeah, looks like the behavior changed in 0.6, nice.
Looks like there was a major service outage on GitHub at about the time that Nanosoldier attempted to upload the logs. Retriggering: @nanosoldier |
Unrelated |
Looks good, thanks! Maybe remove the deprecated statement in the manual now, too? We don't typically include prose like that and it'll likely be forgotten and become outdated. Also, SharedArrays have a constructor of the same style. |
Wow, Nanosoldier's push is getting rejected because the all depwarns here are causing the STDERR log to exceed GitHub's file size limit of 100 MB. That's...a lot of depwarns 😛 Mostly in HDF5 and JLD. I'll remove that big log and just upload the other (much smaller) logs and post the link here. EDIT: Here is the benchmark report. Looks like some of the benchmarks will have to be updated. Here's how I "confirmed" that most of the depwarns in the oversized log were this PR's depwarns:
|
91f7cb9
to
4bea194
Compare
@@ -25,6 +25,14 @@ typealias DenseVecOrMat{T} Union{DenseVector{T}, DenseMatrix{T}} | |||
|
|||
import Core: arraysize, arrayset, arrayref | |||
|
|||
""" | |||
Array{T}(dims) |
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.
list both parameters {T,N}
here?
Hm, I'm not entirely sure what to do about
during the build. These are the defined methods: julia> methods(SharedArray)
# 9 methods for generic function "(::Type)":
(::Type{SharedArray}){T}(I::Int64...; kwargs...) in Base at sharedarray.jl:113
(::Type{SharedArray}){T,N}(dims::Tuple{Vararg{Int64,N}}; init, pids) in Base at sharedarray.jl:57
(::Type{SharedArray}){N}(filename::AbstractString, dims::Tuple{Vararg{Int64,N}}) in Base at sharedarray.jl:147
(::Type{SharedArray}){T,N}(filename::AbstractString, dims::Tuple{Vararg{Int64,N}}, offset::Integer; init, mode, pids) in Base at sharedarray.jl:147
(::Type{SharedArray}){T,N}(::Type{T}, dims::Tuple{Vararg{Int64,N}}; kwargs...) in Base at deprecated.jl:49
(::Type{SharedArray}){T}(::Type{T}, dims::Int64...; kwargs...) in Base at deprecated.jl:49
(::Type{SharedArray}){T,N}(filename::AbstractString, ::Type{T}, dims::Tuple{Vararg{Int64,N}}, offset; kwargs...) in Base at deprecated.jl:49
(::Type{SharedArray}){T}(filename::AbstractString, ::Type{T}, dims::Tuple{Vararg{T<:Any,N<:Any}}, offset; kwargs...) in Base at deprecated.jl:49
(::Type{T}){T}(arg) in Base at sysimg.jl:24 Clearly I've done something wrong here, just quite sure what yet. |
The type parameter is not used as the warning suggests. You need to replace the implementation with one of the methods above. |
4bea194
to
f0faa78
Compare
I'm still having a hard time figuring out what's wrong with the |
@@ -53,7 +53,7 @@ computation with the master process acting as a driver. | |||
If an `init` function of the type `initfn(S::SharedArray)` is specified, it is called on all | |||
the participating workers. | |||
""" | |||
function SharedArray{T,N}(::Type{T}, dims::Dims{N}; init=false, pids=Int[]) | |||
function SharedArray{T,N}(dims::Dims{N}; init=false, pids=Int[]) |
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.
Remove the definition on line 31 and move it here. This isn't a valid method definition at all. I.e. this does NOT define a method for SharedArray{T,N}
.
@@ -110,10 +110,10 @@ function SharedArray{T,N}(::Type{T}, dims::Dims{N}; init=false, pids=Int[]) | |||
S | |||
end | |||
|
|||
SharedArray(T, I::Int...; kwargs...) = SharedArray(T, I; kwargs...) | |||
SharedArray{T}(I::Int...; kwargs...) = SharedArray{T,length(I)}(I; kwargs...) |
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.
This should become a method of ShardArray{T}
too replacing the ones on line 33 to 39.
@@ -142,7 +142,7 @@ file is not writable. | |||
`offset` allows you to skip the specified number of bytes at the | |||
beginning of the file. | |||
""" | |||
function SharedArray{T,N}(filename::AbstractString, ::Type{T}, dims::NTuple{N,Int}, | |||
function SharedArray{T,N}(filename::AbstractString, dims::NTuple{N,Int}, |
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.
This should become a new method of SharedArray{T}
this also needs to go in Compat.jl since it's not available on old julia versions AFAICT.
@@ -307,21 +307,25 @@ localindexes(S::SharedArray) = S.pidx > 0 ? range_1dim(S, S.pidx) : 1:0 | |||
unsafe_convert{T}(::Type{Ptr{T}}, S::SharedArray) = unsafe_convert(Ptr{T}, sdata(S)) | |||
|
|||
function convert(::Type{SharedArray}, A::Array) | |||
S = SharedArray(eltype(A), size(A)) | |||
sz = size(A) | |||
S = SharedArray{eltype(A),length(sz)}(sz) |
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.
Note that there isn't any methods defined for SharedArray{T,N}
apart from the inner constructor so this won't work. You need to either not use them and use SharedArray{T}
instead or check for conflict/ambiguity and define them.
@@ -1649,4 +1649,12 @@ isempty(::Task) = error("isempty not defined for Tasks") | |||
@deprecate Array{T}(::Type{T}, m::Integer,n::Integer) Array{T,2}(Int(m),Int(n)) | |||
@deprecate Array{T}(::Type{T}, m::Integer,n::Integer,o::Integer) Array{T,3}(Int(m),Int(n),Int(o)) | |||
|
|||
# Likewise for SharedArrays | |||
@deprecate SharedArray{T,N}(::Type{T}, dims::Dims{N}; kwargs...) SharedArray{T,N}(dims; kwargs...) |
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.
Similar to comment below, these are calling non-existing methods.
f0faa78
to
753861e
Compare
I think I've addressed all of your comments, @yuyichao. Thanks so much for your help! |
ba77c5a
to
92ee7ed
Compare
@@ -277,7 +277,7 @@ if is_windows() | |||
const FORMAT_MESSAGE_FROM_SYSTEM = UInt32(0x1000) | |||
const FORMAT_MESSAGE_IGNORE_INSERTS = UInt32(0x200) | |||
const FORMAT_MESSAGE_MAX_WIDTH_MASK = UInt32(0xFF) | |||
lpMsgBuf = Array(Ptr{UInt16}) | |||
lpMsgBuf = Array{Ptr{UInt16},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.
Not necessary to change in this PR since this is the exact equivalent of what was there, but shouldn't this be updated to use a Ref{Ptr{UInt16}}
instead of a zero-dimensional array?
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.
+1 to Ref
2fa11d1
to
36122a7
Compare
This PR's depwarns will "break" Nanosoldier's benchmark runs against |
Also would be good to get JuliaIO/HDF5.jl#354 merged for the same reason. |
Array(T, dims...) to Array{T}(dims...) (ref JuliaLang/julia#19989)
Very sorry, should have waited to merge! |
as the latter has been deprecated in JuliaLang/julia#19989.
|
Maybe I got confused by the deprecation message. Can we change it so that |
This PR implements one of the changes mentioned in #19598: deprecate the
Array(T, dims...)
syntax in favor ofArray{T,N}(dims...)
. The manual has claimed the former syntax to be deprecated ever since the latter syntax was introduced, though no formal deprecation ever happened... until now!Thanks to @vtjnash and @JeffBezanson for their help on this.