-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
ENH: implement ExtensionIndex.insert #32476
Conversation
@@ -242,6 +243,10 @@ def repeat(self, repeats, axis=None): | |||
result = self._data.repeat(repeats, axis=axis) | |||
return self._shallow_copy(result) | |||
|
|||
def insert(self, loc: int, item): | |||
# ExtensionIndex subclasses must override Index.insert |
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.
Any reason not to make an abstractmethod?
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.
good idea, updated
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.
So this I believe is ideal but any concerns on backward compat? Otherwise lgtm
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.
any concerns on backward compat?
Nothing comes to mind
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.
Gothca. This is non-public right?
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.
ExtensionIndex
needs to inherit from abc.ABC
in order for the abstractmethod decorator to actually work, right?
In [1]: import abc
In [2]: class Foo:
...: @abc.abstractmethod
...: def some_meth(self):
...: pass
...:
In [3]: class Bar(Foo):
...: pass
...:
In [4]: bar = Bar()
In [5]: class Foo2(abc.ABC):
...: @abc.abstractmethod
...: def some_meth(self):
...: pass
...:
In [6]: class Bar2(Foo2):
...: pass
...:
In [7]: bar2 = Bar2()
---------------------------------------------------------------------------
TypeError: Can't instantiate abstract class Bar2 with abstract methods some_meth
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.
lgtm ex #32476 (comment)
also, since the type of Index returned depends on the inserted item may be worth adding return types so we get mypy checking consistency.
The abc.abstractmethod didn't appear to function as intended even when I subclassed abc.ABC, so reverted to use AbstractMethodError. |
comments addressed, sort of. |
seems fine |
Sort of.