8000 Consistency of docstrings between `ones`, `zeros` and `empty`. · Issue #10611 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

Consistency of docstrings between ones, zeros and empty. #10611

@godaygo

Description

@godaygo

There is some inconsistency in docstrings for 3 frequently used constructor functions:

  • ones
  • zeros
  • empty
  1. The docstring for ones looks as follows:
ones(shape, dtype=None, order='C'):
    """
    Return a new array of given shape and type, filled with ones.

    Parameters
    ----------
    shape : int or sequence of ints
        Shape of the new array, e.g., ``(2, 3)`` or ``2``.
    dtype : data-type, optional
        The desired data-type for the array, e.g., `numpy.int8`.  Default is
        `numpy.float64`.
    order : {'C', 'F'}, optional
        Whether to store multidimensional data in C- or Fortran-contiguous
        (row- or column-wise) order in memory.

Interesting part here is signature ones(shape, dtype=None, order='C'), and dtype=None. While dtype description it is said that "Default is numpy.float64". For other two functions the signatures are:

zeros(shape, dtype=float, order='C')
empty(shape, dtype=float, order='C')

While they are better, they are also incorrect -> should be dtype=double or dtype=float64.

  1. The description of parameters for ones and zeros a pretty identical. But for the empty it is somewhat stripped down:
Docstring:
empty(shape, dtype=float, order='C')

Return a new array of given shape and type, without initializing entries.

Parameters
----------
shape : int or tuple of int
    Shape of the empty array
dtype : data-type, optional
    Desired output data-type.
order : {'C', 'F'}, optional
    Whether to store multi-dimensional data in row-major
    (C-style) or column-major (Fortran-style) order in
    memory.

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