This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: a bug about np.arrange
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.5
process
Status: closed Resolution: third party
Dependencies: Superseder:
Assigned To: Nosy List: mark.dickinson, xyl123
Priority: normal Keywords:

Created on 2018-11-08 07:57 by xyl123, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg329460 - (view) Author: xiyunlong (xyl123) Date: 2018-11-08 07:57
when I use np.arange as follows:
np.arange(1,2.2,0.2)
I got the array as [1. , 1.2, 1.4, 1.6, 1.8, 2. , 2.2],we know, the maxvalue 2.2 of the array should not be included in the array. Is this a bug?
msg329461 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2018-11-08 08:04
np.arange is part of NumPy, not core Python; I'd suggest asking this question on the NumPy mailing lists, e.g. https://mail.python.org/pipermail/numpy-discussion/

But no, it's not a bug; it's a well-known gotcha.
msg329462 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2018-11-08 08:06
It's also worth taking a look at the documentation: https://docs.scipy.org/doc/numpy-1.15.0/reference/generated/numpy.arange.html

See particularly the "Result" section, where it says:

> Because of floating point overflow, this rule may result in the last > element of out being greater than stop.
History
Date User Action Args
2022-04-11 14:59:07adminsetgithub: 79368
2018-11-08 08:06:47mark.dickinsonsetmessages: + msg329462
2018-11-08 08:04:52mark.dickinsonsetstatus: open -> closed

nosy: + mark.dickinson
messages: + msg329461

resolution: third party
stage: resolved
2018-11-08 07:57:46xyl123create