Skip to content

Commit

Permalink
Revert "ENH: Create a 'Y' alias for date_range yearly frequency" (pan…
Browse files Browse the repository at this point in the history
…das-dev#16976)

This reverts commit 9c096d2, as it was prematurely made.
  • Loading branch information
gfyoung authored and 3553x committed Jul 16, 2017
1 parent 6e5786d commit d38535c
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 50 deletions.
28 changes: 28 additions & 0 deletions pandas/tests/io/test_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@
import glob
import os
import re
import threading
import warnings

try:
from importlib import import_module
except ImportError:
import_module = __import__

try:
from importlib import reload
except ImportError:
pass

from distutils.version import LooseVersion

import pytest
Expand All @@ -22,6 +28,7 @@
from pandas.compat import (map, zip, StringIO, string_types, BytesIO,
is_platform_windows, PY3)
from pandas.io.common import URLError, urlopen, file_path_to_url
import pandas.io.html
from pandas.io.html import read_html
from pandas._libs.parsers import ParserError

Expand Down Expand Up @@ -931,3 +938,24 @@ def test_same_ordering():
dfs_lxml = read_html(filename, index_col=0, flavor=['lxml'])
dfs_bs4 = read_html(filename, index_col=0, flavor=['bs4'])
assert_framelist_equal(dfs_lxml, dfs_bs4)

class ErrorThread(threading.Thread):
def run(self):
try:
super(ErrorThread, self).run()
except Exception as e:
self.err = e
else:
self.err = None

@pytest.mark.slow
def test_importcheck_thread_safety():
reload(pandas.io.html)
filename = os.path.join(DATA_PATH, 'valid_markup.html')
helper_thread1 = ErrorThread(target = read_html, args = (filename,))
helper_thread2 = ErrorThread(target = read_html, args = (filename,))
helper_thread1.start()
helper_thread2.start()
while(helper_thread1.is_alive() or helper_thread2.is_alive()):
pass
assert None == helper_thread1.err == helper_thread2.err
41 changes: 13 additions & 28 deletions pandas/tests/tseries/test_frequencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,9 @@ def test_anchored_shortcuts(self):

# ensure invalid cases fail as expected
invalid_anchors = ['SM-0', 'SM-28', 'SM-29',
'SM-FOO', 'BSM', 'SM--1',
'SM-FOO', 'BSM', 'SM--1'
'SMS-1', 'SMS-28', 'SMS-30',
'SMS-BAR', 'SMS-BYR' 'BSMS',
'SMS--2']
'SMS-BAR', 'BSMS', 'SMS--2']
for invalid_anchor in invalid_anchors:
with tm.assert_raises_regex(ValueError,
'Invalid frequency: '):
Expand Down Expand Up @@ -293,15 +292,11 @@ def test_get_rule_month():

result = frequencies._get_rule_month('A-DEC')
assert (result == 'DEC')
result = frequencies._get_rule_month('Y-DEC')
assert (result == 'DEC')
result = frequencies._get_rule_month(offsets.YearEnd())
assert (result == 'DEC')

result = frequencies._get_rule_month('A-MAY')
assert (result == 'MAY')
result = frequencies._get_rule_month('Y-MAY')
assert (result == 'MAY')
result = frequencies._get_rule_month(offsets.YearEnd(month=5))
assert (result == 'MAY')

Expand All @@ -310,10 +305,6 @@ def test_period_str_to_code():
assert (frequencies._period_str_to_code('A') == 1000)
assert (frequencies._period_str_to_code('A-DEC') == 1000)
assert (frequencies._period_str_to_code('A-JAN') == 1001)
assert (frequencies._period_str_to_code('Y') == 1000)
assert (frequencies._period_str_to_code('Y-DEC') == 1000)
assert (frequencies._period_str_to_code('Y-JAN') == 1001)

assert (frequencies._period_str_to_code('Q') == 2000)
assert (frequencies._period_str_to_code('Q-DEC') == 2000)
assert (frequencies._period_str_to_code('Q-FEB') == 2002)
Expand Down Expand Up @@ -358,10 +349,6 @@ def test_freq_code(self):
assert frequencies.get_freq('3A') == 1000
assert frequencies.get_freq('-1A') == 1000

assert frequencies.get_freq('Y') == 1000
assert frequencies.get_freq('3Y') == 1000
assert frequencies.get_freq('-1Y') == 1000

