[Numpy-discussion] As any array, really any array
Luis Pedro Coelho
lpc at cmu.edu
Mon Aug 15 22:42:43 EDT 2011
Hello all,
I often find myself writing the following code:
try:
features = np.asanyarray(features)
except:
features = np.asanyarray(features, dtype=object)
I basically want to be able to use fany indexing on features and, in most
cases, it will be a numpy floating point array. Otherwise, default to having it
be an array of dtype=object.
Is there a more elegant way to do it with numpy?
Thank you,
--
Luis Pedro Coelho | Carnegie Mellon University | http://luispedro.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20110815/2efb9b19/attachment.sig>
More information about the NumPy-Discussion
mailing list