Skip to content

TST: Fixed xfail for tests in pandas/tests/tseries/offsets/test_offsets_properties.py #32465

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
wants to merge 29 commits into from
Closed
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
4fd071c
TST: Cleaned tests
Mar 5, 2020
d69692c
Fixed another test
Mar 5, 2020
6112ddd
Cosmetic changes
Mar 5, 2020
86415fa
Skiping tests if dateutils 2.7.0 or higher is not installed
Mar 5, 2020
10f5b72
Merge remote-tracking branch 'upstream/master' into TST-tseries-xfail
Mar 6, 2020
a1ad09b
Suppressing mypy errors
Mar 6, 2020
f18e402
Merge remote-tracking branch 'upstream/master' into TST-tseries-xfail
Mar 18, 2020
30d9ef7
Using LooseVersion
Mar 18, 2020
6cc8bc4
Merge remote-tracking branch 'upstream/master' into TST-tseries-xfail
Mar 19, 2020
9087485
Added simplefilter for warnings
Mar 19, 2020
889b726
Typos
Mar 19, 2020
a33bb0c
Using td.skip.if_no decorator
Mar 19, 2020
5f4c9a6
Merge remote-tracking branch 'upstream/master' into TST-tseries-xfail
Mar 20, 2020
d8a51f6
Delted duplicate apply_index
Mar 25, 2020
3a508cf
Remove warnings.simplefilter
Mar 25, 2020
5251350
Merge remote-tracking branch 'upstream/master' into TST-tseries-xfail
Mar 25, 2020
7507faa
Merge remote-tracking branch 'upstream/master' into TST-tseries-xfail
Mar 29, 2020
635b28e
Trying with smaller daterange
Mar 29, 2020
baf83d4
Revert "Trying with smaller daterange"
Mar 29, 2020
9389578
Merge remote-tracking branch 'upstream/master' into TST-tseries-xfail
Mar 29, 2020
1802c60
Merge remote-tracking branch 'upstream/master' into TST-tseries-xfail
Apr 3, 2020
273ca9d
Merge remote-tracking branch 'upstream/master' into TST-tseries-xfail
Apr 6, 2020
664411f
Merge remote-tracking branch 'upstream/master' into TST-tseries-xfail
Apr 6, 2020
e148ca7
Merge remote-tracking branch 'upstream/master' into TST-tseries-xfail
Apr 6, 2020
0ea0151
Merge remote-tracking branch 'upstream/master' into TST-tseries-xfail
Apr 7, 2020
5656456
Merge remote-tracking branch 'upstream/master' into TST-tseries-xfail
Apr 8, 2020
648d17f
Merge remote-tracking branch 'upstream/master' into TST-tseries-xfail
Apr 10, 2020
e4a9d0b
Removed skip decorators
Apr 10, 2020
80ad207
Merge remote-tracking branch 'upstream/master' into TST-tseries-xfail
Apr 10, 2020
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
26 changes: 11 additions & 15 deletions pandas/tests/tseries/offsets/test_offsets_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@
# Offset-specific behaviour tests


# Based on CI runs: Always passes on OSX, fails on Linux, sometimes on Windows
@pytest.mark.xfail(strict=False, reason="inconsistent between OSs, Pythons")
Copy link
Member Author

@ShaharNaveh ShaharNaveh Mar 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It says here that on linux it always fails (at least this is how I understood it), but it passed on my machine (I run linux).

Copy link
Member Author

@ShaharNaveh ShaharNaveh Mar 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok so I think I understood why this failing:

hypothesis.extra.dateutil.timezones is using dateutil.UTC which is avaible only from dateutils>=2.7.0 (https://dateutil.readthedocs.io/en/stable/tz.html#dateutil.tz.dateutil.tz.UTC)

but macOS have a pinned python-dateutils to 2.6.1 which then leads to errors.


@jbrockmendel is bumping python-dateutils to 2.7.0 is an option/reasonable thing to do?

if not I will put a pytest.mark.skipif decorator (seems more likely to be the answer)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is bumping python-dateutils to 2.7.0 is an option/reasonable thing to do?

2.7.0 is 2 days shy of 2 years old, so I think we're OK bumping

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MomIsBestFriend this is definitely an improvement, but we can also just bump the dateutil requirement

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MomIsBestFriend this is definitely an improvement, but we can also just bump the dateutil requirement

Sure! will do that in a separate PR

@given(gen_random_datetime, gen_yqm_offset)
def test_on_offset_implementations(dt, offset):
assume(not offset.normalize)
Expand All @@ -97,40 +95,38 @@ def test_on_offset_implementations(dt, offset):
assert offset.is_on_offset(dt) == (compare == dt)


@pytest.mark.xfail(
reason="res_v2 below is incorrect, needs to use the "
"commented-out version with tz_localize. "
"But with that fix in place, hypothesis then "
"has errors in timezone generation."
)
@given(gen_yqm_offset, gen_date_range)
def test_apply_index_implementations(offset, rng):
# offset.apply_index(dti)[i] should match dti[i] + offset
assume(offset.n != 0) # TODO: test for that case separately

# rng = pd.date_range(start='1/1/2000', periods=100000, freq='T')
# TODO: test for that case separately
assume(offset.n != 0)

ser = pd.Series(rng)

res = rng + offset
res_v2 = offset.apply_index(rng)
# res_v2 = offset.apply_index(rng.tz_localize(None)).tz_localize(rng.tz)
res_v2 = offset.apply_index(rng.tz_localize(None)).tz_localize(rng.tz)
assert (res == res_v2).all()

# apply_index is only for indexes, not series, so no res2_v2
assert res[0] == rng[0] + offset
assert res[-1] == rng[-1] + offset
res2 = ser + offset
# apply_index is only for indexes, not series, so no res2_v2

# TODO: Check randomly assorted entries, not just first/last
Copy link
Member Author

@ShaharNaveh ShaharNaveh Mar 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am interested in doing that, anyone got a smart way of doing that?

Will do that in a follow-up PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for _ in range(10):
     n = np.random.randint(len(ser))
     assert res2.iloc[n] == ser.iloc[n] + offset

(10 is arbitrary number here, you decide what is reasonable number

assert res2.iloc[0] == ser.iloc[0] + offset
assert res2.iloc[-1] == ser.iloc[-1] + offset
# TODO: Check randomly assorted entries, not just first/last


@pytest.mark.xfail # TODO: reason?
@given(gen_yqm_offset)
def test_shift_across_dst(offset):
# GH#18319 check that 1) timezone is correctly normalized and
# GH#18319
# check that:
# 1) timezone is correctly normalized and
# 2) that hour is not incorrectly changed by this normalization
# Note that dti includes a transition across DST boundary

dti = pd.date_range(
start="2017-10-30 12:00:00", end="2017-11-06", freq="D", tz="US/Eastern"
)
Expand Down