Skip to content

BUG: incorrect serialization of a CustomBusinessDay in HDF5 (GH8591) #8699

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 2 commits into from
Oct 31, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
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
14 changes: 6 additions & 8 deletions doc/source/whatsnew/v0.15.1.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
.. _whatsnew_0151:

v0.15.1 (November ??, 2014)
-----------------------
v0.15.1 (November 8, 2014)
--------------------------

This is a minor release from 0.15.0 and includes a small number of API changes, several new features,
This is a minor bug-fix release from 0.15.0 and includes a small number of API changes, several new features,
enhancements, and performance improvements along with a large number of bug fixes. We recommend that all
users upgrade to this version.

- Highlights include:

- :ref:`Enhancements <whatsnew_0151.enhancements>`
- :ref:`API Changes <whatsnew_0151.api>`
- :ref:`Performance Improvements <whatsnew_0151.performance>`
Expand All @@ -30,10 +28,10 @@ API changes

.. code-block:: python

# this was underreported and actually took (in < 0.15.1) about 24008 bytes
# this was underreported in prior versions
In [1]: dfi.memory_usage(index=True)
Out[1]:
Index 8000
Index 8000 # took about 24008 bytes in < 0.15.1
A 8000
dtype: int64

Expand Down Expand Up @@ -178,7 +176,7 @@ Experimental
Bug Fixes
~~~~~~~~~


- Bug in unpickling of a ``CustomBusinessDay`` object (:issue:`8591`)
- Bug in coercing ``Categorical`` to a records array, e.g. ``df.to_records()`` (:issue:`8626`)
- Bug in ``Categorical`` not created properly with ``Series.to_frame()`` (:issue:`8626`)
- Bug in coercing in astype of a ``Categorical`` of a passed ``pd.Categorical`` (this now raises ``TypeError`` correctly), (:issue:`8626`)
Expand Down
22 changes: 22 additions & 0 deletions pandas/io/tests/test_pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -2047,6 +2047,28 @@ def compare(a,b):
result = store.select('df')
assert_frame_equal(result,df)

def test_calendar_roundtrip_issue(self):

# 8591
# doc example from tseries holiday section
weekmask_egypt = 'Sun Mon Tue Wed Thu'
holidays = ['2012-05-01', datetime.datetime(2013, 5, 1), np.datetime64('2014-05-01')]
bday_egypt = pandas.offsets.CustomBusinessDay(holidays=holidays, weekmask=weekmask_egypt)
dt = datetime.datetime(2013, 4, 30)
dts = date_range(dt, periods=5, freq=bday_egypt)

s = (Series(dts.weekday, dts).map(Series('Mon Tue Wed Thu Fri Sat Sun'.split())))

with ensure_clean_store(self.path) as store:

store.put('fixed',s)
result = store.select('fixed')
assert_series_equal(result, s)

store.append('table',s)
result = store.select('table')
assert_series_equal(result, s)

def test_append_with_timezones_dateutil(self):

from datetime import timedelta
Expand Down
8 changes: 8 additions & 0 deletions pandas/tseries/offsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,14 @@ def __getstate__(self):
"""Return a pickleable state"""
state = self.__dict__.copy()
del state['calendar']

# we don't want to actually pickle the calendar object
# as its a np.busyday; we recreate on deserilization
try:
state['kwds'].pop('calendar')
except:
pass

return state

def __setstate__(self, state):
Expand Down
4 changes: 2 additions & 2 deletions pandas/tseries/tests/test_offsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
from pandas.core.datetools import (
bday, BDay, CDay, BQuarterEnd, BMonthEnd,
CBMonthEnd, CBMonthBegin,
BYearEnd, MonthEnd, MonthBegin, BYearBegin,
BYearEnd, MonthEnd, MonthBegin, BYearBegin, CustomBusinessDay,
QuarterBegin, BQuarterBegin, BMonthBegin, DateOffset, Week,
YearBegin, YearEnd, Hour, Minute, Second, Day, Micro, Milli, Nano, Easter,
WeekOfMonth, format, ole2datetime, QuarterEnd, to_datetime, normalize_date,
get_offset, get_offset_name, get_standard_freq)

from pandas import Series
from pandas.tseries.frequencies import _offset_map
from pandas.tseries.index import _to_m8, DatetimeIndex, _daterange_cache, date_range
from pandas.tseries.tools import parse_time_string
Expand Down Expand Up @@ -867,7 +868,6 @@ def test_pickle_compat_0_14_1(self):
cday = CDay(holidays=hdays)
self.assertEqual(cday, cday0_14_1)


class CustomBusinessMonthBase(object):
_multiprocess_can_split_ = True

Expand Down