[Numpy-discussion] round, fix, ceil, and floor for complex args

Timothy Hochberg tim.hochberg@ieee....
Mon Feb 4 12:14:35 CST 2008


On Mon, Feb 4, 2008 at 10:34 AM, Stuart Brorson <sdb@cloud9.net> wrote:

> Hi --
>
> I'm fiddling with NumPy's chopping and truncating operators: round,
> fix, ceil, and floor.   In the case where they are passed real args,
> they work just fine.  However, I find that when they are passed
> complex args, I get the following:
>
> round -> works fine.
> ceil  -> throws exception: 'complex' object has no attribute 'ceil'
> floor -> throws exception: 'complex' object has no attribute 'floor'
> fix   -> throws exception: 'complex' object has no attribute 'floor'
>
> Please see the session log below for more details.
>
> My question:  Is this a bug or a feature?  It seems to me that if you
> implement round for complex args, then you need to also support ceil,
> floor, and fix for complex args, so it's a bug.  But I thought I'd ask
> the developers what they thought before filing a ticket.


IMO, the problem is not that ceil, floor and fix are not defined for
complex, but rather that round is. (Re, Im) is not a unique representation
for complex numbers, although that is the internal representation that numpy
uses, and as a result none of these functions are uniquely defined. Since
it's trivial to synthesize the effect that I assume you are looking for
(operating on both the Re and Im parts as if the were floats), there's no
reason to have this functionality built in.

[....examples....]


-- 
.  __
.   |-\
.
.  tim.hochberg@ieee.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20080204/5c5d7b40/attachment.html 


More information about the Numpy-discussion mailing list