-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Let CategoricalIndex take CategoricalDtype as dtype argument #18116
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
lgtm. can you add a release note, 0.21.1 is good. |
350e0be
to
6d48a08
Compare
tm.assert_index_equal(result, expected, exact=True) | ||
|
||
# error to combine categories or ordered and dtype keywords args | ||
with pytest.raises(ValueError): |
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.
We generally try to avoid using pytest.raises
because tm.assert_raises_regex
is more effective. What's the error message that you get when calling the constructor as such?
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.
pytest.raises
is ok, sure if you really want to check the message then use assert_raises_regex
, i don't think its a big deal here
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.
Well, that's why I'm asking.
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 message is "Cannot specify both dtype
and categories
or ordered
." in both cases.
FYI, pytest can now take a parameter match
which does the same thing (i.e. with pytest.raises(ValueError, match="Cannot specify both `dtype` and `categories` or `ordered`." ):
). This is a new feature added in pytest 3.1, so its very new. Pandas doesn't seem to have a minimum specified version of pytest, but it's reasonable to be able to test pandas with version < 3.1 of pytest, though.
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.
actually we do have a min version of 3.1
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.
it’s in our travis install, the requirements files and i believe the docs
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.
Ok, found it in contributing.rst
: "The earliest supported pytest version is 3.1.0.".
It would make sene to have it in install.rst
also as there is a section there on running the test suite.
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 section in install should simply point to contributing
we don’t wants things in more than one place
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.
@jreback : Do you think it would make sense to no longer tm.assert_raises_regex
if we have pytest.raises
in our toolbox now (unrelated to PR)?
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.
i don’t see a lot of benefit of changing
but could be persuaded
6d48a08
to
016f08c
Compare
Codecov Report
@@ Coverage Diff @@
## master #18116 +/- ##
==========================================
+ Coverage 91.25% 91.26% +<.01%
==========================================
Files 163 163
Lines 50124 50124
==========================================
+ Hits 45742 45745 +3
+ Misses 4382 4379 -3
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #18116 +/- ##
==========================================
+ Coverage 91.25% 91.26% +<.01%
==========================================
Files 163 163
Lines 50124 50124
==========================================
+ Hits 45742 45745 +3
+ Misses 4382 4379 -3
Continue to review full report at Codecov.
|
Pinging at green @jreback. |
thanks! |
(cherry picked from commit 58c2f09)
(cherry picked from commit 58c2f09)
git diff upstream/master -u -- "*.py" | flake8 --diff
This PR allows CategoricalIndex to take CategoricalDtype as its dtype argument, see #18109 for details.