Skip to content

Commit

Permalink
Merge pull request #107 from jakevdp:test-warnings
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 570085248
  • Loading branch information
The ml_dtypes Authors committed Oct 2, 2023
2 parents 67236bf + c082a2d commit 2e94dae
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ml_dtypes/tests/custom_float_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@ def testRoundTripToInt(self, float_type):
self.assertEqual(v, int(float_type(v)))
self.assertEqual(-v, int(float_type(-v)))

@ignore_warning(
category=RuntimeWarning, message="invalid value encountered in cast"
)
@ignore_warning(category=RuntimeWarning, message="overflow encountered")
def testRoundTripToNumpy(self, float_type):
for dtype in [
Expand Down Expand Up @@ -457,6 +460,9 @@ def testSort(self, float_type):
sorted_float_type = np.sort(values_to_sort.astype(float_type)) # pylint: disable=too-many-function-args
np.testing.assert_equal(sorted_f32, np.float32(sorted_float_type))

@ignore_warning(
category=RuntimeWarning, message="invalid value encountered in cast"
)
def testArgmax(self, float_type):
values_to_sort = np.float32(
float_type(np.float32(FLOAT_VALUES[float_type]))
Expand All @@ -479,6 +485,9 @@ def testArgmaxOnNegativeInfinity(self, float_type):
inf = np.array([float("-inf")], dtype=np.float32)
np.testing.assert_equal(np.argmax(inf.astype(float_type)), np.argmax(inf))

@ignore_warning(
category=RuntimeWarning, message="invalid value encountered in cast"
)
def testArgmin(self, float_type):
values_to_sort = np.float32(
float_type(np.float32(FLOAT_VALUES[float_type]))
Expand Down

0 comments on commit 2e94dae

Please sign in to comment.