dmitrey 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]) .

Usually, it's not so much that you need to know whether a parameter is a 
float or an integer, but rather that your function is designed to work 
with one or the other. In that case, you can force it with as array:

def test(InputArray):
     InputArray = numpy.asarray(InputArray, numpy.float)


asarray is a no-op if the input is already of the type you've specified

It's handy, as it will take *anything* that can be turned into an array 
of the specified type.

This won't work the function needs to change the input in place, however.

-Chris


-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

[EMAIL PROTECTED]
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to