
On Thu, May 27, 2010 at 11:40, Vincent Davis vincent@vincentdavis.net wrote:
On Thu, May 27, 2010 at 8:39 AM, Keith Goodman kwgoodman@gmail.com wrote:
To see if it is a number could you use something like: np.issubdtype(a.dtype, float) or np.issubdtype(a.dtype, int) or np.issubdtype(a.dtype, complex)
And for string:
np.issubdtype(a.dtype, str)
These are valid but what I don't like is that I need to know the list of possible number types. Basically I don't like a test that fails because I didn't know about a dtype. For string It is ok, the universe of is either string or not string. Maybe this is as good as it gets.
The dtypes have a hierarchy.
In [2]: np.issubdtype(float, np.number) Out[2]: True
In [3]: np.issubdtype(str, np.number) Out[3]: False
-- Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco