
Hi Zach 2009/11/22 Zachary Pincus <zachary.pincus@yale.edu>:
Assuming it's not easy to cast the input array to the float32 type, because I'm guessing it will be called with int arrays if not explicitly stated, can I suggest changing the documentation like:
costs : (M, N) ndarray of float32
This limitation might just be due to my relative inexperience with cython... Would it be better to have two identical functions, one which takes int costs and one with float costs (and then maybe a python wrapper function that selects between the two), or to write it so that it casts to float internally?
Since the cast only needs to happen once, you could just insert it in the Cython function.
For that matter, is there a "safe cast" function that would, say, upcast ints to float32, but would complain about trying to cast float64s to float32? Or just better to document and let the user deal with the constraint?
np.can_cast(x.dtype, np.float32)
Thanks for helping get this in shape, Gary and Stéfan!
Which reminds me -- I should update the contributors list. Thanks! Stéfan