-
-
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
Should dropdims accept dims as a regular argument? #28906
Comments
I agree, I think this should be the standard for a lot of these new keyword argument methods. Also see #28303 . |
Yeah, this was a choice that seemed much more obvious back when the function was still called One thing specific to |
Yes, it does make much more sense in light of the name For reductions, maybe In that issue Jeff and Keno say
but that does not seem to be the case e.g. for
|
|
shouldn't Say julia> A1
1×4 Array{Int64,2}:
1 2 3 4
dropdims(A1,dims=1)
4-element Array{Int64,1}:
1
2
3
4 proposed dropdims(A1)
4-element Array{Int64,1}:
1
2
3
4 |
Doing it automatically is a source of bugs (e.g., https://groups.google.com/d/msg/julia-users/wfEEvYIHVGs/caBXtuZulXgJ), and also not inferrable. |
Although it is good to keep the code type stable, we shouldn't forget that Julia is a dynamic language and having such method will get the job done, especially if the array is constructed somewhere else and we need to squeeze the dimensions. |
Among the functions for reshaping arrays (
reshape
,permutedims
,dropdims
),dropdims
is the only one that acceptsdims
as a keyword argument — the rest take dimensions as a positional argument.Also, it feels a little redundant to have to say "dims" twice, once in the argument and once in the name of the function:
Note: It's possible to make this change backwards-compatibly by accepting both the keyword and positional argument.
The text was updated successfully, but these errors were encountered: