Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

BUG: Add a test for Ticket #2189 #397

Merged
merged 2 commits into from

3 participants

Ondřej Čertík Don't Add Me To Your Organization a.k.a The Travis Bot Nathaniel J. Smith
Ondřej Čertík
Owner

This fixes: http://projects.scipy.org/numpy/ticket/2189

(after this PR is merged, the ticket can be closed)

Don't Add Me To Your Organization a.k.a The Travis Bot

This pull request passes (merged 137f25fd into 5c944b9).

Ondřej Čertík
Owner

@njsmith, if you have a minute, can you please review this PR?

Don't Add Me To Your Organization a.k.a The Travis Bot

This pull request passes (merged cb5a27e into e60c70d).

Don't Add Me To Your Organization a.k.a The Travis Bot

This pull request passes (merged 0713354 into e60c70d).

Nathaniel J. Smith njsmith commented on the diff
numpy/core/tests/test_regression.py
@@ -1737,5 +1737,15 @@ def test_refcount_error_in_clip(self):
# Check the final string:
assert_(y == "[0 0]")
+ def test_searchsorted_wrong_dtype(self):
+ # Ticket #2189, it used to segfault, so we check that it raises the
+ # proper exception.
+ a = np.array([('a', 1)], dtype='S1, int')
+ assert_raises(TypeError, np.searchsorted, a, 1.2)
+ # Ticket #2066, similar problem:
+ dtype = np.format_parser(['i4', 'i4'], [], [])
+ a = np.recarray((2, ), dtype)
Nathaniel J. Smith Owner
njsmith added a note

The use of format_parser is pretty pointless here, it's equivalent to just writing a = np.recarray((2,), "i4, i4") or a = np.recarray((2,), [("", "i4"), ("", "i4")])... doesn't really matter much though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Nathaniel J. Smith
Owner

Sure, it looks fine (modulo the nitpick mentioned above, which you can fix if you feel like it, or not...).

Ondřej Čertík
Owner

I personally like the test, as it tests the reported issue directly. It shouldn't cause any problems. So I am merging this.

Ondřej Čertík certik merged commit 7d30cad into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 31, 2012
  1. Ondřej Čertík
  2. Ondřej Čertík
This page is out of date. Refresh to see the latest.
Showing with 10 additions and 0 deletions.
  1. +10 −0 numpy/core/tests/test_regression.py
10 numpy/core/tests/test_regression.py
View
@@ -1737,5 +1737,15 @@ def test_refcount_error_in_clip(self):
# Check the final string:
assert_(y == "[0 0]")
+ def test_searchsorted_wrong_dtype(self):
+ # Ticket #2189, it used to segfault, so we check that it raises the
+ # proper exception.
+ a = np.array([('a', 1)], dtype='S1, int')
+ assert_raises(TypeError, np.searchsorted, a, 1.2)
+ # Ticket #2066, similar problem:
+ dtype = np.format_parser(['i4', 'i4'], [], [])
+ a = np.recarray((2, ), dtype)
Nathaniel J. Smith Owner
njsmith added a note

The use of format_parser is pretty pointless here, it's equivalent to just writing a = np.recarray((2,), "i4, i4") or a = np.recarray((2,), [("", "i4"), ("", "i4")])... doesn't really matter much though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ assert_raises(TypeError, np.searchsorted, a, 1)
+
if __name__ == "__main__":
run_module_suite()
Something went wrong with that request. Please try again.