[SciPy-user] numarray complex comparisons
Tim Hochberg
tim.hochberg at ieee.org
Wed Dec 11 15:46:22 EST 2002
[Pearu]
> On Wed, 11 Dec 2002, Perry Greenfield wrote:
>
> <snip>
> > This is as simple as clip, is explicit about the
> > comparison behavior, and handles complex arrays
> > in the manner desired. It's true that .real doesn't
> > currently work on non-complex arrays, but it could,
> > or we could add a real function that just returns all
> > non-complex arrays as is and returns the real part of
> > complex arrays.
>
> +1 for .real and .imag attributes be available for non-complex arrays. It
> would be a very useful addition also to current Numeric.
I like this idea in abstract, and it would be easy to do for the real
attrib, but I have a hard time seeing how it would work for the imaginary
attribute? For instance:
>>> a = array([1, 2, 3+1j])
>>> a.imag[0] = 5
>>> a
array([ 1.+5.j, 2.+0.j, 3.+1.j])
>>> b = array([1,2,3])
>>> b.imag # OK, this could work -- it could dynamically create an array of
zeros and return them
array([0., 0., 0.]) # Float or int? I dunno
>>> b.imag[0] = 5 # But what the heck is this supposed to? Change b from int
to complex? Do nothing? Spooky!
????
So, I'm +0.5 on always providing '.real', but not '.imag' (-1 until shown it
can work reasonably).
> +0.5 for functions real() and imag().
+1 here.
-tim
More information about the SciPy-User
mailing list