Skip to content

Should dropdims accept dims as a regular argument? #28906

Open

Description

Among the functions for reshaping arrays (reshape, permutedims, dropdims), dropdims is the only one that accepts dims as a keyword argument — the rest take dimensions as a positional argument.

julia> permutedims([1 2 3], (2, 1))
3×1 Array{Int64,2}:
 1
 2
 3

Also, it feels a little redundant to have to say "dims" twice, once in the argument and once in the name of the function:

julia> dropdims([1 2 3], dims=(1,))
3-element Array{Int64,1}:
 1
 2
 3

julia> dropdims([1 2 3], (1,))
ERROR: MethodError: no method matching dropdims(::Array{Int64,2}, ::Tuple{Int64})

Note: It's possible to make this change backwards-compatibly by accepting both the keyword and positional argument.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions