Skip to content
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
3 changes: 3 additions & 0 deletions doc/release/upcoming_changes/14256.expired.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* ``numeric.loads``, ``numeric.load``, ``np.ma.dump``,
``np.ma.dumps``, ``np.ma.load``, ``np.ma.loads`` are removed,
use ``pickle`` methods instead
11 changes: 0 additions & 11 deletions doc/source/reference/routines.ma.rst
Original file line number Diff line number Diff line change
Expand Up @@ -264,17 +264,6 @@ Conversion operations
ma.MaskedArray.tobytes


Pickling and unpickling
~~~~~~~~~~~~~~~~~~~~~~~
.. autosummary::
:toctree: generated/

ma.dump
ma.dumps
ma.load
ma.loads


Filling a masked array
~~~~~~~~~~~~~~~~~~~~~~
.. autosummary::
Expand Down
34 changes: 1 addition & 33 deletions numpy/core/numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,6 @@
overrides.array_function_dispatch, module='numpy')


def loads(*args, **kwargs):
# NumPy 1.15.0, 2017-12-10
warnings.warn(
"np.core.numeric.loads is deprecated, use pickle.loads instead",
DeprecationWarning, stacklevel=2)
return pickle.loads(*args, **kwargs)


__all__ = [
'newaxis', 'ndarray', 'flatiter', 'nditer', 'nested_iters', 'ufunc',
'arange', 'array', 'zeros', 'count_nonzero', 'empty', 'broadcast', 'dtype',
Expand All @@ -66,7 +58,7 @@ def loads(*args, **kwargs):
'correlate', 'convolve', 'inner', 'dot', 'outer', 'vdot', 'roll',
'rollaxis', 'moveaxis', 'cross', 'tensordot', 'little_endian',
'fromiter', 'array_equal', 'array_equiv', 'indices', 'fromfunction',
'isclose', 'load', 'loads', 'isscalar', 'binary_repr', 'base_repr', 'ones',
'isclose', 'isscalar', 'binary_repr', 'base_repr', 'ones',
'identity', 'allclose', 'compare_chararrays', 'putmask',
'flatnonzero', 'Inf', 'inf', 'infty', 'Infinity', 'nan', 'NaN',
'False_', 'True_', 'bitwise_not', 'CLIP', 'RAISE', 'WRAP', 'MAXDIMS',
Expand Down Expand Up @@ -2024,30 +2016,6 @@ def base_repr(number, base=2, padding=0):
return ''.join(reversed(res or '0'))


def load(file):
"""
Wrapper around cPickle.load which accepts either a file-like object or
a filename.

Note that the NumPy binary format is not based on pickle/cPickle anymore.
For details on the preferred way of loading and saving files, see `load`
and `save`.

See Also
--------
load, save

"""
# NumPy 1.15.0, 2017-12-10
warnings.warn(
"np.core.numeric.load is deprecated, use pickle.load instead",
DeprecationWarning, stacklevel=2)
if isinstance(file, type("")):
with open(file, "rb") as file_pointer:
return pickle.load(file_pointer)
return pickle.load(file)


# These are all essentially abbreviations
# These might wind up in a special abbreviations module

Expand Down
91 changes: 2 additions & 89 deletions numpy/ma/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@
'choose', 'clip', 'common_fill_value', 'compress', 'compressed',
'concatenate', 'conjugate', 'convolve', 'copy', 'correlate', 'cos', 'cosh',
'count', 'cumprod', 'cumsum', 'default_fill_value', 'diag', 'diagonal',
'diff', 'divide', 'dump', 'dumps', 'empty', 'empty_like', 'equal', 'exp',
'diff', 'divide', 'empty', 'empty_like', 'equal', 'exp',
'expand_dims', 'fabs', 'filled', 'fix_invalid', 'flatten_mask',
'flatten_structured_array', 'floor', 'floor_divide', 'fmod',
'frombuffer', 'fromflex', 'fromfunction', 'getdata', 'getmask',
'getmaskarray', 'greater', 'greater_equal', 'harden_mask', 'hypot',
'identity', 'ids', 'indices', 'inner', 'innerproduct', 'isMA',
'isMaskedArray', 'is_mask', 'is_masked', 'isarray', 'left_shift',
'less', 'less_equal', 'load', 'loads', 'log', 'log10', 'log2',
'less', 'less_equal', 'log', 'log10', 'log2',
'logical_and', 'logical_not', 'logical_or', 'logical_xor', 'make_mask',
'make_mask_descr', 'make_mask_none', 'mask_or', 'masked',
'masked_array', 'masked_equal', 'masked_greater',
Expand Down Expand Up @@ -7886,93 +7886,6 @@ def _pickle_warn(method):
stacklevel=3)


def dump(a, F):
"""
Pickle a masked array to a file.

This is a wrapper around ``cPickle.dump``.

Parameters
----------
a : MaskedArray
The array to be pickled.
F : str or file-like object
The file to pickle `a` to. If a string, the full path to the file.

"""
_pickle_warn('dump')
if not hasattr(F, 'readline'):
with open(F, 'w') as F:
pickle.dump(a, F)
else:
pickle.dump(a, F)


def dumps(a):
"""
Return a string corresponding to the pickling of a masked array.

This is a wrapper around ``cPickle.dumps``.

Parameters
----------
a : MaskedArray
The array for which the string representation of the pickle is
returned.

"""
_pickle_warn('dumps')
return pickle.dumps(a)


def load(F):
"""
Wrapper around ``cPickle.load`` which accepts either a file-like object
or a filename.

Parameters
----------
F : str or file
The file or file name to load.

See Also
--------
dump : Pickle an array

Notes
-----
This is different from `numpy.load`, which does not use cPickle but loads
the NumPy binary .npy format.

"""
_pickle_warn('load')
if not hasattr(F, 'readline'):
with open(F, 'r') as F:
return pickle.load(F)
else:
return pickle.load(F)


def loads(strg):
"""
Load a pickle from the current string.

The result of ``cPickle.loads(strg)`` is returned.

Parameters
----------
strg : str
The string to load.

See Also
--------
dumps : Return a string corresponding to the pickling of a masked array.

"""
_pickle_warn('loads')
return pickle.loads(strg)


def fromfile(file, dtype=float, count=-1, sep=''):
raise NotImplementedError(
"fromfile() not yet implemented for a MaskedArray.")
Expand Down