8000 Use pandas wrapper functions for the test suite by kandersolar · Pull Request #1021 · pvlib/pvlib-python · GitHub
[go: up one dir, main page]

Skip to content

Use pandas wrapper functions for the test suite #1021

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

Merged
merged 7 commits into from
Aug 7, 2020
Merged
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
refactor asserts
  • Loading branch information
kandersolar committed Aug 7, 2020
commit 52646f3baa7658083b2ee104bda8d8baa9748a0b
31 changes: 20 additions & 11 deletions pvlib/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,34 @@ def inner(*args, **kwargs):
return wrapper


# custom test function that handles the change in API related to default
# tolerances in pandas 1.1.0. See pvlib GH #1018
def assert_series_equal(left, right, **kwargs):
def _check_pandas_assert_kwargs(kwargs):
# handles the change in API related to default
# tolerances in pandas 1.1.0. See pvlib GH #1018
if parse_version(pd.__version__) >= parse_version('1.1.0'):
kwargs.pop('check_less_precise', None)
if kwargs.pop('check_less_precise', False):
kwargs['atol'] = 1e-3
kwargs['rtol'] = 1e-3
else:
kwargs['atol'] = 1e-5
kwargs['rtol'] = 1e-5
else:
kwargs.pop('rtol', None)
kwargs.pop('atol', None)
return kwargs


def assert_index_equal(left, right, **kwargs):
kwargs = _check_pandas_assert_kwargs(kwargs)
pd.testing.assert_index_equal(left, right, **kwargs)


def assert_series_equal(left, right, **kwargs):
kwargs = _check_pandas_assert_kwargs(kwargs)
pd.testing.assert_series_equal(left, right, **kwargs)


# custom test function that handles the change in API related to default
# tolerances in pandas 1.1.0. See pvlib GH #1018
def assert_frame_equal(left, right, **kwargs):
if parse_version(pd.__version__) >= parse_version('1.1.0'):
kwargs.pop('check_less_precise', None)
else:
kwargs.pop('rtol', None)
kwargs.pop('atol', None)
kwargs = _check_pandas_assert_kwargs(kwargs)
pd.testing.assert_frame_equal(left, right, **kwargs)


Expand Down
0