[SciPy-user] single elements and arrays
Mon Jun 30 13:14:06 CDT 2008
foo finds a root where x is a parameter in the equation to be solved.
If x is an array, I iterate through the elements of the array.
On Jun 30, 2008, at 1:52 PM, Robert Kern wrote:
> On Mon, Jun 30, 2008 at 12:45, Gideon Simpson <firstname.lastname@example.org>
>> Suppose I have a function foo
>> def foo(x):
>> and i have written foo in a vectorized fashion such that x can be a
>> numpy array of #'s. But suppose I also want to be able to do
>> where i am interested in the value at a single point.
>> Is there an easy way to handle both cases? Should I just not permit
>> this sort of ambiguity (force everything to be an array)?
> It depends. If you are just using ufuncs inside, you don't have to do
> anything. Your function will work just fine with arrays and scalars.
> If you're doing something else, like looking at .shape or using .sum()
> or something, then you might need to actually do something. Exactly
> what depends on the details, though. Can you provide more details
> about what your function does?
> Robert Kern
> "I have come to believe that the whole world is an enigma, a harmless
> enigma that is made terrible by our own mad attempt to interpret it as
> though it had an underlying truth."
> -- Umberto Eco
> SciPy-user mailing list
More information about the SciPy-user