-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
CLN: Use more pytest idioms in test_momemts_ewm.py #36801
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
Conversation
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.
Thanks @mroeschke. A suggestion for an alternative approach that may not be any clearer, so feel free to ignore.
assert isinstance(series_result, Series) | ||
|
||
frame_result = getattr(frame.ewm(com=10), name)() | ||
frame_result = frame.ewm(com=10).mean() |
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.
rather than a test use two fixtures independently, could have a test_ewma_series and test_ewma_frame
|
||
|
||
@pytest.mark.parametrize("name", ["var", "vol"]) | ||
def test_ewmvar_ewmvol(series, frame, nan_locs, name): | ||
check_ew(name=name, frame=frame, series=series, nan_locs=nan_locs) | ||
def test_ewmvar_ewmvol(series, frame, name): |
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.
can this be combined with test_ewma
assert isinstance(series_result, Series) | ||
|
||
frame_result = getattr(frame.ewm(com=10), name)() | ||
assert type(frame_result) == DataFrame |
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.
why not isinstance?
(s1, False, False, [(1.0 - alpha) ** 2, np.nan, alpha]), | ||
(s1, False, True, [(1.0 - alpha), np.nan, alpha]), | ||
(s2, True, False, [np.nan, (1.0 - alpha) ** 3, np.nan, np.nan, 1.0, np.nan]), | ||
(s2, True, True, [np.nan, (1.0 - alpha), np.nan, np.nan, 1.0, np.nan]), |
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.
i'm not sure that the parameterisation is clearer.
maybe parameterise s, adjust and ignore_na independently (maybe with fixtures) and create a w
fixture with a dictionary lookup. i.e. pass s, adjust and ignore_na to w
fixture
maybe use a class just for namespacing and use class level fixtures.
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.
I'll consider doing this change in a follow up PR. The main motivation with this pass is to ensure that parameterized test failures are more easily visible within pytest
thanks @mroeschke follows welcome (per @simonjayhawkins comments) |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff
Use
pytest.mark.parameterize
and unnest helper test functions