Skip to content

Commit 4fae83a

Browse files
committed
Reinstate xfail on test_monthly_freq
Pandas fix yet to be included to a release - see comments in code by test. Also: - corrects typing of decorated hypothesis strategies. - updates `test_yahoo` flaky list
1 parent a8c9d6f commit 4fae83a

File tree

4 files changed

+36
-45
lines changed

4 files changed

+36
-45
lines changed

tests/hypstrtgy.py

+21-45
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def calendar_session(
6868
draw,
6969
calendar_name: str,
7070
limit: tuple[pd.Timestamp | None, pd.Timestamp | None] = (None, None),
71-
) -> st.SearchStrategy[pd.Timestamp]:
71+
) -> pd.Timestamp:
7272
"""Return strategy to generate a session for a given calendar.
7373
7474
Parameters
@@ -96,7 +96,7 @@ def calendar_start_end_sessions(
9696
limit: tuple[pd.Timestamp | None, pd.Timestamp | None] = (None, None),
9797
min_dist: int | pd.Timedelta = 0,
9898
max_dist: int | pd.Timedelta | None = None,
99-
) -> st.SearchStrategy[tuple[pd.Timestamp, pd.Timestamp]]:
99+
) -> tuple[pd.Timestamp, pd.Timestamp]:
100100
"""Return strategy to generate a start and end session for a given calendar.
101101
102102
Parameters
@@ -163,7 +163,7 @@ def start_minutes(
163163
draw,
164164
calendar_name: str,
165165
limit: tuple[pd.Timestamp | None, pd.Timestamp | None] = (None, None),
166-
) -> st.SearchStrategy[pd.Timestamp]:
166+
) -> pd.Timestamp:
167167
"""Return strategy to generate a 'start' minute for a given calendar.
168168
169169
Minute will represent a trading minute (not a close).
@@ -211,7 +211,7 @@ def end_minutes(
211211
draw,
212212
calendar_name: str,
213213
limit: tuple[pd.Timestamp | None, pd.Timestamp | None] = (None, None),
214-
) -> st.SearchStrategy[pd.Timestamp]:
214+
) -> pd.Timestamp:
215215
"""Return strategy to generate an 'end' minute for a given calendar.
216216
217217
Minute will represent a trading minute, excluding open minutes, or a
@@ -267,7 +267,7 @@ def end_minutes(
267267
def calendar_start_end_minutes(
268268
draw,
269269
calendar_name: str,
270-
) -> st.SearchStrategy[tuple[pd.Timestamp, pd.Timestamp]]:
270+
) -> tuple[pd.Timestamp, pd.Timestamp]:
271271
"""Return strategy to generate a start and end minute for a given calendar.
272272
273273
'start' will be a trading minute.
@@ -297,9 +297,7 @@ def get_pp_default() -> dict[str, typing.Any]:
297297

298298

299299
@st.composite
300-
def pp_start_end_sessions(
301-
draw, calendar_name: str
302-
) -> st.SearchStrategy[dict[str, typing.Any]]:
300+
def pp_start_end_sessions(draw, calendar_name: str) -> dict[str, typing.Any]:
303301
"""Return strategy to generate period parameters with 'start' and 'end' only.
304302
305303
'start' and 'end' will both be sessions of `calendar`.
@@ -312,9 +310,7 @@ def pp_start_end_sessions(
312310

313311

314312
@st.composite
315-
def pp_end_minute_only(
316-
draw, calendar_name: str
317-
) -> st.SearchStrategy[dict[str, typing.Any]]:
313+
def pp_end_minute_only(draw, calendar_name: str) -> dict[str, typing.Any]:
318314
"""Return strategy to generate period parameters with 'end' only.
319315
320316
'end' will be a trading minute or a close minute of `calendar_name`.
@@ -327,9 +323,7 @@ def pp_end_minute_only(
327323

328324

329325
@st.composite
330-
def pp_start_end_minutes(
331-
draw, calendar_name: str
332-
) -> st.SearchStrategy[dict[str, typing.Any]]:
326+
def pp_start_end_minutes(draw, calendar_name: str) -> dict[str, typing.Any]:
333327
"""Return strategy to generate period parameters with 'start' and 'end' only.
334328
335329
'start' will be a trading minute, 'end' will be a trading minute or a
@@ -344,7 +338,7 @@ def pp_start_end_minutes(
344338

345339

346340
@st.composite
347-
def pp_days(draw, calendar_name: str) -> st.SearchStrategy[dict[str, typing.Any]]:
341+
def pp_days(draw, calendar_name: str) -> dict[str, typing.Any]:
348342
"""Return strategy to generate specific arrangment of period parameters.
349343
350344
duration defined in 'days'.
@@ -374,7 +368,7 @@ def pp_days_start_session(
374368
draw,
375369
calendar_name: str,
376370
start_will_roll_to_ms: bool = False,
377-
) -> st.SearchStrategy[dict[str, typing.Any]]:
371+
) -> dict[str, typing.Any]:
378372
"""Return strategy to generate specific arrangment of period parameters.
379373
380374
duration defined in 'days'.
@@ -411,9 +405,7 @@ def pp_days_start_session(
411405

412406

413407
@st.composite
414-
def pp_days_end_session(
415-
draw, calendar_name: str
416-
) -> st.SearchStrategy[dict[str, typing.Any]]:
408+
def pp_days_end_session(draw, calendar_name: str) -> dict[str, typing.Any]:
417409
"""Return strategy to generate specific arrangment of period parameters.
418410
419411
duration defined in 'days'.
@@ -438,9 +430,7 @@ def pp_days_end_session(
438430

439431

440432
@st.composite
441-
def pp_days_start_minute(
442-
draw, calendar_name: str
443-
) -> st.SearchStrategy[dict[str, typing.Any]]:
433+
def pp_days_start_minute(draw, calendar_name: str) -> dict[str, typing.Any]:
444434
"""Return strategy to generate specific arrangment of period parameters.
445435
446436
duration defined in 'days'.
@@ -461,9 +451,7 @@ def pp_days_start_minute(
461451

462452

463453
@st.composite
464-
def pp_days_end_minute(
465-
draw, calendar_name: str
466-
) -> st.SearchStrategy[dict[str, typing.Any]]:
454+
def pp_days_end_minute(draw, calendar_name: str) -> dict[str, typing.Any]:
467455
"""Return strategy to generate specific arrangment of period parameters.
468456
469457
duration defined in 'days'.
@@ -481,7 +469,7 @@ def pp_days_end_minute(
481469

482470

483471
@st.composite
484-
def pp_caldur(draw) -> st.SearchStrategy[dict[str, typing.Any]]:
472+
def pp_caldur(draw) -> dict[str, typing.Any]:
485473
"""Return strategy to generate specific arrangment of period parameters.
486474
487475
duration defined in 'weeks' and/or 'months' and/or 'years' (i.e.
@@ -500,9 +488,7 @@ def pp_caldur(draw) -> st.SearchStrategy[dict[str, typing.Any]]:
500488

501489

502490
@st.composite
503-
def pp_caldur_start_session(
504-
draw, calendar_name: str
505-
) -> st.SearchStrategy[dict[str, typing.Any]]:
491+
def pp_caldur_start_session(draw, calendar_name: str) -> dict[str, typing.Any]:
506492
"""Return strategy to generate specific arrangment of period parameters.
507493
508494
- duration defined in 'weeks' and/or 'months' and/or 'years' (i.e.
@@ -530,9 +516,7 @@ def pp_caldur_start_session(
530516

531517

532518
@st.composite
533-
def pp_caldur_end_session(
534-
draw, calendar_name: str
535-
) -> st.SearchStrategy[dict[str, typing.Any]]:
519+
def pp_caldur_end_session(draw, calendar_name: str) -> dict[str, typing.Any]:
536520
"""Return strategy to generate specific arrangment of period parameters.
537521
538522
- duration defined in 'weeks' and/or 'months' and/or 'years' (i.e.
@@ -568,9 +552,7 @@ def pp_caldur_end_session(
568552

569553

570554
@st.composite
571-
def pp_caldur_start_minute(
572-
draw, calendar_name: str
573-
) -> st.SearchStrategy[dict[str, typing.Any]]:
555+
def pp_caldur_start_minute(draw, calendar_name: str) -> dict[str, typing.Any]:
574556
"""Return strategy to generate specific arrangment of period parameters.
575557
576558
- duration defined in 'weeks' and/or 'months' and/or 'years' (i.e.
@@ -598,9 +580,7 @@ def pp_caldur_start_minute(
598580

599581

600582
@st.composite
601-
def pp_caldur_end_minute(
602-
draw, calendar_name: str
603-
) -> st.SearchStrategy[dict[str, typing.Any]]:
583+
def pp_caldur_end_minute(draw, calendar_name: str) -> dict[str, typing.Any]:
604584
"""Return strategy to generate specific arrangment of period parameters.
605585
606586
- duration defined in 'weeks' and/or 'months' and/or 'years' (i.e.
@@ -619,7 +599,7 @@ def pp_caldur_end_minute(
619599

620600

621601
@st.composite
622-
def pp_intraday(draw) -> st.SearchStrategy[dict[str, typing.Any]]:
602+
def pp_intraday(draw) -> dict[str, typing.Any]:
623603
"""Return strategy to generate specific arrangment of period parameters.
624604
625605
- duration defined in 'minutes' and/or 'hours' (i.e. in trading
@@ -637,9 +617,7 @@ def pp_intraday(draw) -> st.SearchStrategy[dict[str, typing.Any]]:
637617

638618

639619
@st.composite
640-
def pp_intraday_start_minute(
641-
draw, calendar_name: str
642-
) -> st.SearchStrategy[dict[str, typing.Any]]:
620+
def pp_intraday_start_minute(draw, calendar_name: str) -> dict[str, typing.Any]:
643621
"""Return strategy to generate specific arrangment of period parameters.
644622
645623
- duration defined in 'minutes' and/or 'hours' (i.e. in trading
@@ -660,9 +638,7 @@ def pp_intraday_start_minute(
660638

661639

662640
@st.composite
663-
def pp_intraday_end_minute(
664-
draw, calendar_name: str
665-
) -> st.SearchStrategy[dict[str, typing.Any]]:
641+
def pp_intraday_end_minute(draw, calendar_name: str) -> dict[str, typing.Any]:
666642
"""Return strategy to generate specific arrangment of period parameters.
667643
668644
- duration defined in 'minutes' and/or 'hours' (i.e. in trading

tests/test_helpers.py

+6
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,12 @@ def test_volume_to_na(intraday_pt, intraday_pt_ss):
310310
assert_frame_equal(rtrn, df)
311311

312312

313+
# TODO Remove xfail when pandas >3 or fix otherwise released
314+
# NB pd bug manifests in test, not package (manifests where evaluate
315+
# `expected_ooo.index = df[::12]`)
316+
# pandas issue ref is https://github.com/pandas-dev/pandas/issues/58604
317+
# https://github.com/pandas-dev/pandas/pull/58043, related PR, ya merged to dev
318+
@pytest.mark.xfail(reason="Known pd issue with py3.12, should resolve with pd>3.0")
313319
def test_resample(intraday_pt):
314320
"""Test `resample`.
315321

tests/test_pt.py

+6
Original file line numberDiff line numberDiff line change
@@ -2140,6 +2140,12 @@ def test_cbday_freq(self, daily_pt_ss, xnys):
21402140
df.pt.downsample("3d", xnys),
21412141
)
21422142

2143+
# TODO Remove xfail when pandas >3 or fix otherwise released
2144+
# NB pd bug manifests in test, not package (manifests where takes a slice to
2145+
# evaluate 'subset').
2146+
# pandas issue ref is https://github.com/pandas-dev/pandas/issues/58604
2147+
# https://github.com/pandas-dev/pandas/pull/58043, related PR, ya merged to dev
2148+
@pytest.mark.xfail(reason="Known pd issue with py3.12, should resolve with pd>3.0")
21432149
def test_monthly_freq(self, daily_pt, xnys, x247, one_day, symbols):
21442150
"""Verify "MS" and "QS" frequencies."""
21452151
df = daily_pt

tests/test_yahoo.py

+3
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@
4646
# ...sessions that yahoo temporarily fails to return prices for if (seemingly)
4747
# send a high frequency of requests for prices from the same IP address.
4848
_flakylist = (
49+
pd.Timestamp("2024-08-26"),
50+
pd.Timestamp("2024-08-25"),
51+
pd.Timestamp("2024-08-24"),
4952
pd.Timestamp("2024-05-28"),
5053
pd.Timestamp("2024-05-27"),
5154
pd.Timestamp("2024-01-21"),

0 commit comments

Comments
 (0)