def test_converts_invalid_values(self, array): x = np.array([ [np.nan, 0, 2, np.inf], [-np.inf, np.nan, 1e-18, 2], [np.nan, np.nan, np.nan, np.nan], [np.inf, np.inf, np.inf, np.inf], ]) result = nan_to_num(array(x)) np.testing.assert_equal(assure_array_dense(result), np.nan_to_num(x))
def test_functionality(self, array): expected = np.isnan(self.x) result = isnan(array(self.x)) np.testing.assert_equal(assure_array_dense(result), expected)
def test_preserves_valid_values(self, array): x = np.arange(12).reshape((3, 4)) result = nan_to_num(array(x)) np.testing.assert_equal(assure_array_dense(result), x) np.testing.assert_equal(assure_array_dense(result), np.nan_to_num(x))