On Tue, Feb 1, 2011 at 1:30 PM, John Salvatier <jsalv...@u.washington.edu>wrote:

> Have you thought about using cython to work with the numpy C-API (
> http://wiki.cython.org/tutorials/numpy#UsingtheNumpyCAPI)? This will be
> fast, simple (you can mix and match Python and Cython).
>
> As for your specific issue: you can simply cast to all the inputs to numpy
> arrays (using asarray
> http://docs.scipy.org/doc/numpy/reference/generated/numpy.asarray.html) to
> deal with scalars. This will make sure they get broadcast correctly.
>
>
Don't use "asarray" blindly!  Using asarray causes masked_arrays to become
regular arrays.  If all of the operations in your function are vectorized
already, then you are causing your function to unnecessarially break support
for subclassed arrays like masked_arrays.

Use asanyarray() by default unless it has to be asarray().

Sorry for my rant.  I just love masked arrays too much...
Ben Root
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to