Imagine you have a value that might or might not be one of the NumPy dtypes. How would you write a function that checks which is the case?
def is_numpy(value):
# how to code?
Imagine you have a value that might or might not be one of the NumPy dtypes. How would you write a function that checks which is the case?
def is_numpy(value):
# how to code?
One way I've found that works was used by Mike T in his answer to Converting numpy dtypes to native python types:
def is_numpy(value):
return hasattr(value, 'dtype')
I'm not sure whether or not this is the preferred method, but it's relatively simple and clean.