assert frequencies.get_freq('W') == 4000
assert frequencies.get_freq('W-MON') == 4001
assert frequencies.get_freq('W-FRI') == 4005
Expand All @@ -382,13 +369,6 @@ def test_freq_group(self):
assert frequencies.get_freq_group('-1A') == 1000
assert frequencies.get_freq_group('A-JAN') == 1000
assert frequencies.get_freq_group('A-MAY') == 1000

assert frequencies.get_freq_group('Y') == 1000
assert frequencies.get_freq_group('3Y') == 1000
assert frequencies.get_freq_group('-1Y') == 1000
assert frequencies.get_freq_group('Y-JAN') == 1000
assert frequencies.get_freq_group('Y-MAY') == 1000

assert frequencies.get_freq_group(offsets.YearEnd()) == 1000
assert frequencies.get_freq_group(offsets.YearEnd(month=1)) == 1000
assert frequencies.get_freq_group(offsets.YearEnd(month=5)) == 1000
Expand Down Expand Up @@ -810,6 +790,12 @@ def test_series(self):
for freq in [None, 'L']:
s = Series(period_range('2013', periods=10, freq=freq))
pytest.raises(TypeError, lambda: frequencies.infer_freq(s))
for freq in ['Y']:

msg = frequencies._INVALID_FREQ_ERROR
with tm.assert_raises_regex(ValueError, msg):
s = Series(period_range('2013', periods=10, freq=freq))
pytest.raises(TypeError, lambda: frequencies.infer_freq(s))

# DateTimeIndex
for freq in ['M', 'L', 'S']:
Expand All @@ -826,12 +812,11 @@ def test_legacy_offset_warnings(self):
'W@FRI', 'W@SAT', 'W@SUN', 'Q@JAN', 'Q@FEB', 'Q@MAR',
'A@JAN', 'A@FEB', 'A@MAR', 'A@APR', 'A@MAY', 'A@JUN',
'A@JUL', 'A@AUG', 'A@SEP', 'A@OCT', 'A@NOV', 'A@DEC',
'Y@JAN', 'WOM@1MON', 'WOM@2MON', 'WOM@3MON',
'WOM@4MON', 'WOM@1TUE', 'WOM@2TUE', 'WOM@3TUE',
'WOM@4TUE', 'WOM@1WED', 'WOM@2WED', 'WOM@3WED',
'WOM@4WED', 'WOM@1THU', 'WOM@2THU', 'WOM@3THU',
'WOM@4THU', 'WOM@1FRI', 'WOM@2FRI', 'WOM@3FRI',
'WOM@4FRI']
'WOM@1MON', 'WOM@2MON', 'WOM@3MON', 'WOM@4MON',
'WOM@1TUE', 'WOM@2TUE', 'WOM@3TUE', 'WOM@4TUE',
'WOM@1WED', 'WOM@2WED', 'WOM@3WED', 'WOM@4WED',
'WOM@1THU', 'WOM@2THU', 'WOM@3THU', 'WOM@4THU'
'WOM@1FRI', 'WOM@2FRI', 'WOM@3FRI', 'WOM@4FRI']

msg = frequencies._INVALID_FREQ_ERROR
for freq in freqs:
Expand Down
22 changes: 0 additions & 22 deletions pandas/tseries/frequencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,27 +422,6 @@ def get_period_alias(offset_str):
return _offset_to_period_map.get(offset_str, None)


_pure_alias = {
# 'A' is equivalent to 'Y'.
'Y': 'A',
'YS': 'AS',
'BY': 'BA',
'BYS': 'BAS',
'Y-DEC': 'A-DEC',
'Y-JAN': 'A-JAN',
'Y-FEB': 'A-FEB',
'Y-MAR': 'A-MAR',
'Y-APR': 'A-APR',
'Y-MAY': 'A-MAY',
'Y-JUN': 'A-JUN',
'Y-JUL': 'A-JUL',
'Y-AUG': 'A-AUG',
'Y-SEP': 'A-SEP',
'Y-OCT': 'A-OCT',
'Y-NOV': 'A-NOV',
}


_lite_rule_alias = {
'W': 'W-SUN',
'Q': 'Q-DEC',
Expand Down Expand Up @@ -739,7 +718,6 @@ def get_standard_freq(freq):


def _period_str_to_code(freqstr):
freqstr = _pure_alias.get(freqstr, freqstr)
freqstr = _lite_rule_alias.get(freqstr, freqstr)

if freqstr not in _dont_uppercase:
Expand Down

0 comments on commit d38535c

Please sign in to comment.