BUG: Add a test for Ticket #2189 #397

merged 2 commits into from Sep 2, 2012


None yet

3 participants

certik commented Aug 31, 2012

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

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

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

certik commented Aug 31, 2012

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

This pull request passes (merged cb5a27e into e60c70d).

This pull request passes (merged 0713354 into e60c70d).

@njsmith njsmith commented on the diff Sep 1, 2012
@@ -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)
njsmith Sep 1, 2012 Owner

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.

njsmith commented Sep 1, 2012

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

certik commented Sep 2, 2012

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

@certik certik merged commit 7d30cad into numpy:master Sep 2, 2012

1 check passed

default The Travis build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment