summaryrefslogtreecommitdiff
path: root/numpy/add_newdocs.py
diff options
context:
space:
mode:
authorJulian Taylor <jtaylor.debian@googlemail.com>2014-07-19 12:02:09 +0200
committerJulian Taylor <jtaylor.debian@googlemail.com>2014-07-27 20:04:44 +0200
commitef269d55dfc11b9ca3a66b71c8d0e64703a8f359 (patch)
tree1c02ae614b982e6750b4de14d2e3f744a6cb41d7 /numpy/add_newdocs.py
parent0bdd45a6305b0f0526d092c480b6fcd28f574892 (diff)
downloadnumpy-ef269d55dfc11b9ca3a66b71c8d0e64703a8f359.tar.gz
DOC: fix documented return value of tostring/tobytes
The function returns bytes not strings. This is relevant in python3.
Diffstat (limited to 'numpy/add_newdocs.py')
-rw-r--r--numpy/add_newdocs.py22
1 files changed, 12 insertions, 10 deletions
diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py
index 86ea4b8b6..aca0c2eb2 100644
--- a/numpy/add_newdocs.py
+++ b/numpy/add_newdocs.py
@@ -4459,12 +4459,12 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('tolist',
tobytesdoc = """
- a.tostring(order='C')
+ a.{name}(order='C')
- Construct a Python string containing the raw data bytes in the array.
+ Construct Python bytes containing the raw data bytes in the array.
- Constructs a Python string showing a copy of the raw contents of
- data memory. The string can be produced in either 'C' or 'Fortran',
+ Constructs Python bytes showing a copy of the raw contents of
+ data memory. The bytes object can be produced in either 'C' or 'Fortran',
or 'Any' order (the default is 'C'-order). 'Any' order means C-order
unless the F_CONTIGUOUS flag in the array is set, in which case it
means 'Fortran' order.
@@ -4479,29 +4479,31 @@ tobytesdoc = """
Returns
-------
- s : str
- A Python string exhibiting a copy of `a`'s raw data.
+ s : bytes
+ Python bytes exhibiting a copy of `a`'s raw data.
Examples
--------
>>> x = np.array([[0, 1], [2, 3]])
>>> x.tobytes()
- '\\x00\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x02\\x00\\x00\\x00\\x03\\x00\\x00\\x00'
+ b'\\x00\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x02\\x00\\x00\\x00\\x03\\x00\\x00\\x00'
>>> x.tobytes('C') == x.tobytes()
True
>>> x.tobytes('F')
- '\\x00\\x00\\x00\\x00\\x02\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x03\\x00\\x00\\x00'
+ b'\\x00\\x00\\x00\\x00\\x02\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x03\\x00\\x00\\x00'
"""
add_newdoc('numpy.core.multiarray', 'ndarray',
- ('tostring', tobytesdoc.format(deprecated=
+ ('tostring', tobytesdoc.format(name='tostring',
+ deprecated=
'This function is a compatibility '
'alias for tobytes. Despite its '
'name it returns bytes not '
'strings.')))
add_newdoc('numpy.core.multiarray', 'ndarray',
- ('tobytes', tobytesdoc.format(deprecated='.. versionadded:: 1.9.0')))
+ ('tobytes', tobytesdoc.format(name='tobytes',
+ deprecated='.. versionadded:: 1.9.0')))
add_newdoc('numpy.core.multiarray', 'ndarray', ('trace',
"""