summaryrefslogtreecommitdiff
path: root/numpy/lib/_iotools.py
diff options
context:
space:
mode:
authorJarrod Millman <millman@berkeley.edu>2009-11-13 17:49:06 +0000
committerJarrod Millman <millman@berkeley.edu>2009-11-13 17:49:06 +0000
commitf07c79d3709a7f81219abc3c516fd772f469c167 (patch)
treeeaff2baba0176a7c41e749fd61b88a421dcfb188 /numpy/lib/_iotools.py
parent3122ee546fc0617e195aeb288abe65b9ae95d983 (diff)
downloadnumpy-f07c79d3709a7f81219abc3c516fd772f469c167.tar.gz
first set of checkins from the doc editor
Diffstat (limited to 'numpy/lib/_iotools.py')
-rw-r--r--numpy/lib/_iotools.py34
1 files changed, 27 insertions, 7 deletions
diff --git a/numpy/lib/_iotools.py b/numpy/lib/_iotools.py
index c69bd84dc..2c062f1b0 100644
--- a/numpy/lib/_iotools.py
+++ b/numpy/lib/_iotools.py
@@ -391,12 +391,29 @@ def str2bool(value):
class ConverterError(Exception):
+ """
+ Exception raised when an error occurs in a converter for string values.
+
+ """
pass
class ConverterLockError(ConverterError):
+ """
+ Exception raised when an attempt is made to upgrade a locked converter.
+
+ """
pass
class ConversionWarning(UserWarning):
+ """
+ Warning issued when a string converter has a problem.
+
+ Notes
+ -----
+ In `genfromtxt` a `ConversionWarning` is issued if raising exceptions
+ is explicitly suppressed with the "invalid_raise" keyword.
+
+ """
pass
@@ -708,22 +725,23 @@ def easy_dtype(ndtype, names=None, defaultfmt="f%i", **validationargs):
"""
Convenience function to create a `np.dtype` object.
- The function processes the input dtype and matches it with the given names.
+ The function processes the input `dtype` and matches it with the given
+ names.
Parameters
----------
ndtype : var
- Definition of the dtype. Can be any string or dictionary recognized
- by the `np.dtype` function or a sequence of types.
+ Definition of the dtype. Can be any string or dictionary
+ recognized by the `np.dtype` function, or a sequence of types.
names : str or sequence, optional
Sequence of strings to use as field names for a structured dtype.
For convenience, `names` can be a string of a comma-separated list of
- names
+ names.
defaultfmt : str, optional
- Format string used to define missing names, such as "f%i" (default),
- "fields_%02i"...
+ Format string used to define missing names, such as ``"f%i"``
+ (default) or ``"fields_%02i"``.
validationargs : optional
- A series of optional arguments used to initialize a NameValidator.
+ A series of optional arguments used to initialize a `NameValidator`.
Examples
--------
@@ -733,10 +751,12 @@ def easy_dtype(ndtype, names=None, defaultfmt="f%i", **validationargs):
dtype([('f0', '<i4'), ('f1', '<f8')])
>>> np.lib._iotools.easy_dtype("i4, f8", defaultfmt="field_%03i")
dtype([('field_000', '<i4'), ('field_001', '<f8')])
+
>>> np.lib._iotools.easy_dtype((int, float, float), names="a,b,c")
dtype([('a', '<i8'), ('b', '<f8'), ('c', '<f8')])
>>> np.lib._iotools.easy_dtype(float, names="a,b,c")
dtype([('a', '<f8'), ('b', '<f8'), ('c', '<f8')])
+
"""
try:
ndtype = np.dtype(ndtype)