Thanks to visit codestin.com
Credit goes to github.com

Skip to content

DOC: Document/ Deprecate functions exposed in "numpy" namespace #13222

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 4 commits into from
Jun 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions doc/source/user/basics.io.genfromtxt.rst
Original file line number Diff line number Diff line change
Expand Up @@ -521,12 +521,6 @@ provides several convenience functions derived from
:func:`~numpy.genfromtxt`. These functions work the same way as the
original, but they have different default values.

:func:`~numpy.ndfromtxt`
Always set ``usemask=False``.
The output is always a standard :class:`numpy.ndarray`.
:func:`~numpy.mafromtxt`
Always set ``usemask=True``.
The output is always a :class:`~numpy.ma.MaskedArray`
:func:`~numpy.recfromtxt`
Returns a standard :class:`numpy.recarray` (if ``usemask=False``) or a
:class:`~numpy.ma.MaskedRecords` array (if ``usemaske=True``). The
Expand Down
22 changes: 22 additions & 0 deletions numpy/lib/npyio.py
Original file line number Diff line number Diff line change
Expand Up @@ -2225,6 +2225,12 @@ def ndfromtxt(fname, **kwargs):
"""
Load ASCII data stored in a file and return it as a single array.

.. deprecated:: 1.17
ndfromtxt` is a deprecated alias of `genfromtxt` which
overwrites the ``usemask`` argument with `False` even when
explicitly called as ``ndfromtxt(..., usemask=True)``.
Use `genfromtxt` instead.

Parameters
----------
fname, kwargs : For a description of input parameters, see `genfromtxt`.
Expand All @@ -2235,13 +2241,24 @@ def ndfromtxt(fname, **kwargs):

"""
kwargs['usemask'] = False
# Numpy 1.17
warnings.warn(
"np.ndfromtxt is a deprecated alias of np.genfromtxt, "
"prefer the latter.",
DeprecationWarning, stacklevel=2)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a comment above the warning with the date, version, gh-issue format

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should also recommend a replacement, perhaps `ndfromtxt` is a deprecated alias of `genfromtxt`, prefer the latter

return genfromtxt(fname, **kwargs)


def mafromtxt(fname, **kwargs):
"""
Load ASCII data stored in a text file and return a masked array.

.. deprecated:: 1.17
np.mafromtxt is a deprecated alias of `genfromtxt` which
overwrites the ``usemask`` argument with `True` even when
explicitly called as ``mafromtxt(..., usemask=False)``.
Use `genfromtxt` instead.

Parameters
----------
fname, kwargs : For a description of input parameters, see `genfromtxt`.
Expand All @@ -2252,6 +2269,11 @@ def mafromtxt(fname, **kwargs):

"""
kwargs['usemask'] = True
# Numpy 1.17
warnings.warn(
"np.mafromtxt is a deprecated alias of np.genfromtxt, "
"prefer the latter.",
DeprecationWarning, stacklevel=2)
return genfromtxt(fname, **kwargs)


Expand Down
Loading