Skip to content

Commit

Permalink
Merge pull request numpy#19714 from shubham11941140/patch1
Browse files Browse the repository at this point in the history
MAINT: Remove redundant Python2 float/int conversions
  • Loading branch information
mattip committed Aug 19, 2021
2 parents 31240df + a5c9bb5 commit 5350aa0
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
14 changes: 7 additions & 7 deletions numpy/core/tests/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def test_datetime_nat_argsort_stability(self, size):
expected = np.arange(size)
arr = np.tile(np.datetime64('NaT'), size)
assert_equal(np.argsort(arr, kind='mergesort'), expected)

@pytest.mark.parametrize("size", [
3, 21, 217, 1000])
def test_timedelta_nat_argsort_stability(self, size):
Expand Down Expand Up @@ -1373,13 +1373,13 @@ def test_datetime_divide(self):
assert_equal(tda / 0.5, tdc)
assert_equal((tda / 0.5).dtype, np.dtype('m8[h]'))
# m8 / m8
assert_equal(tda / tdb, 6.0 / 9.0)
assert_equal(np.divide(tda, tdb), 6.0 / 9.0)
assert_equal(np.true_divide(tda, tdb), 6.0 / 9.0)
assert_equal(tdb / tda, 9.0 / 6.0)
assert_equal(tda / tdb, 6 / 9)
assert_equal(np.divide(tda, tdb), 6 / 9)
assert_equal(np.true_divide(tda, tdb), 6 / 9)
assert_equal(tdb / tda, 9 / 6)
assert_equal((tda / tdb).dtype, np.dtype('f8'))
assert_equal(tda / tdd, 60.0)
assert_equal(tdd / tda, 1.0 / 60.0)
assert_equal(tda / tdd, 60)
assert_equal(tdd / tda, 1 / 60)

# int / m8
assert_raises(TypeError, np.divide, 2, tdb)
Expand Down
10 changes: 5 additions & 5 deletions numpy/core/tests/test_numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -2381,7 +2381,7 @@ def test_clip_property(self, data, arr):
shape=in_shapes[1], elements={"allow_nan": False}))

# Then calculate our result and expected result and check that they're
# equal! See gh-12519 and gh-19457 for discussion deciding on this
# equal! See gh-12519 and gh-19457 for discussion deciding on this
# property and the result_type argument.
result = np.clip(arr, amin, amax)
t = np.result_type(arr, amin, amax)
Expand Down Expand Up @@ -2637,15 +2637,15 @@ def test_scalars(self):

def test_ddof1(self):
assert_almost_equal(np.var(self.A, ddof=1),
self.real_var*len(self.A)/float(len(self.A)-1))
self.real_var * len(self.A) / (len(self.A) - 1))
assert_almost_equal(np.std(self.A, ddof=1)**2,
self.real_var*len(self.A)/float(len(self.A)-1))
self.real_var*len(self.A) / (len(self.A) - 1))

def test_ddof2(self):
assert_almost_equal(np.var(self.A, ddof=2),
self.real_var*len(self.A)/float(len(self.A)-2))
self.real_var * len(self.A) / (len(self.A) - 2))
assert_almost_equal(np.std(self.A, ddof=2)**2,
self.real_var*len(self.A)/float(len(self.A)-2))
self.real_var * len(self.A) / (len(self.A) - 2))

def test_out_scalar(self):
d = np.arange(10)
Expand Down
2 changes: 1 addition & 1 deletion numpy/fft/tests/test_pocketfft.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

def fft1(x):
L = len(x)
phase = -2j*np.pi*(np.arange(L)/float(L))
phase = -2j * np.pi * (np.arange(L) / L)
phase = np.arange(L).reshape(-1, 1) * phase
return np.sum(x*np.exp(phase), axis=1)

Expand Down
4 changes: 2 additions & 2 deletions numpy/random/tests/test_generator_mt19937_regressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ def test_logseries_convergence(self):
# these two frequency counts should be close to theoretical
# numbers with this large sample
# theoretical large N result is 0.49706795
freq = np.sum(rvsn == 1) / float(N)
freq = np.sum(rvsn == 1) / N
msg = f'Frequency was {freq:f}, should be > 0.45'
assert_(freq > 0.45, msg)
# theoretical large N result is 0.19882718
freq = np.sum(rvsn == 2) / float(N)
freq = np.sum(rvsn == 2) / N
msg = f'Frequency was {freq:f}, should be < 0.23'
assert_(freq < 0.23, msg)

Expand Down
4 changes: 2 additions & 2 deletions numpy/random/tests/test_randomstate_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ def test_logseries_convergence(self):
# these two frequency counts should be close to theoretical
# numbers with this large sample
# theoretical large N result is 0.49706795
freq = np.sum(rvsn == 1) / float(N)
freq = np.sum(rvsn == 1) / N
msg = f'Frequency was {freq:f}, should be > 0.45'
assert_(freq > 0.45, msg)
# theoretical large N result is 0.19882718
freq = np.sum(rvsn == 2) / float(N)
freq = np.sum(rvsn == 2) / N
msg = f'Frequency was {freq:f}, should be < 0.23'
assert_(freq < 0.23, msg)

Expand Down
4 changes: 2 additions & 2 deletions numpy/random/tests/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ def test_logseries_convergence(self):
# these two frequency counts should be close to theoretical
# numbers with this large sample
# theoretical large N result is 0.49706795
freq = np.sum(rvsn == 1) / float(N)
freq = np.sum(rvsn == 1) / N
msg = f'Frequency was {freq:f}, should be > 0.45'
assert_(freq > 0.45, msg)
# theoretical large N result is 0.19882718
freq = np.sum(rvsn == 2) / float(N)
freq = np.sum(rvsn == 2) / N
msg = f'Frequency was {freq:f}, should be < 0.23'
assert_(freq < 0.23, msg)

Expand Down

0 comments on commit 5350aa0

Please sign in to comment.