-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Fix segfault in lib.isnullobj #13764
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
Conversation
Current coverage is 84.56% (diff: 100%)
|
@@ -342,7 +342,7 @@ def item_from_zerodim(object val): | |||
|
|||
@cython.wraparound(False) | |||
@cython.boundscheck(False) | |||
def isnullobj(ndarray[object] arr): | |||
def isnullobj(arr): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is another routine isnull right below this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sigh...will fix too.
you need to check if it's iterable now eg s scalar will fail |
or at least assert that (as this cannot be called with s scalar) |
tm.assert_numpy_array_equal(result, expected) | ||
|
||
def test_non_ndarray_inp(self): | ||
ind = pd.Index([1, None, 'foo', -5.1, pd.NaT, np.nan]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
put all of these tests with the null tests - you will have to find them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a very helpful comment tbh. This a lib
method, so I don't see why we don't put the tests here and instead go "hunting" for unit tests like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because you will now have tests in multiple places for the same thing
some lib tests see segrated
try types/missing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But they're unit tests for two different methods, one of which is a helper for another. Sure they might be similar, but from an organisation perspective, it's easier I think to put the tests next to the module whose methods or functions you are testing. That makes it easier and write tests IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the bottom line is to be logical where test go do they r easy to fine
my point is that tests for this should be in 1 place
u can pick but consolidate the like tests
or these functions not tested anywhere else??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The specific lib
functions aren't being tested anywhere, so I intended to put unit tests for them in test_lib.py
. The null
functions you were referring to are those exposed at the Python layer, not the internal ones (which is what I am fixing) that are written in Cython.
@jreback : good point about the scalar thing - I think I actually don't need to remove |
eb1e8ee
to
cd07769
Compare
@jreback : "fixed" all four |
lgtm. can you give a perf test and see if anything material (I don't think so, but can't hurt). as this is the null tester for strings. |
What do you mean |
this is called for null testing on strings |
From where exactly? Are you talking about the |
look at how isnull works. this is the only 1 of 2 places this is called. |
Okay, that's what I thought. Where should this perf test go in |
oh, i mean there prob is a benchmark that tells null on strings already, if not see where the null tests are (I think they are all in one place). |
cd07769
to
1f90104
Compare
@jreback : I found |
1f90104
to
b10bbef
Compare
Travis is doing weird things. Putting |
Weird segfault arises when you call lib.isnullobj (or any of its equivalents like lib.isnullobj2d) with an array that uses 0-field values to mean None. Changed input to be a Python object (i.e. no typing), and the segfault went away. Closes pandas-devgh-13717. [ci skip]
b10bbef
to
0338b5d
Compare
self.sample = np.array(list(string.ascii_lowercase) + | ||
list(string.ascii_uppercase) + | ||
list(string.whitespace)) | ||
self.data = np.random.choice(self.choice, (1000, 1000)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls test, this was not building on asv (choice -> sample)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, sorry! Was in a bit of a rush when I wrote it.
thanks minor change I made in the asv |
Weird segfault arises when you call
lib.isnullobj
with an array that uses 0-field values to meanNone
.Changed input to be a
Python
object (i.e. no typing), and the segfault went away. Discovered when there were segfaults in printing aDataFrame
containing such an array.Closes #13717.