Skip to content

REF: implement module for shared constructor functions #27551

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 10 commits into from
Jul 25, 2019

Conversation

jbrockmendel
Copy link
Member

@jbrockmendel jbrockmendel commented Jul 24, 2019

core.construction intended for code to be shared between pd.array, Series.__init__, and Index.__new__. The module should not need to be internals-aware.

This only moves array and extract_array to keep the diff contained. The next step would be to move internals.construction.sanitize_array, which is used in a number of non-internals places and satisfies the not-internals-aware condition.

Several functions from core.dtypes.cast would also make more sense here than in their current locations.

update moved sanitize_array too, and updated imports

@jreback jreback added the Refactor Internal refactoring of code label Jul 24, 2019
@@ -1,16 +1,51 @@
"""
Constructor functions intended to be shared by pd.array, Series.__init__,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, I would have left this where it was I think. what is the reasoning for moving this all to construction? (the array parts I am talking)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after trying to move this back im remembering: because core.arrays.__init__ imports a bunch of stuff keeping it there makes import order a hassle

@@ -278,3 +312,241 @@ def array(

result = PandasArray._from_sequence(data, dtype=dtype, copy=copy)
return result


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 on combing these routines into array module

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

though im not wild about that name (hard to grep for)

@jbrockmendel
Copy link
Member Author

@WillAyd help with mypy complaints?

@WillAyd
Copy link
Member

WillAyd commented Jul 24, 2019

I think this is just starting to validate _shared_docs in pandas.core.generic now. Can probably just annotate that as Dict[str, str] to resolve (off the top of my head - didn't look deeply)

@jbrockmendel
Copy link
Member Author

mypy fixed, thanks

@jreback jreback added this to the 1.0 milestone Jul 25, 2019
@jreback jreback merged commit 8993fac into pandas-dev:master Jul 25, 2019
@jbrockmendel jbrockmendel deleted the constr branch July 25, 2019 17:33
quintusdias pushed a commit to quintusdias/pandas_dev that referenced this pull request Aug 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Refactor Internal refactoring of code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants