Skip to content

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

Merged
merged 3 commits into from
Feb 26, 2020

Conversation

jbrockmendel
Copy link
Member

No description provided.

@jbrockmendel
Copy link
Member Author

@simonjayhawkins mypy is complaining that the _simple_new signature doesnt match Index's. Suggestions?


@classmethod
def _simple_new(cls, values, name=None, dtype=None):
def _simple_new(cls, values: Categorical, name=None):
Copy link
Member

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

Suggested change
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?

Copy link
Member

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.

@@ -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):
Copy link
Member

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?

Copy link
Member Author

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

@jbrockmendel jbrockmendel added Clean Constructors Series/DataFrame/Index/pd.array Constructors labels Feb 25, 2020
@jreback jreback added this to the 1.1 milestone Feb 26, 2020
@jreback jreback merged commit 2fc8559 into pandas-dev:master Feb 26, 2020
@jreback
Copy link
Contributor

jreback commented Feb 26, 2020

thanks

@jbrockmendel jbrockmendel deleted the create_categorical branch February 26, 2020 02:16
roberthdevries pushed a commit to roberthdevries/pandas that referenced this pull request Mar 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean Constructors Series/DataFrame/Index/pd.array Constructors
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants