From 1e11743e2a3e762f3d069185477a2685e833887c Mon Sep 17 00:00:00 2001 From: martin-springer Date: Wed, 10 Apr 2024 09:50:20 -0400 Subject: [PATCH 1/5] add code coverage upload to pytest workflow --- .github/workflows/pytest.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index 45b72c659..17aa453c6 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -43,4 +43,8 @@ jobs: pip install --timeout=300 ${{ matrix.env }} - name: Test with pytest ${{ matrix.env }} run: | - pytest + python -m pytest --cov=./ --cov-report=xml + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v4 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} From 74125f8dd04c4d85e92f49efa0680c6c4e8597ea Mon Sep 17 00:00:00 2001 From: martin-springer Date: Wed, 10 Apr 2024 09:53:16 -0400 Subject: [PATCH 2/5] add codecov badge to readme --- README.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d6482e561..f7149d262 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,14 @@ RdTools logo -Master branch: -[![Build Status](https://github.com/NREL/rdtools/workflows/pytest/badge.svg?branch=master)](https://github.com/NREL/rdtools/actions?query=branch%3Amaster) +Master branch: +[![Build Status](https://github.com/NREL/rdtools/workflows/pytest/badge.svg?branch=master)](https://github.com/NREL/rdtools/actions?query=branch%3Amaster) -Development branch: +Development branch: [![Build Status](https://github.com/NREL/rdtools/workflows/pytest/badge.svg?branch=development)](https://github.com/NREL/rdtools/actions?query=branch%3Adevelopment) +Code coverage: +[![codecov](https://codecov.io/gh/NREL/rdtools/graph/badge.svg?token=K2HDjFkBws)](https://codecov.io/gh/NREL/rdtools) + RdTools is an open-source library to support reproducible technical analysis of time series data from photovoltaic energy systems. The library aims to provide best practice analysis routines along with the building blocks for users to @@ -57,11 +60,11 @@ appropriate: Detection Techniques in AC Power Time Series," 2021 IEEE 48th Photovoltaic Specialists Conference (PVSC), pp. 1638-1643 2021, DOI: [10.1109/PVSC43889.2021.9518733](https://doi.org/10.1109/PVSC43889.2021.9518733). - + ## References The clear sky temperature calculation, `clearsky_temperature.get_clearsky_tamb()`, uses data -from images created by Jesse Allen, NASA’s Earth Observatory using data courtesy of the MODIS Land Group. -https://neo.sci.gsfc.nasa.gov/view.php?datasetId=MOD_LSTD_CLIM_M +from images created by Jesse Allen, NASA’s Earth Observatory using data courtesy of the MODIS Land Group. +https://neo.sci.gsfc.nasa.gov/view.php?datasetId=MOD_LSTD_CLIM_M https://neo.sci.gsfc.nasa.gov/view.php?datasetId=MOD_LSTN_CLIM_M Other useful references which may also be consulted for degradation rate methodology include: From dcfad82c347db4b95a3a4c1923ff44d7eac18bf8 Mon Sep 17 00:00:00 2001 From: martin-springer Date: Wed, 10 Apr 2024 11:08:55 -0400 Subject: [PATCH 3/5] add pytest-cov to setup.py --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 4a7519665..aa684c818 100644 --- a/setup.py +++ b/setup.py @@ -33,6 +33,7 @@ TESTS_REQUIRE = [ 'pytest >= 3.6.3', + 'pytest-cov', 'coverage', 'flake8', 'nbval==0.9.6', # https://github.com/computationalmodelling/nbval/issues/194 From 09d17c0a645584622f690ca7c9d7e0766a6da94a Mon Sep 17 00:00:00 2001 From: martin-springer Date: Wed, 10 Apr 2024 11:56:27 -0400 Subject: [PATCH 4/5] fix test_interpolate_warning for pytest > 7.0.0 --- rdtools/test/interpolate_test.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/rdtools/test/interpolate_test.py b/rdtools/test/interpolate_test.py index 448d3ed39..ce6022b40 100644 --- a/rdtools/test/interpolate_test.py +++ b/rdtools/test/interpolate_test.py @@ -2,6 +2,7 @@ import numpy as np from rdtools import interpolate import pytest +import warnings @pytest.fixture @@ -132,9 +133,9 @@ def test_interpolate_warning(test_df, df_target_index, df_expected_result): interpolate(test_df, df_target_index, pd.to_timedelta('15 minutes'), warning_threshold=0.1) - with pytest.warns(None) as record: + with warnings.catch_warnings() as record: + warnings.simplefilter("error") interpolate(test_df, df_target_index, pd.to_timedelta('15 minutes'), warning_threshold=0.5) - if 'Fraction of excluded data' in ';'.join([str(x.message) for x in record.list]): - pytest.fail("normalize.interpolate raised a warning about " - "excluded data even though the threshold was high") + warnings.filterwarnings("error", message='Fraction of excluded data') + # if this test fails, it means a warning was raised that was not expected From 5bae32f40494698426aa25d4e02478dd5c3426ab Mon Sep 17 00:00:00 2001 From: martin-springer Date: Wed, 10 Apr 2024 12:06:13 -0400 Subject: [PATCH 5/5] remove record variable from test_interpolate_warning --- rdtools/test/interpolate_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rdtools/test/interpolate_test.py b/rdtools/test/interpolate_test.py index ce6022b40..40bac08bc 100644 --- a/rdtools/test/interpolate_test.py +++ b/rdtools/test/interpolate_test.py @@ -133,7 +133,7 @@ def test_interpolate_warning(test_df, df_target_index, df_expected_result): interpolate(test_df, df_target_index, pd.to_timedelta('15 minutes'), warning_threshold=0.1) - with warnings.catch_warnings() as record: + with warnings.catch_warnings(): warnings.simplefilter("error") interpolate(test_df, df_target_index, pd.to_timedelta('15 minutes'), warning_threshold=0.5)