8000 BUG: Fix misleading error when coercing to array by eric-wieser · Pull Request #10268 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: Fix misleading error when coercing to array #10268

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
Dec 24, 2017
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: Fix misleading error when coercing to array
Closes gh-7864
  • Loading branch information
eric-wieser committed Dec 24, 2017
commit 99f605c4545597e9a3bdf66f97b98da30f78ae33
2 changes: 1 addition & 1 deletion numpy/lib/histograms.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def _get_outer_edges(a, range):
if first_edge > last_edge:
raise ValueError(
'max must be larger than min in range parameter.')
if not np.all(np.isfinite([first_edge, last_edge])):
if not (np.isfinite(first_edge) and np.isfinite(last_edge)):
raise ValueError(
'range parameter must be finite.')
if first_edge == last_edge:
Expand Down
11 changes: 11 additions & 0 deletions numpy/lib/tests/test_histograms.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,17 @@ def test_unsigned_monotonicity_check(self):
with assert_raises(ValueError):
hist, edges = np.histogram(arr, bins=bins)

def test_object_array_of_0d(self):
# gh-7864
assert_raises(ValueError,
histogram, [np.array([0.4]) for i in range(10)] + [-np.inf])
assert_raises(ValueError,
histogram, [np.array([0.4]) for i in range(10)] + [np.inf])

# these should not crash
np.histogram([np.array([0.5]) for i in range(10)] + [.500000000000001])
np.histogram([np.array([0.5]) for i in range(10)] + [.5])


class TestHistogramOptimBinNums(object):
"""
Expand Down
0