-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
CLN: simplify CategoricalIndex._simple_new #32204
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
@simonjayhawkins mypy is complaining that the _simple_new signature doesnt match Index's. Suggestions? |
pandas/core/indexes/category.py
Outdated
|
||
@classmethod | ||
def _simple_new(cls, values, name=None, dtype=None): | ||
def _simple_new(cls, values: Categorical, name=None): |
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 would fix-up mypy
def _simple_new(cls, values: Categorical, name=None): | |
def _simple_new(cls, values: Categorical, name=None, dtype=None): |
and then assert dtype is None or CategoricalDtype?
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.
maybe a docstring/comment to say dtype is for compatibility with Index._simple_new and not used, but if specified and not CategoricalDtype will raise.
…eate_categorical
@@ -136,12 +136,3 @@ def test_construction_with_categorical_dtype(self): | |||
|
|||
with pytest.raises(ValueError, match=msg): | |||
Index(data, ordered=ordered, dtype=dtype) | |||
|
|||
def test_create_categorical(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.
Does this no longer work? I think should keep the test no?
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 method it is testing is removed
thanks |
No description provided.