Skip to content

move _add__ and __sub__ to liboffsets, implement _Tick #21694

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 7 commits into from
Jul 3, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
change __class__ to type
  • Loading branch information
jbrockmendel committed Jul 2, 2018
commit 1a87b6a5c55a4ec22691c6c6985a4fb94a63573a
8 changes: 4 additions & 4 deletions pandas/_libs/tslibs/offsets.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -378,17 +378,17 @@ class _BaseOffset(object):
if isinstance(other, datetime):
raise TypeError('Cannot subtract datetime from offset.')
elif type(other) == type(self):
return self.__class__(self.n - other.n, normalize=self.normalize,
**self.kwds)
return type(self)(self.n - other.n, normalize=self.normalize,
**self.kwds)
else: # pragma: no cover
return NotImplemented

def __call__(self, other):
return self.apply(other)

def __mul__(self, other):
return self.__class__(n=other * self.n, normalize=self.normalize,
**self.kwds)
return type(self)(n=other * self.n, normalize=self.normalize,
**self.kwds)

def __neg__(self):
# Note: we are defering directly to __mul__ instead of __rmul__, as
Expand Down