Re: [Numpy-discussion] Vectorize or rewrite function to work with array inputs?

2011-02-01 Thread DParker
I tested with mixed scalar and array inputs for t and far, and same size arrays for both. I did not test with improperly sized arrays but I would expect (desire) an exception to be raised when the arrays are not broadcastable. Still the code seems like an ugly hack... David Parker Chromalloy

Re: [Numpy-discussion] Vectorize or rewrite function to work with array inputs?

2011-02-01 Thread DParker
I'm not sure I need to dive into cython or C for this - performance is not an issue for my problem - I just want a flexible function that will accept scalars or arrays. Both Sebastian's and eat's suggestions show using indexing to handle the conditional statements in the original function. The

Re: [Numpy-discussion] Vectorize or rewrite function to work with array inputs?

2011-02-01 Thread DParker
Thanks for the advice. Using Sebastian's advice I was able to write a version that worked when the input arguments are both arrays with the same length. The code provided by eat works when t is an array, but not for an array of far. The numpy.vectorize version works with any combination of sc

[Numpy-discussion] Vectorize or rewrite function to work with array inputs?

2011-01-31 Thread DParker
I have several functions like the example below that I would like to make compatible with array inputs. The problem is the conditional statements give a ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all(). I can use numpy.vectorize, but if pos