Skip to content

REF: implement indexes.extension to share delegation #30629

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 9 commits into from
Jan 3, 2020

Conversation

jbrockmendel
Copy link
Member

In following steps, I plan to

  • remove the DatetimeDelegateMixin entirely and just use inherit_names
  • de-duplicate the slightly-different comparison method code from CategoricalIndex vs DatetimelikeIndex
  • move the remaining wrapping utilities from datetimelike to extension.py, after double-checking if we can remove any layers
  • delegate more methods, some of which depends on smoothing out small idiosyncrasies, e.g. REF: remove IntervalIndex.copy #30627.

from pandas.util._decorators import cache_readonly


def inherit_from_data(name, delegate, cache=False):
Copy link
Member

Choose a reason for hiding this comment

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

Can you annotate?


method = property(fget, fset)

elif not callable(attr):
Copy link
Member

Choose a reason for hiding this comment

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

Hmm somewhat confused by this function. Documented as working on methods but seems to accept attributes as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

Will update docstring. This clause is for regular class attributes, in particular a few List[str] that we share

@jreback jreback added ExtensionArray Extending pandas with custom dtypes or arrays. Index Related to the Index class or subclasses labels Jan 3, 2020
Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

lgtm. very minor comments; does this properly preserve doc-strings? i guess no easy way to test this

"_field_ops",
"_datetimelike_ops",
"_datetimelike_methods",
],
Copy link
Contributor

Choose a reason for hiding this comment

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

you have the cache=True ones first in datetimelike, can you conform

return method


def inherit_names(names: List[str], delegate, cache: bool = False):
Copy link
Contributor

Choose a reason for hiding this comment

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

you could type this -> Callable[[Type[T]], Type[T]] i think

@jreback jreback added this to the 1.0 milestone Jan 3, 2020
@jreback
Copy link
Contributor

jreback commented Jan 3, 2020

k merge on green.

@jbrockmendel
Copy link
Member Author

green

@jreback jreback merged commit 6c1597e into pandas-dev:master Jan 3, 2020
@jreback
Copy link
Contributor

jreback commented Jan 3, 2020

thanks

@jbrockmendel jbrockmendel deleted the ref-eai branch January 3, 2020 02:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ExtensionArray Extending pandas with custom dtypes or arrays. Index Related to the Index class or subclasses
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants