[Numpy-discussion] why does b[:-0] not work, and is there an elegant solution?
David Cournapeau
cournape@gmail....
Wed Aug 19 20:22:48 CDT 2009
On Wed, Aug 19, 2009 at 5:50 AM, Neil Martinsen-Burrell<nmb@wartburg.edu> wrote:
> On Aug 19, 2009, at 7:25 AM, Mark Bakker wrote:
>> I compute the index of the last term in an array that I need and
>> call the index n.
>>
>> I can then call the array b as
>>
>> b[:-n]
>>
>> If I need all terms in the array, the logical syntax would be:
>>
>> b[:-0]
>>
>> but that doesn't work. Any reason why that has not been implemented?
>> Any elegant workaround?
>
> Because there is no negative zero as an integer:
>
> >>> -0 == 0
> True
Not that it matters for the discussion, but -0.0 == 0.0:
x = np.array(np.PZERO)
y = np.array(np.NZERO)
y == x # True
1 / x == 1 / y # False: inf and negative inf
The only way to differentiate the number by itself is signbit,
cheers,
David
More information about the NumPy-Discussion
mailing list