You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Same dt in both cases, The last element is supposed not to be inclusive, Why in the first case works and in the second doesn't? Any idea?
In [16]: dt = 0.005
In [17]: t1=numpy.arange(0, 50.005, dt)
In [18]: t1[-1]
Out[18]: 50.0
In [19]: t2=numpy.arange(0, 10.005, dt)
In [20]: t2[-1]
Out[20]: 10.005000000000001
According to numpy.arange documentation:
For floating point arguments, the length of the result is ceil((stop - start)/step). Because of floating point overflow, this rule may result in the last element of out being greater than stop.
caso a) numpy.ceil((stop - start)/dt) returns 10001.0
caso b) numpy.ceil((stop - start)/dt) returns 2002.0
The text was updated successfully, but these errors were encountered:
Same dt in both cases, The last element is supposed not to be inclusive, Why in the first case works and in the second doesn't? Any idea?
According to numpy.arange documentation:
For floating point arguments, the length of the result is
ceil((stop - start)/step)
. Because of floating point overflow, this rule may result in the last element of out being greater than stop.caso a)
numpy.ceil((stop - start)/dt) returns 10001.0
caso b)
numpy.ceil((stop - start)/dt) returns 2002.0
The text was updated successfully, but these errors were encountered: