[SciPy-User] determining if structured/rec array
Sun Mar 21 20:43:33 CDT 2010
On Mar 21, 2010, at 12:12 PM, Skipper Seabold wrote:
> Is there anywhere in scipy that works on structured arrays
> dynamically? If not, is this a good way to determine if a structured/
> rec array was given to a function or is there a better/easier way?
> import numpy as np
> def isstructarray(X):
> Returns a bool indicating if X is a structured or recarray.
> X : ndarray or subclass
> True or False, indicating if X is a structured or recarray.
> if X.__class__ is np.recarray or (isinstance(X, np.ndarray) and\
> return True
> return False
Meh. As long as dtype.names is not None, you have a structured array (recarrays are by definition structured arrays). Looks like a function that doesn't really do anything...
More information about the SciPy-User