-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
TST: add test for Index.where when needing to cast to object dtype #40888
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
@@ -248,6 +249,20 @@ def test_putmask_with_wrong_mask(self, index): | |||
index.putmask("foo", fill) | |||
|
|||
|
|||
class TestCasting: | |||
def test_maybe_cast_with_dtype(self): |
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.
This test is better suited in pandas/tests/indexes/base_class/test_where.py
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 main issue was the casting so I was not sure, I could move it anyway.
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.
Thanks, Generally we group tests by the method calls on the particular objects (Index.where
)
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.
@cgarciae Thanks for the PR!
(side-note: for future reference, try to give your PRs a descriptive title; only reference the issue number is not that useful (since we don't know by heart what those numbers are about ;))
Thanks @jorisvandenbossche and @mroeschke for the feedback! I'll clean the PR a bit :) |
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.
As a last comment, could you still move the test?
I think tests/indexes/numeric/test_indexing.py
might be best suites, there is a TestWhere
class
@jorisvandenbossche moved the test there! |
This pull request is stale because it has been open for thirty days with no activity. Please update or respond to this comment if you're still interested in working on this. |
@@ -376,6 +376,18 @@ def test_where(self, klass, index): | |||
result = index.where(klass(cond)) | |||
tm.assert_index_equal(result, expected) | |||
|
|||
def test_maybe_cast_with_dtype(self): |
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.
can you give this a name of the form test_where_[...]
ideally more desc
the underlying problem in #32413 was at a lower level IIRC. should we have a test on astype or a constructor? |
|
||
fixed_index = index.where(cond, other) | ||
|
||
tm.assert_index_equal(other, Index(["a0", "a1"])) |
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.
can you use
result =
expected =
tm.assert_index_equal(result, expected)
|
||
fixed_index = index.where(cond, other) | ||
|
||
tm.assert_index_equal(other, Index(["a0", "a1"])) |
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 parameterize if you have multiple cases
closing as stale |
Hey! This is my first PR with actual code: added a very basic test to validate #32413.
Questions:
pandas/tests/indexes/test_indexing.py
)index
input argument?