8000 TST: Added numbers comparison (#17970) · numpy/numpy@3b6ace3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3b6ace3

Browse files
committed
TST: Added numbers comparison (#17970)
1 parent 4bdfda8 commit 3b6ace3

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

numpy/core/tests/test_scalarmath.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
np.int_, np.uint, np.longlong, np.ulonglong,
1717
np.single, np.double, np.longdouble, np.csingle,
1818
np.cdouble, np.clongdouble]
19+
all_numbers_dtypes = np.typecodes['AllInteger'] + np.typecodes['AllFloat'] +\
20+
np.typecodes['Complex']
1921

2022
floating_types = np.floating.__subclasses__()
2123
complex_floating_types = np.complexfloating.__subclasses__()
@@ -707,3 +709,13 @@ def test_shift_all_bits(self, type_code, op):
707709
shift_arr = np.array([shift]*32, dtype=dt)
708710
res_arr = op(val_arr, shift_arr)
709711
assert_equal(res_arr, res_scl)
712+
713+
class TestComparison:
714+
@pytest.mark.parametrize('type_code_rhs', all_numbers_dtypes)
715+
@pytest.mark.parametrize('type_code_lhs', all_numbers_dtypes)
716+
def test_numbers_compare(self, type_code_rhs, type_code_lhs):
717+
rand_num = np.random.randint(0, 127)
718+
a = np.dtype(type_code_rhs).type(rand_num)
719+
b = np.dtype(type_code_lhs).type(rand_num)
720+
721+
assert_almost_equal(a, b)

0 commit comments

Comments
 (0)
0