Skip to content

Commit

Permalink
Merge pull request #456 from neutrinoceros/hotfix_nep50
Browse files Browse the repository at this point in the history
TST: adapt a test to numpy 2.0 (NEP 50)
  • Loading branch information
jzuhone authored Oct 27, 2023
2 parents d3ae05c + 8434c15 commit b1513bd
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions unyt/tests/test_array_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1297,8 +1297,18 @@ def test_common_type():


def test_result_type():
dtype = np.result_type(3 * cm, np.arange(7, dtype="i1"))
assert dtype == np.dtype("int8")
scalar = 3 * cm
array = np.arange(7, dtype="i1")
if NUMPY_VERSION >= Version("2.0.0dev0"):
# promotion rules vary under NEP 50. The default behaviour is different
# in numpy 2.0 VS numpy 1.x
# see https://github.com/numpy/numpy/pull/23912
# see https://numpy.org/neps/nep-0050-scalar-promotion.html
expected_dtype = scalar.dtype
else:
expected_dtype = array.dtype

assert np.result_type(scalar, array) == expected_dtype


@pytest.mark.parametrize(
Expand Down

0 comments on commit b1513bd

Please sign in to comment.