Skip to content

Commit

Permalink
Fixed the all_full_days_since_2918 test for first date.
Browse files Browse the repository at this point in the history
  • Loading branch information
rsheftel committed Feb 24, 2018
1 parent b44bd9d commit a39f2fd
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
3 changes: 2 additions & 1 deletion docs/change_log.rst
Expand Up @@ -60,6 +60,7 @@ Updates
~~~~~~~~~~~~~
- Made default open and close times time-zone aware

0.15 (2/20/18)
0.15 (2/23/18)
~~~~~~~~~~~~~~
- Removed toolz as a required package and removed from the one test that required it
- Added daily closes on NYSE back to 1928 from PR #30 thanks to @pldrouin
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -18,7 +18,7 @@

setup(
name='pandas_market_calendars',
version='0.14',
version='0.15',

description='Market and exchange trading calendars for pandas',
long_description=long_description,
Expand Down
25 changes: 16 additions & 9 deletions tests/test_nyse_calendar.py
Expand Up @@ -2,6 +2,7 @@
import pandas as pd
import pytz
import os
from pandas.testing import assert_index_equal
from pandas_market_calendars.exchange_calendar_nyse import NYSEExchangeCalendar


Expand All @@ -14,6 +15,7 @@ def test_open_time_tz():
nyse = NYSEExchangeCalendar()
assert nyse.open_time.tzinfo == nyse.tz


def test_close_time_tz():
nyse = NYSEExchangeCalendar()
assert nyse.close_time.tzinfo == nyse.tz
Expand Down Expand Up @@ -238,18 +240,23 @@ def test_early_close_independence_day_thursday():
assert nyse.open_at_time(schedule, friday_after_open) is True
assert nyse.open_at_time(schedule, friday_after) is True


def test_all_full_day_holidays_since_1928(request):
"""
Perform a full comparison of all known full day NYSE holidays since 1928/01/01 and
make sure that it matches.
"""
# get the expected dates from the csv file
expected = pd.read_csv(os.path.join(request.fspath.dirname, 'data', 'nyse_all_full_day_holidays_since_1928.csv'),
index_col=0, parse_dates=True, header=None).index
del expected.name

# calculated expected
nyse = NYSEExchangeCalendar()
dticsv=pd.read_csv(os.path.join(request.fspath.dirname,
'nyse_all_full_day_holidays_since_1928.csv'),
index_col=0, parse_dates=True).index
dti=pd.DatetimeIndex(nyse.adhoc_holidays).tz_convert(None).sort_values()
slice_locs=dti.slice_locs(dticsv[0], dticsv[-1])
dti=dti[slice_locs[0]:slice_locs[1]]
dti=dti.append(nyse.regular_holidays.holidays(dticsv[0], dticsv[-1]))
dti=dti.sort_values().unique()
assert dticsv.equals(dti)
actual = pd.DatetimeIndex(nyse.adhoc_holidays).tz_convert(None).sort_values()
slice_locs = actual.slice_locs(expected[0], expected[-1])
actual = actual[slice_locs[0]:slice_locs[1]]
actual = actual.append(nyse.regular_holidays.holidays(expected[0], expected[-1]))
actual = actual.sort_values().unique()

assert_index_equal(expected, actual)

0 comments on commit a39f2fd

Please sign in to comment.