8000 BUG:warn on Nan in minimum,maximum for scalars, float16 by mattip · Pull Request #11595 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG:warn on Nan in minimum,maximum for scalars, float16 #11595

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
BUG:warn on Nan in minimum,maximum for scalars
  • Loading branch information
mattip committed Jul 24, 2018
commit b63687b0f84902a6e51d78496a3ff13e7963fa97
8 changes: 6 additions & 2 deletions numpy/core/src/umath/loops.c.src
Original file line number Diff line number Diff line change
Expand Up @@ -1874,9 +1874,13 @@ NPY_NO_EXPORT void
}
else {
BINARY_LOOP {
const @type@ in1 = *(@type@ *)ip1;
@type@ in1 = *(@type@ *)ip1;
const @type@ in2 = *(@type@ *)ip2;
*((@type@ *)op1) = (in1 @OP@ in2 || npy_isnan(in1)) ? in1 : in2;
in1 = (in1 @OP@ in2 || npy_isnan(in1)) ? in1 : in2;
if (npy_isnan(in1)) {
npy_set_floatstatus_invalid();
}
*((@type@ *)op1) = in1;
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion numpy/core/tests/test_umath.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
assert_, assert_equal, assert_raises, assert_raises_regex,
assert_array_equal, assert_almost_equal, assert_array_almost_equal,
assert_allclose, assert_no_warnings, suppress_warnings,
_gen_alignment_data,
_gen_alignment_data, assert_warns
)


Expand Down Expand Up @@ -1339,6 +1339,10 @@ def test_reduce_warns(self):
assert_equal(np.min(r), np.nan)
assert_equal(len(sup.log), n)

def test_minimize_warns(self):
# gh 11589
assert_warns(RuntimeWarning, np.minimum, np.nan, 1)


class TestAbsoluteNegative(object):
def test_abs_neg_blocked(self):
Expand Down
0