[Numpy-discussion] floats for indexing, reshape - too strict ?

Chris Barker - NOAA Federal chris.barker at noaa.gov
Thu Jul 2 20:51:01 EDT 2015


Sent from my iPhone

>
> The disadvantage I see is, that some weirder calculations would possible
> work most of the times, but not always,


>  not sure if you can define a "tolerance"
> reasonable here unless it is exact.

You could use a relative tolerance, but you'd still have to set that.
Better to put that decision squarely in the user's hands.

> Though I guess you are right that
> `//` will also just round silently already.

Yes, but if it's in the user's code, it should be obvious -- and then
the user can choose to round, or floor, or ceiling....

-CHB

>
> - Sebastian
>
>>
>> for example
>>
>>
>>>>> 5.0 == 5
>> True
>>
>>
>>>>> np.ones(10 / 2)
>> array([ 1.,  1.,  1.,  1.,  1.])
>>>>> 10 / 2 == 5
>> True
>>
>>
>> or the python 2 version
>>
>>
>>>>> np.ones(10. / 2)
>> array([ 1.,  1.,  1.,  1.,  1.])
>>>>> 10. / 2 == 5
>> True
>>
>>
>> I'm using now 10 // 2, or int(10./2 + 1)   but this is unconditional
>> and doesn't raise if the numbers are not close or equal to an integer
>> (which would be a bug)
>>
>>
>>
>>
>> Josef
>>
>>
>>
>>
>> _______________________________________________
>> NumPy-Discussion mailing list
>> NumPy-Discussion at scipy.org
>> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion



More information about the NumPy-Discussion mailing list