summaryrefslogtreecommitdiff
path: root/numpy/lib/recfunctions.py
diff options
context:
space:
mode:
authorDevin Shanahan <dshanahan88@gmail.com>2022-01-16 05:12:59 -0700
committerDevin Shanahan <dshanahan88@gmail.com>2022-01-16 05:12:59 -0700
commit0f66b6032a2c5039007d5041398561b452ddabef (patch)
treed030c1ae812e138f74a29b280cddde376d821ab8 /numpy/lib/recfunctions.py
parent5a52c717fe45c7c6bdc3d20b178a00bffbe9e24e (diff)
parent7191d9a4773d77205349ac151f84b72c0ffcf848 (diff)
downloadnumpy-0f66b6032a2c5039007d5041398561b452ddabef.tar.gz
MAINT: Merge branch 'main' into delete-speedup
Diffstat (limited to 'numpy/lib/recfunctions.py')
-rw-r--r--numpy/lib/recfunctions.py30
1 files changed, 17 insertions, 13 deletions
diff --git a/numpy/lib/recfunctions.py b/numpy/lib/recfunctions.py
index a11d5f2c7..ee4fbcd74 100644
--- a/numpy/lib/recfunctions.py
+++ b/numpy/lib/recfunctions.py
@@ -513,7 +513,7 @@ def drop_fields(base, drop_names, usemask=True, asrecarray=False):
Nested fields are supported.
- ..versionchanged: 1.18.0
+ .. versionchanged:: 1.18.0
`drop_fields` returns an array with 0 fields if all fields are dropped,
rather than returning ``None`` as it did previously.
@@ -784,7 +784,8 @@ def repack_fields(a, align=False, recurse=False):
This method removes any overlaps and reorders the fields in memory so they
have increasing byte offsets, and adds or removes padding bytes depending
- on the `align` option, which behaves like the `align` option to `np.dtype`.
+ on the `align` option, which behaves like the `align` option to
+ `numpy.dtype`.
If `align=False`, this method produces a "packed" memory layout in which
each field starts at the byte the previous field ended, and any padding
@@ -819,7 +820,8 @@ def repack_fields(a, align=False, recurse=False):
...
>>> dt = np.dtype('u1, <i8, <f8', align=True)
>>> dt
- dtype({'names':['f0','f1','f2'], 'formats':['u1','<i8','<f8'], 'offsets':[0,8,16], 'itemsize':24}, align=True)
+ dtype({'names': ['f0', 'f1', 'f2'], 'formats': ['u1', '<i8', '<f8'], \
+'offsets': [0, 8, 16], 'itemsize': 24}, align=True)
>>> print_offsets(dt)
offsets: [0, 8, 16]
itemsize: 24
@@ -899,7 +901,7 @@ def _structured_to_unstructured_dispatcher(arr, dtype=None, copy=None,
@array_function_dispatch(_structured_to_unstructured_dispatcher)
def structured_to_unstructured(arr, dtype=None, copy=False, casting='unsafe'):
"""
- Converts and n-D structured array into an (n+1)-D unstructured array.
+ Converts an n-D structured array into an (n+1)-D unstructured array.
The new array will have a new last dimension equal in size to the
number of field-elements of the input array. If not supplied, the output
@@ -916,11 +918,12 @@ def structured_to_unstructured(arr, dtype=None, copy=False, casting='unsafe'):
dtype : dtype, optional
The dtype of the output unstructured array.
copy : bool, optional
- See copy argument to `ndarray.astype`. If true, always return a copy.
- If false, and `dtype` requirements are satisfied, a view is returned.
+ See copy argument to `numpy.ndarray.astype`. If true, always return a
+ copy. If false, and `dtype` requirements are satisfied, a view is
+ returned.
casting : {'no', 'equiv', 'safe', 'same_kind', 'unsafe'}, optional
- See casting argument of `ndarray.astype`. Controls what kind of data
- casting may occur.
+ See casting argument of `numpy.ndarray.astype`. Controls what kind of
+ data casting may occur.
Returns
-------
@@ -996,7 +999,7 @@ def _unstructured_to_structured_dispatcher(arr, dtype=None, names=None,
def unstructured_to_structured(arr, dtype=None, names=None, align=False,
copy=False, casting='unsafe'):
"""
- Converts and n-D unstructured array into an (n-1)-D structured array.
+ Converts an n-D unstructured array into an (n-1)-D structured array.
The last dimension of the input array is converted into a structure, with
number of field-elements equal to the size of the last dimension of the
@@ -1019,11 +1022,12 @@ def unstructured_to_structured(arr, dtype=None, names=None, align=False,
align : boolean, optional
Whether to create an aligned memory layout.
copy : bool, optional
- See copy argument to `ndarray.astype`. If true, always return a copy.
- If false, and `dtype` requirements are satisfied, a view is returned.
+ See copy argument to `numpy.ndarray.astype`. If true, always return a
+ copy. If false, and `dtype` requirements are satisfied, a view is
+ returned.
casting : {'no', 'equiv', 'safe', 'same_kind', 'unsafe'}, optional
- See casting argument of `ndarray.astype`. Controls what kind of data
- casting may occur.
+ See casting argument of `numpy.ndarray.astype`. Controls what kind of
+ data casting may occur.
Returns
-------