-
-
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
Replace deprecated Array(T..., dims...) with Array{T...}(dims...) in /base/ #16498
Conversation
|
||
cell(dims::Integer...) = Array(Any, dims...) | ||
cell(dims::Tuple{Vararg{Integer}}) = Array(Any, convert(Tuple{Vararg{Int}}, dims)) | ||
cell(dims::Integer...) = Array{Any}( 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.
Here's an extra space before dims
What are the string failure? Shouldn't the two constructors be equivalent? |
Sorry, I really explained myself poorly. There was a string test error before changing anything and it was there after as well. It seems to have disappeared when rebasing. Edit: I will run the tests again locally just to be sure. It doesn't seem to appear on the CIs. |
@@ -7376,7 +7376,7 @@ for the effects of compilation. | |||
Array(dims) | |||
|
|||
`Array{T}(dims)` constructs an uninitialized dense array with element type `T`. `dims` may | |||
be a tuple or a series of integer arguments. The syntax `Array(T, dims)` is also available, | |||
be a tuple or a series of integer arguments. The syntax `Array{T}(dims)` is also available, |
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.
You don't want to change this one. It's interesting that it's documented as deprecated, but I guess we never actually made it show a deprecation warning.
The next step will be to actually deprecate these:
Lines 315 to 320 in 99bf23d
# TODO: possibly turn these into deprecations | |
Array{T,N}(::Type{T}, d::NTuple{N,Int}) = Array{T}(d) | |
Array{T}(::Type{T}, d::Int...) = Array{T}(d) | |
Array{T}(::Type{T}, m::Int) = Array{T,1}(m) | |
Array{T}(::Type{T}, m::Int,n::Int) = Array{T,2}(m,n) | |
Array{T}(::Type{T}, m::Int,n::Int,o::Int) = Array{T,3}(m,n,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.
Yes of course, that is a mistake.
I will add the deprecation.
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.
Okay, I tried, and I have to say, I'm not sure how to do the deprecation. I understand it should be something like
@deprecate old new
but if I try something like
@deprecate Array{T,N}(::Type{T}, d::NTuple{N,Int}) = Array{T}(d)
I get something like (plus a lot more backtracing)
deprecated.jl
require.jl
error during bootstrap:
LoadError(at "sysimg.jl" line 337: LoadError(at "deprecated.jl" line 1186: Base.MethodError(f=Base.#@deprecate(), args=(Expr(:call, Expr(:curly, :Array, :T, :N)::Any, Expr(:::, Expr(:curly, :Type, :T)::Any)::Any, Expr(:::, :d, Expr(:curly, :NTuple, :N, :Int)::Any)::Any)::Any = Expr(:block, Expr(:line, 1186, :deprecated.jl)::Any, Expr(:call, Expr(:curly, :Array, :T)::Any, :d)::Any)::Any,))))
rec_backtrace at /home/pkm/julia5/julia/src/stackwalk.c:83
record_backtrace at /home/pkm/julia5/julia/src/task.c:228
jl_throw at /home/pkm/julia5/julia/src/task.c:514
eval at /home/pkm/julia5/julia/src/interpreter.c:415
jl_parse_eval_all at /home/pkm/julia5/julia/src/ast.c:773
jl_load at /home/pkm/julia5/julia/src/toplevel.c:583
#218 at ./sysimg.jl:188
jl_call_method_internal at /home/pkm/julia5/julia/src/julia_internal.h:78
do_call at /home/pkm/julia5/julia/src/interpreter.c:58
eval at /home/pkm/julia5/julia/src/interpreter.c:174
jl_toplevel_eval_flex at /home/pkm/julia5/julia/src/toplevel.c:545
jl_toplevel_eval_flex at /home/pkm/julia5/julia/src/toplevel.c:433
jl_toplevel_eval_flex at /home/pkm/julia5/julia/src/toplevel.c:443
jl_parse_eval_all at /home/pkm/julia5/julia/src/ast.c:777
jl_load at /home/pkm/julia5/julia/src/toplevel.c:583
exec_program at /home/pkm/julia5/julia/ui/repl.c:483
true_main at /home/pkm/julia5/julia/ui/repl.c:550
main at /home/pkm/julia5/julia/ui/repl.c:671
unknown function (ip: 0x7f7298be0a3f)
unknown function (ip: 0x401788)
or if I delete all the methods you linked to
docs/core.jl
inference.jl
A method error occurred before the base module was defined. Aborting...
Array
(Any, 9)
while loading inference.jl, in expression starting on line 3467
rec_backtrace at /home/pkm/julia5/julia/src/stackwalk.c:83
jl_method_error_bare at /home/pkm/julia5/julia/src/gf.c:965
jl_method_error at /home/pkm/julia5/julia/src/gf.c:976
jl_apply_generic at /home/pkm/julia5/julia/src/gf.c:1581
Type at ./inference.jl:92
jl_call_method_internal at /home/pkm/julia5/julia/src/julia_internal.h:78
typeinf_edge at ./inference.jl:1498
jl_call_method_internal at /home/pkm/julia5/julia/src/julia_internal.h:78
typeinf at ./inference.jl:1528
jl_call_method_internal at /home/pkm/julia5/julia/src/julia_internal.h:78
macro expansion; at ./inference.jl:3468
jl_call_method_internal at /home/pkm/julia5/julia/src/julia_internal.h:78
jl_parse_eval_all at /home/pkm/julia5/julia/src/ast.c:777
jl_load at /home/pkm/julia5/julia/src/toplevel.c:583
include at ./boot.jl:222
jl_call_method_internal at /home/pkm/julia5/julia/src/julia_internal.h:78
do_call at /home/pkm/julia5/julia/src/interpreter.c:58
eval at /home/pkm/julia5/julia/src/interpreter.c:174
jl_toplevel_eval_flex at /home/pkm/julia5/julia/src/toplevel.c:545
jl_toplevel_eval_flex at /home/pkm/julia5/julia/src/toplevel.c:433
jl_toplevel_eval_flex at /home/pkm/julia5/julia/src/toplevel.c:443
jl_toplevel_eval_in_warn at /home/pkm/julia5/julia/src/builtins.c:547
eval at ./boot.jl:225
jl_call_method_internal at /home/pkm/julia5/julia/src/julia_internal.h:78
do_call at /home/pkm/julia5/julia/src/interpreter.c:58
eval at /home/pkm/julia5/julia/src/interpreter.c:174
jl_toplevel_eval_flex at /home/pkm/julia5/julia/src/toplevel.c:545
jl_parse_eval_all at /home/pkm/julia5/julia/src/ast.c:777
jl_load at /home/pkm/julia5/julia/src/toplevel.c:583
exec_program at /home/pkm/julia5/julia/ui/repl.c:483
true_main at /home/pkm/julia5/julia/ui/repl.c:550
main at /home/pkm/julia5/julia/ui/repl.c:671
unknown function (ip: 0x7f81f1155a3f)
unknown function (ip: 0x401788)
Allocations: 298087 (Pool: 298048; Big: 39); GC: 0
I know I'm doing something wrong, I just can't figure out what.
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.
@deprecate Array{T,N}(::Type{T}, d::NTuple{N,Int}) Array{T}(d)
no =
.
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 first error message says you are calling @deprecate
with the wrong number of arguments), the second error message says you haven't fix the inference.jl for the deprecated constructor yet.
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.
@deprecate
Array{T,N}(::Type{T}, d::NTuple{N,Int}) Array{T}(d) no =.
Obviously, thanks. And thanks, I'll have a look at inference.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.
(Please quote macros.... Apparently there are many creative usernames on github.....)
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.
(Please quote macros.... Apparently there are many creative usernames on github.....)
(Sorry, didn't notice the quote was stripped when quoting using the "r" shortcut )
8b59080
to
d5911d7
Compare
This is great. I think we could merge it as is, and have a followup PR to add the deprecation and clean up any last stragglers? |
Fine by me. I have not been outside of Edit: I am working on |
Some further changes. I still don't fully understand how I should do the deprecation. I can't really find any information about the content and structure of Inference.jl, and consequently I'm unsure what I need to change. I take it the commits will simply be squashed upon merge, so I don't need to do that myself, yes? |
I'm not sure why you want to modify inference.jl, but have a look at deprecated.jl. |
Are we really sure we want to deprecate I guess we will want the array constructor to be I also certainly hope inference.jl doesn't need to be modified for this. |
As for the issue you see in type inference. It seems to be caused by type comprehension. |
Are you referring to the changes in this PR currently, or if
and
Well, if I deprecate the functions mbauman mentioned in comments from a previous commit, I get an error in
Regarding CI, it looks like a timeout at AppVeyor |
@@ -102,7 +102,7 @@ objects: | |||
julia> dump(ex2) | |||
Expr | |||
head: Symbol call | |||
args: Array(Any,(3,)) | |||
args: Array{Any}(3,)) |
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 is missing one (
Maybe we don't have to deprecate the old way, but I think this is a bit better style and more generalizable to other array types without them all having to implement the "eltype as first positional argument" pattern. Besides, I think that pattern is somewhat flawed - ref #11557. |
@@ -586,7 +586,7 @@ to another, you should probably define a ``convert`` method instead. | |||
On the other hand, if your constructor does not represent a lossless | |||
conversion, or doesn't represent "conversion" at all, it is better | |||
to leave it as a constructor rather than a ``convert`` method. For | |||
example, the ``Array(Int)`` constructor creates a zero-dimensional | |||
example, the ``Array{Int}`` constructor creates a zero-dimensional |
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 one is specifically documenting the paren method
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.
Thanks for pointing it out. I will go through everything and look for these mistakes. I'm wondering, though. Should it be Array(Int)
or Array{Int}()
(supporting two syntaxes for one thing... :) ) ? I've changed it to the latter in the actual code.
I'm strongly in favor of deprecating the old way. Having too many ways to write things is just confusing. |
Let's hold off on making this pr any bigger and just merge it when green then, unless anyone sees any other cases that are confusing or typos. The deprecation can be a followup. |
Git error on AppVeyor. |
…base/ for files starting b-e.
…base/ for files starting with f-i.
…base/dSFMT.jl, base/Enums.jl, and base/LineEdit.jl.
…base/ for files starting with l-m.
…base/ for files starting with p-r.
…base/ for files starting with s-t.
Not exactly sure what is happening with AppVeyor. If someone feels like it, you can stop the current runs on both CIs, and I can try to fire them again. I rebased twice within a short amount of time (I have a feeling that many commits are going to cause merge conflicts here... :) ) |
Thanks. I'm not sure if you're doing this already @tkelman, but is it possible to stop the already running and queued runs ? ( https://travis-ci.org/JuliaLang/julia/pull_requests , https://ci.appveyor.com/project/JuliaLang/julia/history ) |
There's some fail-fast code that automatically cancels them quickly when there are newer builds pending for the same PR. edit: that doesn't help for the ones that have already started though, so yeah those are worth cancelling manually |
============================================================================ ============================================ ======================================================================================= | ||
|
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.
sphinx might not like deleting this line but we can deal with that later if it causes any issues
Not quite done, but almost. All tests (besides some string-stuff) pass locally on ubuntu.