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

josef.pktd at gmail.com josef.pktd at gmail.com
Wed Jul 1 10:05:23 EDT 2015


About the deprecation warning for using another type than integers, in
ones, reshape, indexing and so on:

Wouldn't it be nicer to accept floats that are equal to an integer?

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20150701/77e9e6bb/attachment.html>


More information about the NumPy-Discussion mailing list