In [61]:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
In [62]:
L = 2 * np.pi
dx = 0.0122718463031
x = np.arange(0, L, dx)
A = np.linspace(0, L, 100000, endpoint=False)
A.max()
Out[62]:
In [63]:
%%timeit
res1 = (A / dx).astype(int)
In [64]:
%%timeit
res2 = (A // dx).astype(int)
In [65]:
%%timeit
res3 = np.floor_divide(A, dx).astype(int)
In [66]:
results = [res1, res2, res3]
for r1 in results:
plt.plot(r1)
for r2 in results:
if r2 is not r1:
assert np.allclose(r1, r2)