summaryrefslogtreecommitdiff
path: root/numpy/lib/format.py
diff options
context:
space:
mode:
authoriamsoto <iambriansoto@gmail.com>2020-06-25 15:34:02 -0700
committeriamsoto <iambriansoto@gmail.com>2020-06-25 15:55:47 -0700
commitccfa661c2551a882946f383785c17820e079d7b1 (patch)
treeda267ae6730a3f01477144a848740d0dacb7fe8b /numpy/lib/format.py
parentc37dc5f1cf5d42ddf05e0cd04a7fc528f30f20e5 (diff)
downloadnumpy-ccfa661c2551a882946f383785c17820e079d7b1.tar.gz
DOC: fixed docstring for descr_to_dtype
DOC: fixed docstring for descr_to_dtype
Diffstat (limited to 'numpy/lib/format.py')
-rw-r--r--numpy/lib/format.py28
1 files changed, 20 insertions, 8 deletions
diff --git a/numpy/lib/format.py b/numpy/lib/format.py
index 98c3cb63f..4e6e731c1 100644
--- a/numpy/lib/format.py
+++ b/numpy/lib/format.py
@@ -280,14 +280,26 @@ def dtype_to_descr(dtype):
return dtype.str
def descr_to_dtype(descr):
- '''
- descr may be stored as dtype.descr, which is a list of
- (name, format, [shape]) tuples where format may be a str or a tuple.
- Offsets are not explicitly saved, rather empty fields with
- name, format == '', '|Vn' are added as padding.
-
- This function reverses the process, eliminating the empty padding fields.
- '''
+ """
+ Returns a dtype based off the given description.
+
+ This is essentially the reverse of `dtype_to_descr()`. It will remove
+ the valueless padding fields created by, i.e. simple fields like
+ dtype('float32'), and then convert the description to its corresponding
+ dtype.
+
+ Parameters
+ ----------
+ descr : object
+ The object retreived by dtype.descr. Can be passed to
+ `numpy.dtype()` in order to replicate the input dtype.
+
+ Returns
+ -------
+ dtype : dtype
+ The dtype constructed by the description.
+
+ """
if isinstance(descr, str):
# No padding removal needed
return numpy.dtype(descr)