10000 DOC: Invalid docstring for numpy.fix (?) · Issue #27257 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content
DOC: Invalid docstring for numpy.fix (?) #27257
@serge-sans-paille

Description

@serge-sans-paille

Issue with current documentation:

The documentation for numpy.fix states it returns a float for integral values, but running the actual code make it return an integral value:

$ python -c 'from numpy.version import full_version; import numpy; print(full_version); print(numpy.fix.__doc__); print(numpy.fix(3))'                                                                                                                                                                         
2.1.0

    Round to nearest integer towards zero.

    Round an array of floats element-wise to nearest integer towards zero.
    The rounded values are returned as floats.

    Parameters
    ----------
    x : array_like
        An array of floats to be rounded
    out : ndarray, optional
        A location into which the result is stored. If provided, it must have
        a shape that the input broadcasts to. If not provided or None, a
        freshly-allocated array is returned.

    Returns
    -------
    out : ndarray of floats
        A float array with the same dimensions as the input.
        If second argument is not supplied then a float array is returned
        with the rounded values.

        If a second argument is supplied the result is stored there.
        The return value `out` is then a reference to that array.

    See Also
    --------
    rint, trunc, floor, ceil
    around : Round to given number of decimals

    Examples
    --------
    >>> import numpy as np
    >>> np.fix(3.14)
    3.0
    >>> np.fix(3)
    3.0
    >>> np.fix([2.1, 2.9, -2.1, -2.9])
    array([ 2.,  2., -2., -2.])

    
3

In addition to this unconsistency, it worries me that docstring would be invalid... does that mean we're not running doctest?

Idea or request for content:

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0