diff options
| author | Julian Taylor <jtaylor.debian@googlemail.com> | 2014-02-03 20:01:07 +0100 |
|---|---|---|
| committer | Julian Taylor <jtaylor.debian@googlemail.com> | 2014-02-11 19:30:21 +0100 |
| commit | 2facd5cbdcaa08b61270c0c0760a39cd03acc007 (patch) | |
| tree | 7001911b928ecc830184633e209bd052073d6895 /doc | |
| parent | b7850701a31127cad8c7399cea6be9cd5f71bec5 (diff) | |
| download | numpy-2facd5cbdcaa08b61270c0c0760a39cd03acc007.tar.gz | |
ENH: add tobytes and stop using tostring in documentation
tostring returns bytes which are not equal to string, so provide a
tobytes function alias.
tostring does not emit a deprecation warning yet so rdepends do not need
to check two names to support older versions of numpy without warnings.
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/numpybook/capi.lyx | 2 | ||||
| -rw-r--r-- | doc/numpybook/numpybook.lyx | 12 | ||||
| -rw-r--r-- | doc/release/1.9.0-notes.rst | 8 | ||||
| -rw-r--r-- | doc/source/reference/arrays.ndarray.rst | 1 | ||||
| -rw-r--r-- | doc/source/reference/c-api.array.rst | 2 | ||||
| -rw-r--r-- | doc/source/reference/maskedarray.baseclass.rst | 1 | ||||
| -rw-r--r-- | doc/source/reference/routines.ma.rst | 2 |
7 files changed, 19 insertions, 9 deletions
diff --git a/doc/numpybook/capi.lyx b/doc/numpybook/capi.lyx index 94f18362a..a5c835523 100644 --- a/doc/numpybook/capi.lyx +++ b/doc/numpybook/capi.lyx @@ -9384,7 +9384,7 @@ self \emph default . \series bold -tostring +tobytes \series default ( \emph on diff --git a/doc/numpybook/numpybook.lyx b/doc/numpybook/numpybook.lyx index 59f51b4eb..65185a2be 100644 --- a/doc/numpybook/numpybook.lyx +++ b/doc/numpybook/numpybook.lyx @@ -6062,9 +6062,9 @@ name "ndarray!methods!itemset" \end_layout \begin_layout Description -tostring +tobytes \begin_inset LatexCommand index -name "ndarray!methods!tostring" +name "ndarray!methods!tobytes" \end_inset @@ -6134,7 +6134,7 @@ format the shape, type, or endianness of an array. When written in binary mode, tofile is functionally equivalent to \family typewriter -fid.write(self.tostring()) +fid.write(self.tobytes()) \family default . \end_layout @@ -6836,7 +6836,7 @@ Insert scalar (last argument) into array \begin_layout Standard \series bold -tostring +tobytes \end_layout \end_inset @@ -9450,7 +9450,7 @@ name "ndarray!special methods!setstate" ). In this tuple, isfortran is a Bool stating whether the following flattened data is in Fortran order or not, and string_or_list is a string formed - by self.tostring() if the data type is not object. + by self.tobytes() if the data type is not object. If the data type of self is an object array, then string_or_list is a flat list equivalent to self.ravel().tolist(). @@ -17719,7 +17719,7 @@ __reduce__ () \InsetSpace ~ This is called to pickle an array scalar. It returns a tuple of (numpy.core.multiarray.scalar, self.dtypestr, obj or - self.tostring()) which can be used to reconstruct the scalar on unpickling. + self.tobytes()) which can be used to reconstruct the scalar on unpickling. Notice that no state is written, because the entire scalar can be constructed from just the string. Also, if this is an object array scalar, then the Python object being reference diff --git a/doc/release/1.9.0-notes.rst b/doc/release/1.9.0-notes.rst index 1d382ff03..8047fbd3a 100644 --- a/doc/release/1.9.0-notes.rst +++ b/doc/release/1.9.0-notes.rst @@ -74,6 +74,14 @@ Dtype parameter added to `np.linspace` and `np.logspace` The returned data type from the `linspace` and `logspace` functions can now be specificed using the dtype parameter. + +`tobytes` alias for `tostring` method +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`ndarray.tobytes` and `MaskedArray.tobytes` have been added as aliases for +`tostring` which exports arrays as `bytes`. This is more consistent in Python 3 +where `str` and `bytes` are not the same. + + Improvements ============ diff --git a/doc/source/reference/arrays.ndarray.rst b/doc/source/reference/arrays.ndarray.rst index 85e41c215..e9c0a6d87 100644 --- a/doc/source/reference/arrays.ndarray.rst +++ b/doc/source/reference/arrays.ndarray.rst @@ -294,6 +294,7 @@ Array conversion ndarray.itemset ndarray.setasflat ndarray.tostring + ndarray.tobytes ndarray.tofile ndarray.dump ndarray.dumps diff --git a/doc/source/reference/c-api.array.rst b/doc/source/reference/c-api.array.rst index 6e68a9a0e..323ca0655 100644 --- a/doc/source/reference/c-api.array.rst +++ b/doc/source/reference/c-api.array.rst @@ -1574,7 +1574,7 @@ Conversion .. cfunction:: PyObject* PyArray_ToString(PyArrayObject* self, NPY_ORDER order) - Equivalent to :meth:`ndarray.tostring` (*self*, *order*). Return the bytes + Equivalent to :meth:`ndarray.tobytes` (*self*, *order*). Return the bytes of this array in a Python string. .. cfunction:: PyObject* PyArray_ToFile(PyArrayObject* self, FILE* fp, char* sep, char* format) diff --git a/doc/source/reference/maskedarray.baseclass.rst b/doc/source/reference/maskedarray.baseclass.rst index fd1fd7ae6..a1c90a45d 100644 --- a/doc/source/reference/maskedarray.baseclass.rst +++ b/doc/source/reference/maskedarray.baseclass.rst @@ -200,6 +200,7 @@ Conversion MaskedArray.tolist MaskedArray.torecords MaskedArray.tostring + MaskedArray.tobytes Shape manipulation diff --git a/doc/source/reference/routines.ma.rst b/doc/source/reference/routines.ma.rst index 6eda37578..5cb38e83f 100644 --- a/doc/source/reference/routines.ma.rst +++ b/doc/source/reference/routines.ma.rst @@ -251,7 +251,7 @@ Conversion operations ma.MaskedArray.tofile ma.MaskedArray.tolist ma.MaskedArray.torecords - ma.MaskedArray.tostring + ma.MaskedArray.tobytes Pickling and unpickling |
