When using numpy array the type of the array is given by the "dtype" variable of the array. So if your array is int then array.dtype will be 'int32'. Numpy uses more complex data types then just int and floats so you might want to check all the available data types.
In : a = array([1,2,3]) In : a.dtype Out: dtype('int32')
In : b = array([1.,2.,3.]) In : b.dtype Out: dtype('float64')
OR (Strings) In : c = array(['sdf', 'fff', 'tye']) In : c.dtype Out: dtype('|S3') # This could also be 'Sxxx' where xxx is the length of the largest string in the array
Alternatively, as a hackjob type check you could also do an "isinstance" check on the first element of the array since, unlike lists, arrays have uniform elements all the way through.
Hope that helps,
- Simon Berube
P.S.: Someone please correct me if there's a better way.
On Apr 29, 6:51 am, dmitrey open...@ukr.net wrote:
hi all, please inform me what is the simplest way to check, does the vector x that came to my func is float or integer. I.e. someone can pass to my func for example x0 = numpy.array([1, 0, 0]) and it can yield wrong unexpected results vs numpy.array([1.0, 0, 0]) . Thx, D.
Numpy-discussion mailing list Numpy-discuss...@scipy.orghttp://projects.scipy.org/mailman/listinfo/numpy-discussion