Skip to content

Tslibs offsets immutable #18224

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

Closed
Closed
Show file tree
Hide file tree
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
Make sure _use_relativedelta is set for unpickled
  • Loading branch information
jbrockmendel committed Nov 10, 2017
commit bc8bfd5308d8f904b446cebb99ce882ef29c3132
7 changes: 2 additions & 5 deletions pandas/_libs/tslibs/offsets.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,6 @@ class EndMixin(object):
return base + off


class BusinessMixin(object):
""" mixin to business types to provide related functions """
pass


# ---------------------------------------------------------------------
# Base Classes
@cython.auto_pickle(False)
Expand Down Expand Up @@ -384,6 +379,8 @@ cdef class _BaseOffset(object):
# default for prior pickles
# See GH #7748, #7789
state['normalize'] = False
if '_use_relativedelta' not in state:
state['_use_relativedelta'] = False

if 'offset' in state:
# Older versions Business offsets have offset attribute
Expand Down
1 change: 1 addition & 0 deletions pandas/compat/pickle_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def load_reduce(self):
except:
pass


# unknown exception, re-raise
if getattr(self, 'is_verbose', None):
print(sys.exc_info())
Expand Down
11 changes: 2 additions & 9 deletions pandas/tseries/offsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
_determine_offset,
apply_index_wraps,
BeginMixin, EndMixin,
BaseOffset,
BusinessMixin as _BusinessMixin)
BaseOffset)

import functools
import operator
Expand Down Expand Up @@ -157,14 +156,8 @@ def __add__(date):

Since 0 is a bit weird, we suggest avoiding its use.
"""
_use_relativedelta = False
_adjust_dst = False

# default for prior pickles
# normalize = False
# FIXME: without commenting this out, all
# DateOffsets get initialized with normalize=False, regardless of kwarg

def __init__(self, n=1, normalize=False, **kwds):
BaseOffset.__init__(self, n, normalize)
self.kwds = kwds
Expand Down Expand Up @@ -415,7 +408,7 @@ def _from_name(cls, suffix=None):
return cls()


class BusinessMixin(_BusinessMixin):
class BusinessMixin(object):
""" mixin to business types to provide related functions """

@property
Expand Down