Title: a bug about np.arrange
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.5
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 2018-11-08 08:06 by mark.dickinson. 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:
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.

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:

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.
Date User Action Args
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