8000 numpy.gradient inconsistent returns · Issue #7548 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content
numpy.gradient inconsistent returns #7548
Closed
@kcbrowning

Description

@kcbrowning
x = np.arange(20)
np.gradient(x)

returns an array. While,

x = np.arange(20)
x = x.resape(10,2)
np.gradient(x)

returns a list of arrays. For consistency the returns should be the same or force a default axis=0 argument so that an array is always returned.

As a side note, it would be nice if gradient could handle the following...

x = np.arange(20)
x = x.resape(10,2,1)
np.gradient(x)

ValueError: Shape of array too small to calculate a numerical gradient, at least two elements are required.

and only fail if the user requests the gradient along the signal element axis.

Metadata

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

      0