-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: when flooring, ambiguous parameter unnecessarily used (and raising Error) #50024
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
Changes from 13 commits
0fc33f8
673a876
4650eb4
4a762d0
296320a
48814b7
62ec2a9
568802b
c663b6c
db967a3
c260315
f38e138
241233c
3e5944b
c7cd6f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,20 +25,21 @@ Fixed regressions | |
Bug fixes | ||
~~~~~~~~~ | ||
- Bug in :meth:`.Styler.to_excel` leading to error when unrecognized ``border-style`` (e.g. ``"hair"``) provided to Excel writers (:issue:`48649`) | ||
- | ||
- Bug in :meth:`.Timestamp.floor` fixed tz_localize so 'ambiguous' parameter can only be True, False, 'NaT' or 'raise' and all other invalid arguments to ambiguous have same error, including 'infer' (:issue:`49565`) | ||
|
||
.. --------------------------------------------------------------------------- | ||
.. _whatsnew_153.other: | ||
|
||
Other | ||
~~~~~ | ||
- | ||
- Modified test cases in test_timezones.py to reflect new error message from bug fix for bug: (:issue:`49565`) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is unnecessary, let's remove it |
||
- | ||
|
||
.. --------------------------------------------------------------------------- | ||
.. _whatsnew_153.contributors: | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
- Julia Chaker Aoun | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no need, this is populated automatically There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi! If you could approve or merge my PR by tomorrow I would really appreciate it! I'm working on this for a project and I get extra credit if the PR is approved :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you'll need to address the review comments first There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe I resolved the remaining comments in my last commit There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
.. contributors:: v1.5.2..v1.5.3|HEAD |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
datetime, | ||
timedelta, | ||
) | ||
import re | ||
|
||
import dateutil | ||
from dateutil.tz import ( | ||
|
@@ -102,7 +103,10 @@ def test_tz_localize_ambiguous(self): | |
ts_no_dst = ts.tz_localize("US/Eastern", ambiguous=False) | ||
|
||
assert (ts_no_dst.value - ts_dst.value) / 1e9 == 3600 | ||
msg = "Cannot infer offset with only one time" | ||
msg = re.escape( | ||
"'ambiguous' parameter must be one of: " | ||
"True, False, 'NaT', 'raise' (default)" | ||
) | ||
with pytest.raises(ValueError, match=msg): | ||
ts.tz_localize("US/Eastern", ambiguous="infer") | ||
|
||
|
@@ -182,8 +186,8 @@ def test_tz_localize_ambiguous_compat(self): | |
|
||
pytz_zone = "Europe/London" | ||
dateutil_zone = "dateutil/Europe/London" | ||
result_pytz = naive.tz_localize(pytz_zone, ambiguous=0) | ||
result_dateutil = naive.tz_localize(dateutil_zone, ambiguous=0) | ||
result_pytz = naive.tz_localize(pytz_zone, ambiguous=False) | ||
result_dateutil = naive.tz_localize(dateutil_zone, ambiguous=False) | ||
assert result_pytz.value == result_dateutil.value | ||
assert result_pytz.value == 1382835600000000000 | ||
|
||
|
@@ -194,8 +198,8 @@ def test_tz_localize_ambiguous_compat(self): | |
assert str(result_pytz) == str(result_dateutil) | ||
|
||
# 1 hour difference | ||
result_pytz = naive.tz_localize(pytz_zone, ambiguous=1) | ||
result_dateutil = naive.tz_localize(dateutil_zone, ambiguous=1) | ||
result_pytz = naive.tz_localize(pytz_zone, ambiguous=True) | ||
result_dateutil = naive.tz_localize(dateutil_zone, ambiguous=True) | ||
assert result_pytz.value == result_dateutil.value | ||
assert result_pytz.value == 1382832000000000000 | ||
|
||
|
@@ -357,7 +361,6 @@ def test_astimezone(self, tzstr): | |
|
||
@td.skip_if_windows | ||
def test_tz_convert_utc_with_system_utc(self): | ||
|
||
# from system utc to real utc | ||
ts = Timestamp("2001-01-05 11:56", tz=timezones.maybe_get_tz("dateutil/UTC")) | ||
# check that the time hasn't changed. | ||
|
@@ -368,9 +371,6 @@ def test_tz_convert_utc_with_system_utc(self): | |
# check that the time hasn't changed. | ||
assert ts == ts.tz_convert(dateutil.tz.tzutc()) | ||
|
||
# ------------------------------------------------------------------ | ||
# Timestamp.__init__ with tz str or tzinfo | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you check over the file again please? let's not make irrelevant changes |
||
def test_timestamp_constructor_tz_utc(self): | ||
utc_stamp = Timestamp("3/11/2012 05:00", tz="utc") | ||
assert utc_stamp.tzinfo is pytz.utc | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should go in v2.0.0.rst
as for the test, how about