Content-Length: 331582 | pFad | http://github.com/numpy/numpy/pull/29402

C9 DOC: Correct more ndarray defaults by MarcoGorelli · Pull Request #29402 · numpy/numpy · GitHub
Skip to content

DOC: Correct more ndarray defaults #29402

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

Merged
merged 1 commit into from
Jul 24, 2025
Merged

Conversation

MarcoGorelli
Copy link
Member

@MarcoGorelli MarcoGorelli commented Jul 21, 2025

Follow-up to https://github.com/numpy/numpy/pull/29387/files

These are the other methods which have a np._NoDefault default, and all the arguments just get forwarded to the corresponding top-level function

all:

static PyObject *
array_all(PyArrayObject *self,
PyObject *const *args, Py_ssize_t len_args, PyObject *kwnames)
{
NPY_FORWARD_NDARRAY_METHOD(_all);
}

@array_function_dispatch(_all_dispatcher)
def all(a, axis=None, out=None, keepdims=np._NoValue, *, where=np._NoValue):

any:

static PyObject *
array_any(PyArrayObject *self,
PyObject *const *args, Py_ssize_t len_args, PyObject *kwnames)
{
NPY_FORWARD_NDARRAY_METHOD(_any);
}

@array_function_dispatch(_any_dispatcher)
def any(a, axis=None, out=None, keepdims=np._NoValue, *, where=np._NoValue):

clip:

static PyObject *
array_clip(PyArrayObject *self,
PyObject *const *args, Py_ssize_t len_args, PyObject *kwnames)
{
NPY_FORWARD_NDARRAY_METHOD(_clip);
}

@array_function_dispatch(_clip_dispatcher)
def clip(a, a_min=np._NoValue, a_max=np._NoValue, out=None, *,
min=np._NoValue, max=np._NoValue, **kwargs):

max:

static PyObject *
array_max(PyArrayObject *self,
PyObject *const *args, Py_ssize_t len_args, PyObject *kwnames)
{
NPY_FORWARD_NDARRAY_METHOD(_amax);
}

@array_function_dispatch(_max_dispatcher)
@set_module('numpy')
def max(a, axis=None, out=None, keepdims=np._NoValue, initial=np._NoValue,
where=np._NoValue):

min:

static PyObject *
array_min(PyArrayObject *self,
PyObject *const *args, Py_ssize_t len_args, PyObject *kwnames)
{
NPY_FORWARD_NDARRAY_METHOD(_amin);
}

@array_function_dispatch(_min_dispatcher)
def min(a, axis=None, out=None, keepdims=np._NoValue, initial=np._NoValue,
where=np._NoValue):

mean:

static PyObject *
array_mean(PyArrayObject *self,
PyObject *const *args, Py_ssize_t len_args, PyObject *kwnames)
{
NPY_FORWARD_NDARRAY_METHOD(_mean);
}

@array_function_dispatch(_mean_dispatcher)
def mean(a, axis=None, dtype=None, out=None, keepdims=np._NoValue, *,
where=np._NoValue):

prod:

static PyObject *
array_prod(PyArrayObject *self,
PyObject *const *args, Py_ssize_t len_args, PyObject *kwnames)
{
NPY_FORWARD_NDARRAY_METHOD(_prod);
}

@array_function_dispatch(_prod_dispatcher)
def prod(a, axis=None, dtype=None, out=None, keepdims=np._NoValue,
initial=np._NoValue, where=np._NoValue):

std:

static PyObject *
array_stddev(PyArrayObject *self,
PyObject *const *args, Py_ssize_t len_args, PyObject *kwnames)
{
NPY_FORWARD_NDARRAY_METHOD(_std);
}

@array_function_dispatch(_std_dispatcher)
def std(a, axis=None, dtype=None, out=None, ddof=0, keepdims=np._NoValue, *,
where=np._NoValue, mean=np._NoValue, correction=np._NoValue):

sum:

static PyObject *
array_sum(PyArrayObject *self,
PyObject *const *args, Py_ssize_t len_args, PyObject *kwnames)
{
NPY_FORWARD_NDARRAY_METHOD(_sum);
}

@array_function_dispatch(_sum_dispatcher)
def sum(a, axis=None, dtype=None, out=None, keepdims=np._NoValue,
initial=np._NoValue, where=np._NoValue):

var:

static PyObject *
array_variance(PyArrayObject *self,
PyObject *const *args, Py_ssize_t len_args, PyObject *kwnames)
{
NPY_FORWARD_NDARRAY_METHOD(_var);
}

@array_function_dispatch(_var_dispatcher)
def var(a, axis=None, dtype=None, out=None, ddof=0, keepdims=np._NoValue, *,
where=np._NoValue, mean=np._NoValue, correction=np._NoValue):

@MarcoGorelli MarcoGorelli marked this pull request as ready for review July 21, 2025 12:49
@ngoldbaum
Copy link
Member

Thanks so much for carefully going through and updating these to reflect the actual implementation.

IMO this is OK to merge and I don’t think this can impact downstream unless they’re parsing docstrings and that’s error-prone anyway.

@jorenham do you agree with that?

@jorenham
Copy link
Member

Yea I agree that this is a great fix

@jorenham jorenham merged commit 9812a3f into numpy:main Jul 24, 2025
77 checks passed
@jorenham
Copy link
Member

Thanks Marco!

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

Successfully merging this pull request may close these issues.

3 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/numpy/numpy/pull/29402

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy