diff --git a/.github/workflows/pytest-remote-data.yml b/.github/workflows/pytest-remote-data.yml index 64c30a0097..6b214f7652 100644 --- a/.github/workflows/pytest-remote-data.yml +++ b/.github/workflows/pytest-remote-data.yml @@ -100,7 +100,7 @@ jobs: SOLARANYWHERE_API_KEY: ${{ secrets.SOLARANYWHERE_API_KEY }} BSRN_FTP_USERNAME: ${{ secrets.BSRN_FTP_USERNAME }} BSRN_FTP_PASSWORD: ${{ secrets.BSRN_FTP_PASSWORD }} - run: pytest pvlib/tests/iotools --cov=./ --cov-report=xml --remote-data + run: pytest tests/iotools --cov=./ --cov-report=xml --remote-data - name: Upload coverage to Codecov if: matrix.python-version == 3.9 && matrix.suffix == '' diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index a91af26d79..7f589d0886 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -79,7 +79,7 @@ jobs: shell: bash -l {0} # necessary for conda env to be active run: | # ignore iotools; those tests are run in a separate workflow - pytest pvlib --cov=./ --cov-report=xml --ignore=pvlib/tests/iotools + pytest tests --cov=./ --cov-report=xml --ignore=tests/iotools - name: Upload coverage to Codecov if: matrix.python-version == 3.9 && matrix.suffix == '' && matrix.os == 'ubuntu-latest' && matrix.environment-type == 'conda' diff --git a/.gitignore b/.gitignore index 21c8d5a998..c9d19f557d 100644 --- a/.gitignore +++ b/.gitignore @@ -81,9 +81,9 @@ coverage.xml # Datafiles -*.csv -# Ignore some csv -!pvlib/data/*.csv +# Do not exclude data directories +!pvlib/data/** +!tests/data/** # vi *.swp diff --git a/codecov.yml b/codecov.yml index 45cb481e68..2f5728b11f 100644 --- a/codecov.yml +++ b/codecov.yml @@ -14,14 +14,15 @@ flags: core: paths: - pvlib/ + - tests/ - '!pvlib/iotools/' - - '!pvlib/tests/iotools/' + - '!tests/iotools/' carryforward: false remote-data: paths: - pvlib/iotools/ - - pvlib/tests/iotools + - tests/iotools carryforward: true # if not run, use coverage from previous commit @@ -47,15 +48,15 @@ coverage: tests-core: target: 95% paths: - - 'pvlib/tests/.*' - - '!pvlib/tests/iotools/.*' + - 'tests/.*' + - '!tests/iotools/.*' flags: - core tests-remote-data: target: 95% paths: - - 'pvlib/tests/iotools/.*' + - 'tests/iotools/.*' flags: - remote-data diff --git a/docs/sphinx/source/contributing/testing.rst b/docs/sphinx/source/contributing/testing.rst index 3fa107fa57..0ece283143 100644 --- a/docs/sphinx/source/contributing/testing.rst +++ b/docs/sphinx/source/contributing/testing.rst @@ -11,7 +11,7 @@ Overview Developers **must** include comprehensive tests for any additions or modifications to pvlib. New unit test code should be placed in the corresponding test module in the -`pvlib/tests `_ +`tests `_ directory. A pull request will automatically run the tests for you on a variety of @@ -30,11 +30,11 @@ pvlib directory:: or, for a single module:: - pytest pvlib/tests/test_clearsky.py + pytest tests/test_clearsky.py or, for a single test:: - pytest pvlib/tests/test_clearsky.py::test_ineichen_nans + pytest tests/test_clearsky.py::test_ineichen_nans We suggest using pytest's ``--pdb`` flag to debug test failures rather than using ``print`` or ``logging`` calls. For example:: diff --git a/docs/sphinx/source/whatsnew/v0.11.3.rst b/docs/sphinx/source/whatsnew/v0.11.3.rst index 8ad6602c25..4f2637f948 100644 --- a/docs/sphinx/source/whatsnew/v0.11.3.rst +++ b/docs/sphinx/source/whatsnew/v0.11.3.rst @@ -16,6 +16,10 @@ Enhancements ground irradiance when the sun was below the horizon. (:issue:`2245`, :pull:`2359`) * Fix a bug where :py:func:`pvlib.transformer.simple_efficiency` could only be imported using the `from pvlib.transformer` syntax (:pull:`2388`) +* Reduced space requirements by excluding tests and test files from wheel. + Zipped wheel is now 66% of the previous size, and installed size is 50% of + the previous size. + (:issue:`2271`, :pull:`2277`) * Correct keys for First Solar modules in `~pvlib.spectrum.spectral_factor_pvspec` (:issue:`2398`, :pull:`2400`) Documentation @@ -27,6 +31,8 @@ Documentation Testing ~~~~~~~ +* Moved tests folder to `/tests` and data exclusively used for testing to `/tests/data`. + (:issue:`2271`, :pull:`2277`) * Added Python 3.13 to test suite. (:pull:`2258`) @@ -51,3 +57,4 @@ Contributors * Manoj K S (:ghuser:`manojks1999`) * Kurt Rhee (:ghuser:`kurt-rhee`) * Ayush jariyal (:ghuser:`ayushjariyal`) +* Echedey Luis (:ghuser:`echedey-ls`) diff --git a/docs/sphinx/source/whatsnew/v0.7.2.rst b/docs/sphinx/source/whatsnew/v0.7.2.rst index 8cabb37cfb..1113abb3f4 100644 --- a/docs/sphinx/source/whatsnew/v0.7.2.rst +++ b/docs/sphinx/source/whatsnew/v0.7.2.rst @@ -46,7 +46,7 @@ Bug fixes * Fix :py:func:`~pvlib.iotools.read_tmy3` parsing when February contains a leap year. (:pull:`866`) * Implement NREL Developer Network API key for consistent success with API - calls in :py:mod:`pvlib.tests.iotools.test_psm3`. (:pull:`873`) + calls in :py:mod:`!pvlib.tests.iotools.test_psm3`. (:pull:`873`) * Fix issue with :py:class:`pvlib.location.Location` creation when passing ``tz=datetime.timezone.utc``. (:pull:`879`) * Fix documentation homepage title to "pvlib python" based on first heading on diff --git a/pyproject.toml b/pyproject.toml index b368cc75df..6929045b55 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -85,14 +85,22 @@ all = ["pvlib[test,optional,doc]"] Documentation = "https://pvlib-python.readthedocs.io/" "Source Code" = "https://github.com/pvlib/pvlib-python" +[tool.setuptools] +# do not include all non-python files in the bdist by default, but select them manually +# https://setuptools.pypa.io/en/latest/userguide/datafiles.html#interplay-between-these-keywords (2024-10-22) +include-package-data = false # true by default + [tool.setuptools.packages.find] include = ["pvlib*"] +[tool.setuptools.package-data] +pvlib = ["data/*"] + [tool.setuptools_scm] [tool.pytest] junit_family = "xunit2" -testpaths = "pvlib/tests" +testpaths = "tests" # warning messages to suppress from pytest output. useful in cases # where a dependency hasn't addressed a deprecation yet, and there's # nothing we can do to fix it ourselves. diff --git a/pvlib/tests/__init__.py b/tests/__init__.py similarity index 100% rename from pvlib/tests/__init__.py rename to tests/__init__.py diff --git a/pvlib/tests/bifacial/__init__.py b/tests/bifacial/__init__.py similarity index 100% rename from pvlib/tests/bifacial/__init__.py rename to tests/bifacial/__init__.py diff --git a/pvlib/tests/bifacial/test_infinite_sheds.py b/tests/bifacial/test_infinite_sheds.py similarity index 99% rename from pvlib/tests/bifacial/test_infinite_sheds.py rename to tests/bifacial/test_infinite_sheds.py index 23de27e428..b689b419d1 100644 --- a/pvlib/tests/bifacial/test_infinite_sheds.py +++ b/tests/bifacial/test_infinite_sheds.py @@ -5,7 +5,7 @@ import numpy as np import pandas as pd from pvlib.bifacial import infinite_sheds -from ..conftest import assert_series_equal +from tests.conftest import assert_series_equal import pytest diff --git a/pvlib/tests/bifacial/test_losses_models.py b/tests/bifacial/test_losses_models.py similarity index 100% rename from pvlib/tests/bifacial/test_losses_models.py rename to tests/bifacial/test_losses_models.py diff --git a/pvlib/tests/bifacial/test_pvfactors.py b/tests/bifacial/test_pvfactors.py similarity index 97% rename from pvlib/tests/bifacial/test_pvfactors.py rename to tests/bifacial/test_pvfactors.py index a199999364..26edcd1bb1 100644 --- a/pvlib/tests/bifacial/test_pvfactors.py +++ b/tests/bifacial/test_pvfactors.py @@ -1,7 +1,7 @@ import pandas as pd from datetime import datetime from pvlib.bifacial.pvfactors import pvfactors_timeseries -from ..conftest import requires_pvfactors, assert_series_equal +from tests.conftest import requires_pvfactors, assert_series_equal import pytest diff --git a/pvlib/tests/bifacial/test_utils.py b/tests/bifacial/test_utils.py similarity index 100% rename from pvlib/tests/bifacial/test_utils.py rename to tests/bifacial/test_utils.py diff --git a/pvlib/tests/conftest.py b/tests/conftest.py similarity index 99% rename from pvlib/tests/conftest.py rename to tests/conftest.py index 21ee60f17b..907936f7b5 100644 --- a/pvlib/tests/conftest.py +++ b/tests/conftest.py @@ -70,7 +70,8 @@ def assert_frame_equal(left, right, **kwargs): # commonly used directories in the tests TEST_DIR = Path(__file__).parent -DATA_DIR = TEST_DIR.parent / 'data' +PVLIB_DATA_DIR = Path(pvlib.__path__[0]) / 'data' +TESTS_DATA_DIR = TEST_DIR / 'data' # pytest-rerunfailures variables diff --git a/pvlib/data/BIRD_08_16_2012.csv b/tests/data/BIRD_08_16_2012.csv similarity index 100% rename from pvlib/data/BIRD_08_16_2012.csv rename to tests/data/BIRD_08_16_2012.csv diff --git a/pvlib/data/BIRD_08_16_2012_patm.csv b/tests/data/BIRD_08_16_2012_patm.csv similarity index 100% rename from pvlib/data/BIRD_08_16_2012_patm.csv rename to tests/data/BIRD_08_16_2012_patm.csv diff --git a/pvlib/data/Burlington, United States SolarAnywhere Time Series 2021 Lat_44_465 Lon_-73_205 TMY3 format.csv b/tests/data/Burlington, United States SolarAnywhere Time Series 2021 Lat_44_465 Lon_-73_205 TMY3 format.csv similarity index 100% rename from pvlib/data/Burlington, United States SolarAnywhere Time Series 2021 Lat_44_465 Lon_-73_205 TMY3 format.csv rename to tests/data/Burlington, United States SolarAnywhere Time Series 2021 Lat_44_465 Lon_-73_205 TMY3 format.csv diff --git a/pvlib/data/Burlington, United States SolarAnywhere Time Series 20210101 to 20210103 Lat_44_4675 Lon_-73_2075 SA format.csv b/tests/data/Burlington, United States SolarAnywhere Time Series 20210101 to 20210103 Lat_44_4675 Lon_-73_2075 SA format.csv similarity index 100% rename from pvlib/data/Burlington, United States SolarAnywhere Time Series 20210101 to 20210103 Lat_44_4675 Lon_-73_2075 SA format.csv rename to tests/data/Burlington, United States SolarAnywhere Time Series 20210101 to 20210103 Lat_44_4675 Lon_-73_2075 SA format.csv diff --git a/pvlib/data/Burlington, United States SolarAnywhere Typical GHI Year Lat_44_465 Lon_-73_205 SA format.csv b/tests/data/Burlington, United States SolarAnywhere Typical GHI Year Lat_44_465 Lon_-73_205 SA format.csv similarity index 100% rename from pvlib/data/Burlington, United States SolarAnywhere Typical GHI Year Lat_44_465 Lon_-73_205 SA format.csv rename to tests/data/Burlington, United States SolarAnywhere Typical GHI Year Lat_44_465 Lon_-73_205 SA format.csv diff --git a/pvlib/data/CPS SCH275KTL-DO-US-800-250kW_275kVA_1.OND b/tests/data/CPS SCH275KTL-DO-US-800-250kW_275kVA_1.OND similarity index 100% rename from pvlib/data/CPS SCH275KTL-DO-US-800-250kW_275kVA_1.OND rename to tests/data/CPS SCH275KTL-DO-US-800-250kW_275kVA_1.OND diff --git a/pvlib/data/CRNS0101-05-2019-AZ_Tucson_11_W.txt b/tests/data/CRNS0101-05-2019-AZ_Tucson_11_W.txt similarity index 100% rename from pvlib/data/CRNS0101-05-2019-AZ_Tucson_11_W.txt rename to tests/data/CRNS0101-05-2019-AZ_Tucson_11_W.txt diff --git a/pvlib/data/CRN_with_problems.txt b/tests/data/CRN_with_problems.txt similarity index 100% rename from pvlib/data/CRN_with_problems.txt rename to tests/data/CRN_with_problems.txt diff --git a/pvlib/data/ET-M772BH550GL.PAN b/tests/data/ET-M772BH550GL.PAN similarity index 100% rename from pvlib/data/ET-M772BH550GL.PAN rename to tests/data/ET-M772BH550GL.PAN diff --git a/pvlib/data/NLD_Amsterdam062400_IWEC.epw b/tests/data/NLD_Amsterdam062400_IWEC.epw similarity index 100% rename from pvlib/data/NLD_Amsterdam062400_IWEC.epw rename to tests/data/NLD_Amsterdam062400_IWEC.epw diff --git a/pvlib/data/PVsyst_demo.csv b/tests/data/PVsyst_demo.csv similarity index 100% rename from pvlib/data/PVsyst_demo.csv rename to tests/data/PVsyst_demo.csv diff --git a/pvlib/data/PVsyst_demo_model.csv b/tests/data/PVsyst_demo_model.csv similarity index 100% rename from pvlib/data/PVsyst_demo_model.csv rename to tests/data/PVsyst_demo_model.csv diff --git a/pvlib/data/SRML-day-EUPO1801.txt b/tests/data/SRML-day-EUPO1801.txt similarity index 100% rename from pvlib/data/SRML-day-EUPO1801.txt rename to tests/data/SRML-day-EUPO1801.txt diff --git a/pvlib/data/abq19056.dat b/tests/data/abq19056.dat similarity index 100% rename from pvlib/data/abq19056.dat rename to tests/data/abq19056.dat diff --git a/pvlib/data/bishop88_numerical_precision.csv b/tests/data/bishop88_numerical_precision.csv similarity index 100% rename from pvlib/data/bishop88_numerical_precision.csv rename to tests/data/bishop88_numerical_precision.csv diff --git a/pvlib/data/bsrn-lr0100-pay0616.dat b/tests/data/bsrn-lr0100-pay0616.dat similarity index 100% rename from pvlib/data/bsrn-lr0100-pay0616.dat rename to tests/data/bsrn-lr0100-pay0616.dat diff --git a/pvlib/data/bsrn-pay0616.dat.gz b/tests/data/bsrn-pay0616.dat.gz similarity index 100% rename from pvlib/data/bsrn-pay0616.dat.gz rename to tests/data/bsrn-pay0616.dat.gz diff --git a/pvlib/data/cams_mcclear_1min_verbose.csv b/tests/data/cams_mcclear_1min_verbose.csv similarity index 100% rename from pvlib/data/cams_mcclear_1min_verbose.csv rename to tests/data/cams_mcclear_1min_verbose.csv diff --git a/pvlib/data/cams_mcclear_monthly.csv b/tests/data/cams_mcclear_monthly.csv similarity index 100% rename from pvlib/data/cams_mcclear_monthly.csv rename to tests/data/cams_mcclear_monthly.csv diff --git a/pvlib/data/cams_radiation_1min_verbose.csv b/tests/data/cams_radiation_1min_verbose.csv similarity index 100% rename from pvlib/data/cams_radiation_1min_verbose.csv rename to tests/data/cams_radiation_1min_verbose.csv diff --git a/pvlib/data/cams_radiation_monthly.csv b/tests/data/cams_radiation_monthly.csv similarity index 100% rename from pvlib/data/cams_radiation_monthly.csv rename to tests/data/cams_radiation_monthly.csv diff --git a/pvlib/data/detect_clearsky_data.csv b/tests/data/detect_clearsky_data.csv similarity index 100% rename from pvlib/data/detect_clearsky_data.csv rename to tests/data/detect_clearsky_data.csv diff --git a/pvlib/data/detect_clearsky_threshold_data.csv b/tests/data/detect_clearsky_threshold_data.csv similarity index 100% rename from pvlib/data/detect_clearsky_threshold_data.csv rename to tests/data/detect_clearsky_threshold_data.csv diff --git a/pvlib/data/greensboro_kimber_soil_manwash.dat b/tests/data/greensboro_kimber_soil_manwash.dat similarity index 100% rename from pvlib/data/greensboro_kimber_soil_manwash.dat rename to tests/data/greensboro_kimber_soil_manwash.dat diff --git a/pvlib/data/greensboro_kimber_soil_nowash.dat b/tests/data/greensboro_kimber_soil_nowash.dat similarity index 100% rename from pvlib/data/greensboro_kimber_soil_nowash.dat rename to tests/data/greensboro_kimber_soil_nowash.dat diff --git a/pvlib/data/inverter_fit_snl_meas.csv b/tests/data/inverter_fit_snl_meas.csv similarity index 100% rename from pvlib/data/inverter_fit_snl_meas.csv rename to tests/data/inverter_fit_snl_meas.csv diff --git a/pvlib/data/inverter_fit_snl_sim.csv b/tests/data/inverter_fit_snl_sim.csv similarity index 100% rename from pvlib/data/inverter_fit_snl_sim.csv rename to tests/data/inverter_fit_snl_sim.csv diff --git a/pvlib/data/ivtools_numdiff.csv b/tests/data/ivtools_numdiff.csv similarity index 100% rename from pvlib/data/ivtools_numdiff.csv rename to tests/data/ivtools_numdiff.csv diff --git a/pvlib/data/midc_20181014.txt b/tests/data/midc_20181014.txt similarity index 100% rename from pvlib/data/midc_20181014.txt rename to tests/data/midc_20181014.txt diff --git a/pvlib/data/midc_raw_20181018.txt b/tests/data/midc_raw_20181018.txt similarity index 100% rename from pvlib/data/midc_raw_20181018.txt rename to tests/data/midc_raw_20181018.txt diff --git a/pvlib/data/midc_raw_short_header_20191115.txt b/tests/data/midc_raw_short_header_20191115.txt similarity index 100% rename from pvlib/data/midc_raw_short_header_20191115.txt rename to tests/data/midc_raw_short_header_20191115.txt diff --git a/pvlib/data/msn19056.dat b/tests/data/msn19056.dat similarity index 100% rename from pvlib/data/msn19056.dat rename to tests/data/msn19056.dat diff --git a/pvlib/data/precise_iv_curves1.json b/tests/data/precise_iv_curves1.json similarity index 100% rename from pvlib/data/precise_iv_curves1.json rename to tests/data/precise_iv_curves1.json diff --git a/pvlib/data/precise_iv_curves2.json b/tests/data/precise_iv_curves2.json similarity index 100% rename from pvlib/data/precise_iv_curves2.json rename to tests/data/precise_iv_curves2.json diff --git a/pvlib/data/precise_iv_curves_parameter_sets1.csv b/tests/data/precise_iv_curves_parameter_sets1.csv similarity index 100% rename from pvlib/data/precise_iv_curves_parameter_sets1.csv rename to tests/data/precise_iv_curves_parameter_sets1.csv diff --git a/pvlib/data/precise_iv_curves_parameter_sets2.csv b/tests/data/precise_iv_curves_parameter_sets2.csv similarity index 100% rename from pvlib/data/precise_iv_curves_parameter_sets2.csv rename to tests/data/precise_iv_curves_parameter_sets2.csv diff --git a/pvlib/data/pvgis_hourly_Timeseries_45.000_8.000_SA2_10kWp_CIS_5_2a_2013_2014.json b/tests/data/pvgis_hourly_Timeseries_45.000_8.000_SA2_10kWp_CIS_5_2a_2013_2014.json similarity index 100% rename from pvlib/data/pvgis_hourly_Timeseries_45.000_8.000_SA2_10kWp_CIS_5_2a_2013_2014.json rename to tests/data/pvgis_hourly_Timeseries_45.000_8.000_SA2_10kWp_CIS_5_2a_2013_2014.json diff --git a/pvlib/data/pvgis_hourly_Timeseries_45.000_8.000_SA_30deg_0deg_2016_2016.csv b/tests/data/pvgis_hourly_Timeseries_45.000_8.000_SA_30deg_0deg_2016_2016.csv similarity index 100% rename from pvlib/data/pvgis_hourly_Timeseries_45.000_8.000_SA_30deg_0deg_2016_2016.csv rename to tests/data/pvgis_hourly_Timeseries_45.000_8.000_SA_30deg_0deg_2016_2016.csv diff --git a/pvlib/data/pvgis_tmy_meta.json b/tests/data/pvgis_tmy_meta.json similarity index 100% rename from pvlib/data/pvgis_tmy_meta.json rename to tests/data/pvgis_tmy_meta.json diff --git a/pvlib/data/pvgis_tmy_test.csv b/tests/data/pvgis_tmy_test.csv similarity index 100% rename from pvlib/data/pvgis_tmy_test.csv rename to tests/data/pvgis_tmy_test.csv diff --git a/pvlib/data/pvwatts_8760_rackmount.csv b/tests/data/pvwatts_8760_rackmount.csv similarity index 100% rename from pvlib/data/pvwatts_8760_rackmount.csv rename to tests/data/pvwatts_8760_rackmount.csv diff --git a/pvlib/data/pvwatts_8760_roofmount.csv b/tests/data/pvwatts_8760_roofmount.csv similarity index 100% rename from pvlib/data/pvwatts_8760_roofmount.csv rename to tests/data/pvwatts_8760_roofmount.csv diff --git a/pvlib/data/singleaxis_tracker_wslope.csv b/tests/data/singleaxis_tracker_wslope.csv similarity index 100% rename from pvlib/data/singleaxis_tracker_wslope.csv rename to tests/data/singleaxis_tracker_wslope.csv diff --git a/pvlib/data/spectrl2_example_spectra.csv b/tests/data/spectrl2_example_spectra.csv similarity index 100% rename from pvlib/data/spectrl2_example_spectra.csv rename to tests/data/spectrl2_example_spectra.csv diff --git a/pvlib/data/surfrad-slv16001.dat b/tests/data/surfrad-slv16001.dat similarity index 100% rename from pvlib/data/surfrad-slv16001.dat rename to tests/data/surfrad-slv16001.dat diff --git a/pvlib/data/test_psm3_2017.csv b/tests/data/test_psm3_2017.csv similarity index 100% rename from pvlib/data/test_psm3_2017.csv rename to tests/data/test_psm3_2017.csv diff --git a/pvlib/data/test_psm3_2019_5min.csv b/tests/data/test_psm3_2019_5min.csv similarity index 100% rename from pvlib/data/test_psm3_2019_5min.csv rename to tests/data/test_psm3_2019_5min.csv diff --git a/pvlib/data/test_psm3_tmy-2017.csv b/tests/data/test_psm3_tmy-2017.csv similarity index 100% rename from pvlib/data/test_psm3_tmy-2017.csv rename to tests/data/test_psm3_tmy-2017.csv diff --git a/pvlib/data/test_read_psm3.csv b/tests/data/test_read_psm3.csv similarity index 100% rename from pvlib/data/test_read_psm3.csv rename to tests/data/test_read_psm3.csv diff --git a/pvlib/data/test_read_pvgis_horizon.csv b/tests/data/test_read_pvgis_horizon.csv similarity index 100% rename from pvlib/data/test_read_pvgis_horizon.csv rename to tests/data/test_read_pvgis_horizon.csv diff --git a/pvlib/data/tmy_45.000_8.000_2005_2023.csv b/tests/data/tmy_45.000_8.000_2005_2023.csv similarity index 100% rename from pvlib/data/tmy_45.000_8.000_2005_2023.csv rename to tests/data/tmy_45.000_8.000_2005_2023.csv diff --git a/pvlib/data/tmy_45.000_8.000_2005_2023.epw b/tests/data/tmy_45.000_8.000_2005_2023.epw similarity index 100% rename from pvlib/data/tmy_45.000_8.000_2005_2023.epw rename to tests/data/tmy_45.000_8.000_2005_2023.epw diff --git a/pvlib/data/tmy_45.000_8.000_2005_2023.json b/tests/data/tmy_45.000_8.000_2005_2023.json similarity index 100% rename from pvlib/data/tmy_45.000_8.000_2005_2023.json rename to tests/data/tmy_45.000_8.000_2005_2023.json diff --git a/pvlib/data/tmy_45.000_8.000_2005_2023.txt b/tests/data/tmy_45.000_8.000_2005_2023.txt similarity index 100% rename from pvlib/data/tmy_45.000_8.000_2005_2023.txt rename to tests/data/tmy_45.000_8.000_2005_2023.txt diff --git a/pvlib/data/tmy_45.000_8.000_userhorizon.json b/tests/data/tmy_45.000_8.000_userhorizon.json similarity index 100% rename from pvlib/data/tmy_45.000_8.000_userhorizon.json rename to tests/data/tmy_45.000_8.000_userhorizon.json diff --git a/pvlib/tests/iotools/__init__.py b/tests/iotools/__init__.py similarity index 100% rename from pvlib/tests/iotools/__init__.py rename to tests/iotools/__init__.py diff --git a/pvlib/tests/iotools/test_acis.py b/tests/iotools/test_acis.py similarity index 99% rename from pvlib/tests/iotools/test_acis.py rename to tests/iotools/test_acis.py index 8458e9b930..7db591f749 100644 --- a/pvlib/tests/iotools/test_acis.py +++ b/tests/iotools/test_acis.py @@ -9,7 +9,7 @@ get_acis_prism, get_acis_nrcc, get_acis_mpe, get_acis_station_data, get_acis_available_stations ) -from ..conftest import RERUNS, RERUNS_DELAY, assert_frame_equal +from tests.conftest import RERUNS, RERUNS_DELAY, assert_frame_equal from requests import HTTPError diff --git a/pvlib/tests/iotools/test_bsrn.py b/tests/iotools/test_bsrn.py similarity index 91% rename from pvlib/tests/iotools/test_bsrn.py rename to tests/iotools/test_bsrn.py index 815b5d84c9..6a01511e93 100644 --- a/pvlib/tests/iotools/test_bsrn.py +++ b/tests/iotools/test_bsrn.py @@ -7,8 +7,13 @@ import os import tempfile from pvlib.iotools import read_bsrn, get_bsrn -from ..conftest import (DATA_DIR, RERUNS, RERUNS_DELAY, assert_index_equal, - requires_bsrn_credentials) +from tests.conftest import ( + TESTS_DATA_DIR, + RERUNS, + RERUNS_DELAY, + assert_index_equal, + requires_bsrn_credentials, +) @pytest.fixture(scope="module") @@ -33,7 +38,7 @@ def expected_index(): ('bsrn-lr0100-pay0616.dat'), ]) def test_read_bsrn(testfile, expected_index): - data, metadata = read_bsrn(DATA_DIR / testfile) + data, metadata = read_bsrn(TESTS_DATA_DIR / testfile) assert_index_equal(expected_index, data.index) assert 'ghi' in data.columns assert 'dni_std' in data.columns @@ -45,7 +50,7 @@ def test_read_bsrn(testfile, expected_index): def test_read_bsrn_logical_records(expected_index): # Test if logical records 0300 and 0500 are correct parsed # and that 0100 is not passed when not specified - data, metadata = read_bsrn(DATA_DIR / 'bsrn-pay0616.dat.gz', + data, metadata = read_bsrn(TESTS_DATA_DIR / 'bsrn-pay0616.dat.gz', logical_records=['0300', '0500']) assert_index_equal(expected_index, data.index) assert 'lwu' in data.columns @@ -57,13 +62,13 @@ def test_read_bsrn_logical_records(expected_index): def test_read_bsrn_bad_logical_record(): # Test if ValueError is raised if an unsupported logical record is passed with pytest.raises(ValueError, match='not in'): - read_bsrn(DATA_DIR / 'bsrn-lr0100-pay0616.dat', + read_bsrn(TESTS_DATA_DIR / 'bsrn-lr0100-pay0616.dat', logical_records=['dummy']) def test_read_bsrn_logical_records_not_found(): # Test if an empty dataframe is returned if specified LRs are not present - data, metadata = read_bsrn(DATA_DIR / 'bsrn-lr0100-pay0616.dat', + data, metadata = read_bsrn(TESTS_DATA_DIR / 'bsrn-lr0100-pay0616.dat', logical_records=['0300', '0500']) assert data.empty # assert that the dataframe is empty assert 'uva_global' in data.columns diff --git a/pvlib/tests/iotools/test_crn.py b/tests/iotools/test_crn.py similarity index 94% rename from pvlib/tests/iotools/test_crn.py rename to tests/iotools/test_crn.py index 8d880e0432..882e553d71 100644 --- a/pvlib/tests/iotools/test_crn.py +++ b/tests/iotools/test_crn.py @@ -3,7 +3,11 @@ from numpy import dtype, nan import pytest from pvlib.iotools import crn -from ..conftest import DATA_DIR, assert_frame_equal, assert_index_equal +from tests.conftest import ( + TESTS_DATA_DIR, + assert_frame_equal, + assert_index_equal, +) @pytest.fixture @@ -41,12 +45,12 @@ def dtypes(): @pytest.fixture def testfile(): - return DATA_DIR / 'CRNS0101-05-2019-AZ_Tucson_11_W.txt' + return TESTS_DATA_DIR / 'CRNS0101-05-2019-AZ_Tucson_11_W.txt' @pytest.fixture def testfile_problems(): - return DATA_DIR / 'CRN_with_problems.txt' + return TESTS_DATA_DIR / 'CRN_with_problems.txt' def test_read_crn(testfile, columns_mapped, dtypes): diff --git a/pvlib/tests/iotools/test_epw.py b/tests/iotools/test_epw.py similarity index 80% rename from pvlib/tests/iotools/test_epw.py rename to tests/iotools/test_epw.py index f9e9ccba39..43e8e4cb48 100644 --- a/pvlib/tests/iotools/test_epw.py +++ b/tests/iotools/test_epw.py @@ -1,9 +1,9 @@ import pytest from pvlib.iotools import epw -from ..conftest import DATA_DIR, RERUNS, RERUNS_DELAY +from tests.conftest import TESTS_DATA_DIR, RERUNS, RERUNS_DELAY -epw_testfile = DATA_DIR / 'NLD_Amsterdam062400_IWEC.epw' +epw_testfile = TESTS_DATA_DIR / 'NLD_Amsterdam062400_IWEC.epw' def test_read_epw(): diff --git a/pvlib/tests/iotools/test_midc.py b/tests/iotools/test_midc.py similarity index 91% rename from pvlib/tests/iotools/test_midc.py rename to tests/iotools/test_midc.py index 96992babba..9a327d1394 100644 --- a/pvlib/tests/iotools/test_midc.py +++ b/tests/iotools/test_midc.py @@ -3,7 +3,7 @@ import pytz from pvlib.iotools import midc -from ..conftest import DATA_DIR, RERUNS, RERUNS_DELAY +from tests.conftest import TESTS_DATA_DIR, RERUNS, RERUNS_DELAY @pytest.fixture @@ -17,10 +17,10 @@ def test_mapping(): } -MIDC_TESTFILE = DATA_DIR / 'midc_20181014.txt' -MIDC_RAW_TESTFILE = DATA_DIR / 'midc_raw_20181018.txt' +MIDC_TESTFILE = TESTS_DATA_DIR / 'midc_20181014.txt' +MIDC_RAW_TESTFILE = TESTS_DATA_DIR / 'midc_raw_20181018.txt' MIDC_RAW_SHORT_HEADER_TESTFILE = ( - DATA_DIR / 'midc_raw_short_header_20191115.txt') + TESTS_DATA_DIR / 'midc_raw_short_header_20191115.txt') # TODO: not used, remove? # midc_network_testfile = ('https://midcdmz.nrel.gov/apps/data_api.pl' diff --git a/pvlib/tests/iotools/test_panond.py b/tests/iotools/test_panond.py similarity index 85% rename from pvlib/tests/iotools/test_panond.py rename to tests/iotools/test_panond.py index a692d3e119..3b62d9463f 100644 --- a/pvlib/tests/iotools/test_panond.py +++ b/tests/iotools/test_panond.py @@ -3,10 +3,11 @@ """ from pvlib.iotools import read_panond -from pvlib.tests.conftest import DATA_DIR -PAN_FILE = DATA_DIR / 'ET-M772BH550GL.PAN' -OND_FILE = DATA_DIR / 'CPS SCH275KTL-DO-US-800-250kW_275kVA_1.OND' +from tests.conftest import TESTS_DATA_DIR + +PAN_FILE = TESTS_DATA_DIR / 'ET-M772BH550GL.PAN' +OND_FILE = TESTS_DATA_DIR / 'CPS SCH275KTL-DO-US-800-250kW_275kVA_1.OND' def test_read_panond(): diff --git a/pvlib/tests/iotools/test_psm3.py b/tests/iotools/test_psm3.py similarity index 95% rename from pvlib/tests/iotools/test_psm3.py rename to tests/iotools/test_psm3.py index b68671696b..6affa4811f 100644 --- a/pvlib/tests/iotools/test_psm3.py +++ b/tests/iotools/test_psm3.py @@ -2,21 +2,25 @@ test iotools for PSM3 """ -import os from pvlib.iotools import psm3 -from ..conftest import DATA_DIR, RERUNS, RERUNS_DELAY, assert_index_equal +from tests.conftest import ( + TESTS_DATA_DIR, + RERUNS, + RERUNS_DELAY, + assert_index_equal, +) import numpy as np import pandas as pd import pytest +import os from requests import HTTPError from io import StringIO import warnings -from pvlib._deprecation import pvlibDeprecationWarning -TMY_TEST_DATA = DATA_DIR / 'test_psm3_tmy-2017.csv' -YEAR_TEST_DATA = DATA_DIR / 'test_psm3_2017.csv' -YEAR_TEST_DATA_5MIN = DATA_DIR / 'test_psm3_2019_5min.csv' -MANUAL_TEST_DATA = DATA_DIR / 'test_read_psm3.csv' +TMY_TEST_DATA = TESTS_DATA_DIR / 'test_psm3_tmy-2017.csv' +YEAR_TEST_DATA = TESTS_DATA_DIR / 'test_psm3_2017.csv' +YEAR_TEST_DATA_5MIN = TESTS_DATA_DIR / 'test_psm3_2019_5min.csv' +MANUAL_TEST_DATA = TESTS_DATA_DIR / 'test_read_psm3.csv' LATITUDE, LONGITUDE = 40.5137, -108.5449 METADATA_FIELDS = [ 'Source', 'Location ID', 'City', 'State', 'Country', 'Latitude', diff --git a/pvlib/tests/iotools/test_pvgis.py b/tests/iotools/test_pvgis.py similarity index 97% rename from pvlib/tests/iotools/test_pvgis.py rename to tests/iotools/test_pvgis.py index 9a999592a7..a8290d7f91 100644 --- a/pvlib/tests/iotools/test_pvgis.py +++ b/tests/iotools/test_pvgis.py @@ -10,16 +10,21 @@ from pvlib.iotools import get_pvgis_tmy, read_pvgis_tmy from pvlib.iotools import get_pvgis_hourly, read_pvgis_hourly from pvlib.iotools import get_pvgis_horizon -from ..conftest import (DATA_DIR, RERUNS, RERUNS_DELAY, assert_frame_equal, - assert_series_equal) +from tests.conftest import ( + TESTS_DATA_DIR, + RERUNS, + RERUNS_DELAY, + assert_frame_equal, + assert_series_equal, +) # PVGIS Hourly tests # The test files are actual files from PVGIS where the data section have been # reduced to only a few lines -testfile_radiation_csv = DATA_DIR / \ +testfile_radiation_csv = TESTS_DATA_DIR / \ 'pvgis_hourly_Timeseries_45.000_8.000_SA_30deg_0deg_2016_2016.csv' -testfile_pv_json = DATA_DIR / \ +testfile_pv_json = TESTS_DATA_DIR / \ 'pvgis_hourly_Timeseries_45.000_8.000_SA2_10kWp_CIS_5_2a_2013_2014.json' index_radiation_csv = \ @@ -304,12 +309,14 @@ def test_read_pvgis_hourly_empty_file(): # PVGIS TMY tests @pytest.fixture def expected(): - return pd.read_csv(DATA_DIR / 'pvgis_tmy_test.csv', index_col='time(UTC)') + return pd.read_csv( + TESTS_DATA_DIR / "pvgis_tmy_test.csv", index_col="time(UTC)" + ) @pytest.fixture def userhorizon_expected(): - return pd.read_json(DATA_DIR / 'tmy_45.000_8.000_userhorizon.json') + return pd.read_json(TESTS_DATA_DIR / 'tmy_45.000_8.000_userhorizon.json') @pytest.fixture @@ -348,7 +355,7 @@ def epw_meta(): @pytest.fixture def meta_expected(): - with (DATA_DIR / 'pvgis_tmy_meta.json').open() as f: + with (TESTS_DATA_DIR / 'pvgis_tmy_meta.json').open() as f: return json.load(f) @@ -550,7 +557,7 @@ def test_get_pvgis_map_variables(pvgis_tmy_mapped_columns): @pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY) def test_read_pvgis_horizon(): pvgis_data, _ = get_pvgis_horizon(35.171051, -106.465158) - horizon_data = pd.read_csv(DATA_DIR / 'test_read_pvgis_horizon.csv', + horizon_data = pd.read_csv(TESTS_DATA_DIR / 'test_read_pvgis_horizon.csv', index_col=0) horizon_data = horizon_data['horizon_elevation'] assert_series_equal(pvgis_data, horizon_data) @@ -564,14 +571,14 @@ def test_read_pvgis_horizon_invalid_coords(): def test_read_pvgis_tmy_map_variables(pvgis_tmy_mapped_columns): - fn = DATA_DIR / 'tmy_45.000_8.000_2005_2023.json' + fn = TESTS_DATA_DIR / 'tmy_45.000_8.000_2005_2023.json' actual, _, _, _ = read_pvgis_tmy(fn, map_variables=True) assert all(c in pvgis_tmy_mapped_columns for c in actual.columns) def test_read_pvgis_tmy_json(expected, month_year_expected, inputs_expected, meta_expected): - fn = DATA_DIR / 'tmy_45.000_8.000_2005_2023.json' + fn = TESTS_DATA_DIR / 'tmy_45.000_8.000_2005_2023.json' # infer outputformat from file extensions pvgis_data = read_pvgis_tmy(fn, map_variables=False) _compare_pvgis_tmy_json(expected, month_year_expected, inputs_expected, @@ -588,7 +595,7 @@ def test_read_pvgis_tmy_json(expected, month_year_expected, inputs_expected, def test_read_pvgis_tmy_epw(expected, epw_meta): - fn = DATA_DIR / 'tmy_45.000_8.000_2005_2023.epw' + fn = TESTS_DATA_DIR / 'tmy_45.000_8.000_2005_2023.epw' # infer outputformat from file extensions pvgis_data = read_pvgis_tmy(fn, map_variables=False) _compare_pvgis_tmy_epw(expected, epw_meta, pvgis_data) @@ -603,7 +610,7 @@ def test_read_pvgis_tmy_epw(expected, epw_meta): def test_read_pvgis_tmy_csv(expected, month_year_expected, inputs_expected, meta_expected, csv_meta): - fn = DATA_DIR / 'tmy_45.000_8.000_2005_2023.csv' + fn = TESTS_DATA_DIR / 'tmy_45.000_8.000_2005_2023.csv' # infer outputformat from file extensions pvgis_data = read_pvgis_tmy(fn, map_variables=False) _compare_pvgis_tmy_csv(expected, month_year_expected, inputs_expected, @@ -620,7 +627,7 @@ def test_read_pvgis_tmy_csv(expected, month_year_expected, inputs_expected, def test_read_pvgis_tmy_basic(expected, meta_expected): - fn = DATA_DIR / 'tmy_45.000_8.000_2005_2023.txt' + fn = TESTS_DATA_DIR / 'tmy_45.000_8.000_2005_2023.txt' # XXX: can't infer outputformat from file extensions for basic with pytest.raises(ValueError, match="pvgis format 'txt' was unknown"): read_pvgis_tmy(fn, map_variables=False) diff --git a/pvlib/tests/iotools/test_sodapro.py b/tests/iotools/test_sodapro.py similarity index 97% rename from pvlib/tests/iotools/test_sodapro.py rename to tests/iotools/test_sodapro.py index 83983d2b68..93e3c39cff 100644 --- a/pvlib/tests/iotools/test_sodapro.py +++ b/tests/iotools/test_sodapro.py @@ -8,13 +8,13 @@ import pytest from pvlib.iotools import sodapro -from ..conftest import DATA_DIR, assert_frame_equal +from tests.conftest import TESTS_DATA_DIR, assert_frame_equal -testfile_mcclear_verbose = DATA_DIR / 'cams_mcclear_1min_verbose.csv' -testfile_mcclear_monthly = DATA_DIR / 'cams_mcclear_monthly.csv' -testfile_radiation_verbose = DATA_DIR / 'cams_radiation_1min_verbose.csv' -testfile_radiation_monthly = DATA_DIR / 'cams_radiation_monthly.csv' +testfile_mcclear_verbose = TESTS_DATA_DIR / 'cams_mcclear_1min_verbose.csv' +testfile_mcclear_monthly = TESTS_DATA_DIR / 'cams_mcclear_monthly.csv' +testfile_radiation_verbose = TESTS_DATA_DIR / 'cams_radiation_1min_verbose.csv' +testfile_radiation_monthly = TESTS_DATA_DIR / 'cams_radiation_monthly.csv' index_verbose = pd.date_range('2020-06-01 12', periods=4, freq='1min', diff --git a/pvlib/tests/iotools/test_solaranywhere.py b/tests/iotools/test_solaranywhere.py similarity index 96% rename from pvlib/tests/iotools/test_solaranywhere.py rename to tests/iotools/test_solaranywhere.py index 018c583be8..accb6a930d 100644 --- a/pvlib/tests/iotools/test_solaranywhere.py +++ b/tests/iotools/test_solaranywhere.py @@ -2,14 +2,18 @@ import pytest import pvlib import os -from ..conftest import (DATA_DIR, RERUNS, RERUNS_DELAY, - requires_solaranywhere_credentials) +from tests.conftest import ( + TESTS_DATA_DIR, + RERUNS, + RERUNS_DELAY, + requires_solaranywhere_credentials, +) # High spatial resolution and 5-min data, true dynamics enabled -TESTFILE_HIGH_RESOLUTION = DATA_DIR / 'Burlington, United States SolarAnywhere Time Series 20210101 to 20210103 Lat_44_4675 Lon_-73_2075 SA format.csv' # noqa: E501 +TESTFILE_HIGH_RESOLUTION = TESTS_DATA_DIR / 'Burlington, United States SolarAnywhere Time Series 20210101 to 20210103 Lat_44_4675 Lon_-73_2075 SA format.csv' # noqa: E501 # TGY test file (v3.6) containing GHI/DHI and temperature. # Note, the test file only contains the first three days. -TESTFILE_TMY = DATA_DIR / 'Burlington, United States SolarAnywhere Typical GHI Year Lat_44_465 Lon_-73_205 SA format.csv' # noqa: E501 +TESTFILE_TMY = TESTS_DATA_DIR / 'Burlington, United States SolarAnywhere Typical GHI Year Lat_44_465 Lon_-73_205 SA format.csv' # noqa: E501 @pytest.fixture(scope="module") diff --git a/pvlib/tests/iotools/test_solargis.py b/tests/iotools/test_solargis.py similarity index 95% rename from pvlib/tests/iotools/test_solargis.py rename to tests/iotools/test_solargis.py index 55882e91c5..f7aedd58f0 100644 --- a/pvlib/tests/iotools/test_solargis.py +++ b/tests/iotools/test_solargis.py @@ -2,8 +2,12 @@ import pytest import pvlib import requests -from ..conftest import (RERUNS, RERUNS_DELAY, assert_frame_equal, - assert_index_equal) +from tests.conftest import ( + RERUNS, + RERUNS_DELAY, + assert_frame_equal, + assert_index_equal, +) @pytest.fixture diff --git a/pvlib/tests/iotools/test_solcast.py b/tests/iotools/test_solcast.py similarity index 100% rename from pvlib/tests/iotools/test_solcast.py rename to tests/iotools/test_solcast.py diff --git a/pvlib/tests/iotools/test_solrad.py b/tests/iotools/test_solrad.py similarity index 97% rename from pvlib/tests/iotools/test_solrad.py rename to tests/iotools/test_solrad.py index 963014302b..387ef026f2 100644 --- a/pvlib/tests/iotools/test_solrad.py +++ b/tests/iotools/test_solrad.py @@ -5,11 +5,16 @@ import pytest from pvlib.iotools import solrad -from ..conftest import DATA_DIR, assert_frame_equal, RERUNS, RERUNS_DELAY +from tests.conftest import ( + TESTS_DATA_DIR, + assert_frame_equal, + RERUNS, + RERUNS_DELAY, +) -testfile = DATA_DIR / 'abq19056.dat' -testfile_mad = DATA_DIR / 'msn19056.dat' +testfile = TESTS_DATA_DIR / 'abq19056.dat' +testfile_mad = TESTS_DATA_DIR / 'msn19056.dat' https_testfile = ('https://gml.noaa.gov/aftp/data/radiation/solrad/msn/' '2019/msn19056.dat') diff --git a/pvlib/tests/iotools/test_srml.py b/tests/iotools/test_srml.py similarity index 95% rename from pvlib/tests/iotools/test_srml.py rename to tests/iotools/test_srml.py index 80e76d4635..c40ea494c1 100644 --- a/pvlib/tests/iotools/test_srml.py +++ b/tests/iotools/test_srml.py @@ -3,10 +3,15 @@ import pytest from pvlib.iotools import srml -from ..conftest import (DATA_DIR, RERUNS, RERUNS_DELAY, assert_index_equal, - assert_frame_equal) - -srml_testfile = DATA_DIR / 'SRML-day-EUPO1801.txt' +from tests.conftest import ( + TESTS_DATA_DIR, + RERUNS, + RERUNS_DELAY, + assert_index_equal, + assert_frame_equal, +) + +srml_testfile = TESTS_DATA_DIR / 'SRML-day-EUPO1801.txt' def test_read_srml(): diff --git a/pvlib/tests/iotools/test_surfrad.py b/tests/iotools/test_surfrad.py similarity index 95% rename from pvlib/tests/iotools/test_surfrad.py rename to tests/iotools/test_surfrad.py index 83f7ec7645..ce12428713 100644 --- a/pvlib/tests/iotools/test_surfrad.py +++ b/tests/iotools/test_surfrad.py @@ -2,9 +2,9 @@ import pytest from pvlib.iotools import surfrad -from ..conftest import DATA_DIR, RERUNS, RERUNS_DELAY +from tests.conftest import TESTS_DATA_DIR, RERUNS, RERUNS_DELAY -testfile = DATA_DIR / 'surfrad-slv16001.dat' +testfile = TESTS_DATA_DIR / 'surfrad-slv16001.dat' network_testfile = ('ftp://aftp.cmdl.noaa.gov/data/radiation/surfrad/' 'Alamosa_CO/2016/slv16001.dat') https_testfile = ('https://gml.noaa.gov/aftp/data/radiation/surfrad/' diff --git a/pvlib/tests/iotools/test_tmy.py b/tests/iotools/test_tmy.py similarity index 93% rename from pvlib/tests/iotools/test_tmy.py rename to tests/iotools/test_tmy.py index 9107f78b33..35e8542338 100644 --- a/pvlib/tests/iotools/test_tmy.py +++ b/tests/iotools/test_tmy.py @@ -2,19 +2,19 @@ import pandas as pd from pvlib.iotools import tmy from pvlib._deprecation import pvlibDeprecationWarning -from ..conftest import DATA_DIR +from tests.conftest import TESTS_DATA_DIR, PVLIB_DATA_DIR import pytest import warnings # test the API works from pvlib.iotools import read_tmy3 -TMY2_TESTFILE = DATA_DIR / '12839.tm2' +TMY2_TESTFILE = PVLIB_DATA_DIR / '12839.tm2' # TMY3 format (two files below) represents midnight as 24:00 -TMY3_TESTFILE = DATA_DIR / '703165TY.csv' -TMY3_FEB_LEAPYEAR = DATA_DIR / '723170TYA.CSV' +TMY3_TESTFILE = PVLIB_DATA_DIR / '703165TY.csv' +TMY3_FEB_LEAPYEAR = PVLIB_DATA_DIR / '723170TYA.CSV' # The SolarAnywhere TMY3 format (file below) represents midnight as 00:00 -TMY3_SOLARANYWHERE = DATA_DIR / 'Burlington, United States SolarAnywhere Time Series 2021 Lat_44_465 Lon_-73_205 TMY3 format.csv' # noqa: E501 +TMY3_SOLARANYWHERE = TESTS_DATA_DIR / 'Burlington, United States SolarAnywhere Time Series 2021 Lat_44_465 Lon_-73_205 TMY3 format.csv' # noqa: E501 def test_read_tmy3(): diff --git a/pvlib/tests/ivtools/__init__.py b/tests/ivtools/__init__.py similarity index 100% rename from pvlib/tests/ivtools/__init__.py rename to tests/ivtools/__init__.py diff --git a/pvlib/tests/ivtools/test_sde.py b/tests/ivtools/test_sde.py similarity index 99% rename from pvlib/tests/ivtools/test_sde.py rename to tests/ivtools/test_sde.py index 66d2e1e54d..a465d448c4 100644 --- a/pvlib/tests/ivtools/test_sde.py +++ b/tests/ivtools/test_sde.py @@ -2,7 +2,6 @@ import pytest from pvlib import pvsystem from pvlib.ivtools import sde -from pvlib._deprecation import pvlibDeprecationWarning @pytest.fixture diff --git a/pvlib/tests/ivtools/test_sdm.py b/tests/ivtools/test_sdm.py similarity index 99% rename from pvlib/tests/ivtools/test_sdm.py rename to tests/ivtools/test_sdm.py index e0def04621..19599ff0a0 100644 --- a/pvlib/tests/ivtools/test_sdm.py +++ b/tests/ivtools/test_sdm.py @@ -8,9 +8,7 @@ from pvlib.ivtools import sdm from pvlib import pvsystem -from pvlib.tests.conftest import requires_pysam, requires_statsmodels - -from ..conftest import DATA_DIR +from tests.conftest import requires_pysam, requires_statsmodels, TESTS_DATA_DIR @pytest.fixture @@ -152,7 +150,7 @@ def _read_iv_curves_for_test(datafile, npts): ivcurves = dict.fromkeys(['i_sc', 'i_mp', 'v_mp', 'v_oc', 'poa', 'tc', 'ee']) - infilen = DATA_DIR / datafile + infilen = TESTS_DATA_DIR / datafile with infilen.open(mode='r') as f: Ns, aIsc, bVoc, descr = f.readline().split(',') @@ -216,7 +214,7 @@ def _read_pvsyst_expected(datafile): varlist = ['iph', 'io', 'rs', 'rsh', 'u'] pvsyst = dict.fromkeys(paramlist + varlist) - infilen = DATA_DIR / datafile + infilen = TESTS_DATA_DIR / datafile with infilen.open(mode='r') as f: Ns, aIsc, bVoc, descr = f.readline().split(',') diff --git a/pvlib/tests/ivtools/test_utils.py b/tests/ivtools/test_utils.py similarity index 98% rename from pvlib/tests/ivtools/test_utils.py rename to tests/ivtools/test_utils.py index d8a35e554d..24c5cd81ad 100644 --- a/pvlib/tests/ivtools/test_utils.py +++ b/tests/ivtools/test_utils.py @@ -4,7 +4,7 @@ from pvlib.ivtools.utils import _numdiff, rectify_iv_curve, astm_e1036 from pvlib.ivtools.utils import _schumaker_qspline -from ..conftest import DATA_DIR +from tests.conftest import TESTS_DATA_DIR @pytest.fixture @@ -17,7 +17,7 @@ def ivcurve(): def test__numdiff(): - iv = pd.read_csv(DATA_DIR / 'ivtools_numdiff.csv', + iv = pd.read_csv(TESTS_DATA_DIR / 'ivtools_numdiff.csv', names=['I', 'V', 'dIdV', 'd2IdV2'], dtype=float) df, d2f = _numdiff(iv.V, iv.I) assert np.allclose(iv.dIdV, df, equal_nan=True) diff --git a/pvlib/tests/spectrum/__init__.py b/tests/spectrum/__init__.py similarity index 100% rename from pvlib/tests/spectrum/__init__.py rename to tests/spectrum/__init__.py diff --git a/pvlib/tests/spectrum/conftest.py b/tests/spectrum/conftest.py similarity index 90% rename from pvlib/tests/spectrum/conftest.py rename to tests/spectrum/conftest.py index 6e2a42c05c..8f1b4d27df 100644 --- a/pvlib/tests/spectrum/conftest.py +++ b/tests/spectrum/conftest.py @@ -2,9 +2,9 @@ import pytest import pandas as pd -from ..conftest import DATA_DIR +from tests.conftest import TESTS_DATA_DIR -SPECTRL2_TEST_DATA = DATA_DIR / 'spectrl2_example_spectra.csv' +SPECTRL2_TEST_DATA = TESTS_DATA_DIR / 'spectrl2_example_spectra.csv' @pytest.fixture diff --git a/pvlib/tests/spectrum/test_irradiance.py b/tests/spectrum/test_irradiance.py similarity index 98% rename from pvlib/tests/spectrum/test_irradiance.py rename to tests/spectrum/test_irradiance.py index 63b0bc95d2..f53948dd82 100644 --- a/pvlib/tests/spectrum/test_irradiance.py +++ b/tests/spectrum/test_irradiance.py @@ -5,7 +5,7 @@ from pvlib import spectrum from pvlib._deprecation import pvlibDeprecationWarning -from ..conftest import assert_series_equal, fail_on_pvlib_version +from tests.conftest import assert_series_equal, fail_on_pvlib_version @fail_on_pvlib_version('0.12') diff --git a/pvlib/tests/spectrum/test_mismatch.py b/tests/spectrum/test_mismatch.py similarity index 99% rename from pvlib/tests/spectrum/test_mismatch.py rename to tests/spectrum/test_mismatch.py index ed2257747f..69ed476f59 100644 --- a/pvlib/tests/spectrum/test_mismatch.py +++ b/tests/spectrum/test_mismatch.py @@ -4,7 +4,7 @@ import numpy as np from pvlib import spectrum -from ..conftest import assert_series_equal +from tests.conftest import assert_series_equal def test_calc_spectral_mismatch_field(spectrl2_data): diff --git a/pvlib/tests/spectrum/test_response.py b/tests/spectrum/test_response.py similarity index 100% rename from pvlib/tests/spectrum/test_response.py rename to tests/spectrum/test_response.py diff --git a/pvlib/tests/spectrum/test_spectrl2.py b/tests/spectrum/test_spectrl2.py similarity index 100% rename from pvlib/tests/spectrum/test_spectrl2.py rename to tests/spectrum/test_spectrl2.py diff --git a/pvlib/tests/test__deprecation.py b/tests/test__deprecation.py similarity index 100% rename from pvlib/tests/test__deprecation.py rename to tests/test__deprecation.py diff --git a/pvlib/tests/test_albedo.py b/tests/test_albedo.py similarity index 100% rename from pvlib/tests/test_albedo.py rename to tests/test_albedo.py diff --git a/pvlib/tests/test_atmosphere.py b/tests/test_atmosphere.py similarity index 100% rename from pvlib/tests/test_atmosphere.py rename to tests/test_atmosphere.py diff --git a/pvlib/tests/test_clearsky.py b/tests/test_clearsky.py similarity index 99% rename from pvlib/tests/test_clearsky.py rename to tests/test_clearsky.py index f7300b98a9..ef943ac39d 100644 --- a/pvlib/tests/test_clearsky.py +++ b/tests/test_clearsky.py @@ -16,7 +16,7 @@ from pvlib import atmosphere from pvlib import irradiance -from .conftest import DATA_DIR +from .conftest import TESTS_DATA_DIR def test_ineichen_series(): @@ -513,7 +513,7 @@ def monthly_lt_nointerp(lat, lon, time=months): @pytest.fixture def detect_clearsky_data(): - data_file = DATA_DIR / 'detect_clearsky_data.csv' + data_file = TESTS_DATA_DIR / 'detect_clearsky_data.csv' expected = pd.read_csv( data_file, index_col=0, parse_dates=True, comment='#') expected = expected.tz_localize('UTC').tz_convert('Etc/GMT+7') @@ -537,7 +537,7 @@ def detect_clearsky_data(): def detect_clearsky_threshold_data(): # this is (roughly) just a 2 hour period of the same data in # detect_clearsky_data (which only spans 30 minutes) - data_file = DATA_DIR / 'detect_clearsky_threshold_data.csv' + data_file = TESTS_DATA_DIR / 'detect_clearsky_threshold_data.csv' expected = pd.read_csv( data_file, index_col=0, parse_dates=True, comment='#') expected = expected.tz_localize('UTC').tz_convert('Etc/GMT+7') @@ -787,7 +787,7 @@ def test_bird(): etr, b_a, alb ) Eb, Ebh, Gh, Dh = (irrads[_] for _ in field_names) - data_path = DATA_DIR / 'BIRD_08_16_2012.csv' + data_path = TESTS_DATA_DIR / 'BIRD_08_16_2012.csv' testdata = pd.read_csv(data_path, usecols=range(1, 26), header=1).dropna() testdata[['DEC', 'EQT']] = testdata[['DEC', 'EQT']].shift(tz) testdata = testdata[:tz] @@ -848,7 +848,7 @@ def test_bird(): zenith, airmass, aod_380nm, aod_500nm, h2o_cm, dni_extra=etr ) Eb2, Ebh2, Gh2, Dh2 = (irrads2[_] for _ in field_names) - data_path = DATA_DIR / 'BIRD_08_16_2012_patm.csv' + data_path = TESTS_DATA_DIR / 'BIRD_08_16_2012_patm.csv' testdata2 = pd.read_csv(data_path, usecols=range(1, 26), header=1).dropna() testdata2[['DEC', 'EQT']] = testdata2[['DEC', 'EQT']].shift(tz) testdata2 = testdata2[:tz] diff --git a/pvlib/tests/test_conftest.py b/tests/test_conftest.py similarity index 97% rename from pvlib/tests/test_conftest.py rename to tests/test_conftest.py index c0baf7654d..fc8b14c31c 100644 --- a/pvlib/tests/test_conftest.py +++ b/tests/test_conftest.py @@ -1,6 +1,6 @@ import pytest -from pvlib.tests import conftest +from tests import conftest @pytest.mark.parametrize('function_name', ['assert_index_equal', diff --git a/pvlib/tests/test_iam.py b/tests/test_iam.py similarity index 100% rename from pvlib/tests/test_iam.py rename to tests/test_iam.py diff --git a/pvlib/tests/test_inverter.py b/tests/test_inverter.py similarity index 97% rename from pvlib/tests/test_inverter.py rename to tests/test_inverter.py index 6c854efba2..5794669ec9 100644 --- a/pvlib/tests/test_inverter.py +++ b/tests/test_inverter.py @@ -4,7 +4,7 @@ from .conftest import assert_series_equal from numpy.testing import assert_allclose -from .conftest import DATA_DIR +from .conftest import TESTS_DATA_DIR import pytest from pvlib import inverter @@ -190,8 +190,8 @@ def test_pvwatts_multi(): assert_series_equal(pd.Series(expected), out) -INVERTER_TEST_MEAS = DATA_DIR / 'inverter_fit_snl_meas.csv' -INVERTER_TEST_SIM = DATA_DIR / 'inverter_fit_snl_sim.csv' +INVERTER_TEST_MEAS = TESTS_DATA_DIR / 'inverter_fit_snl_meas.csv' +INVERTER_TEST_SIM = TESTS_DATA_DIR / 'inverter_fit_snl_sim.csv' @pytest.mark.parametrize('infilen, expected', [ diff --git a/pvlib/tests/test_irradiance.py b/tests/test_irradiance.py similarity index 100% rename from pvlib/tests/test_irradiance.py rename to tests/test_irradiance.py diff --git a/pvlib/tests/test_location.py b/tests/test_location.py similarity index 98% rename from pvlib/tests/test_location.py rename to tests/test_location.py index e04b10ab4c..9c43ed2faa 100644 --- a/pvlib/tests/test_location.py +++ b/tests/test_location.py @@ -211,7 +211,7 @@ def test_get_clearsky_valueerror(times): def test_from_tmy_3(): - from pvlib.tests.iotools.test_tmy import TMY3_TESTFILE + from tests.iotools.test_tmy import TMY3_TESTFILE from pvlib.iotools import read_tmy3 data, meta = read_tmy3(TMY3_TESTFILE, map_variables=True) loc = Location.from_tmy(meta, data) @@ -222,7 +222,7 @@ def test_from_tmy_3(): def test_from_tmy_2(): - from pvlib.tests.iotools.test_tmy import TMY2_TESTFILE + from tests.iotools.test_tmy import TMY2_TESTFILE from pvlib.iotools import read_tmy2 data, meta = read_tmy2(TMY2_TESTFILE) loc = Location.from_tmy(meta, data) @@ -233,7 +233,7 @@ def test_from_tmy_2(): def test_from_epw(): - from pvlib.tests.iotools.test_epw import epw_testfile + from tests.iotools.test_epw import epw_testfile from pvlib.iotools import read_epw data, meta = read_epw(epw_testfile) loc = Location.from_epw(meta, data) diff --git a/pvlib/tests/test_modelchain.py b/tests/test_modelchain.py similarity index 99% rename from pvlib/tests/test_modelchain.py rename to tests/test_modelchain.py index dcbd820f16..836fd3c3a0 100644 --- a/pvlib/tests/test_modelchain.py +++ b/tests/test_modelchain.py @@ -7,13 +7,10 @@ from pvlib.modelchain import ModelChain from pvlib.pvsystem import PVSystem from pvlib.location import Location -from pvlib._deprecation import pvlibDeprecationWarning from .conftest import assert_series_equal, assert_frame_equal import pytest -from .conftest import fail_on_pvlib_version - @pytest.fixture(scope='function') def sapm_dc_snl_ac_system(sapm_module_params, cec_inverter_parameters, diff --git a/pvlib/tests/test_numerical_precision.py b/tests/test_numerical_precision.py similarity index 98% rename from pvlib/tests/test_numerical_precision.py rename to tests/test_numerical_precision.py index 53f535401a..9cdf210ab9 100644 --- a/pvlib/tests/test_numerical_precision.py +++ b/tests/test_numerical_precision.py @@ -21,13 +21,13 @@ import pandas as pd from pvlib import pvsystem from pvlib.singlediode import bishop88, estimate_voc -from .conftest import DATA_DIR +from .conftest import TESTS_DATA_DIR logging.basicConfig() LOGGER = logging.getLogger(__name__) LOGGER.setLevel(logging.DEBUG) TEST_DATA = 'bishop88_numerical_precision.csv' -DATA_PATH = DATA_DIR / TEST_DATA +DATA_PATH = TESTS_DATA_DIR / TEST_DATA POA = 888 TCELL = 55 # module parameters from CEC module SunPower SPR-E20-327 diff --git a/pvlib/tests/test_pvarray.py b/tests/test_pvarray.py similarity index 100% rename from pvlib/tests/test_pvarray.py rename to tests/test_pvarray.py diff --git a/pvlib/tests/test_pvsystem.py b/tests/test_pvsystem.py similarity index 99% rename from pvlib/tests/test_pvsystem.py rename to tests/test_pvsystem.py index fd482c5127..9eb5c388a4 100644 --- a/pvlib/tests/test_pvsystem.py +++ b/tests/test_pvsystem.py @@ -20,7 +20,8 @@ from pvlib._deprecation import pvlibDeprecationWarning from pvlib.tools import cosd from pvlib.singlediode import VOLTAGE_BUILTIN -from pvlib.tests.test_singlediode import get_pvsyst_fs_495 + +from tests.test_singlediode import get_pvsyst_fs_495 @pytest.mark.parametrize('iam_model,model_params', [ diff --git a/pvlib/tests/test_scaling.py b/tests/test_scaling.py similarity index 100% rename from pvlib/tests/test_scaling.py rename to tests/test_scaling.py diff --git a/pvlib/tests/test_shading.py b/tests/test_shading.py similarity index 100% rename from pvlib/tests/test_shading.py rename to tests/test_shading.py diff --git a/pvlib/tests/test_singlediode.py b/tests/test_singlediode.py similarity index 98% rename from pvlib/tests/test_singlediode.py rename to tests/test_singlediode.py index 0271e53e90..efded9ff3c 100644 --- a/pvlib/tests/test_singlediode.py +++ b/tests/test_singlediode.py @@ -10,7 +10,7 @@ bishop88, bishop88_i_from_v, bishop88_v_from_i) import pytest from numpy.testing import assert_array_equal -from .conftest import DATA_DIR +from .conftest import TESTS_DATA_DIR POA = 888 TCELL = 55 @@ -128,12 +128,12 @@ def build_precise_iv_curve_dataframe(file_csv, file_json): @pytest.fixture(scope='function', params=[ { - 'csv': f'{DATA_DIR}/precise_iv_curves_parameter_sets1.csv', - 'json': f'{DATA_DIR}/precise_iv_curves1.json' + 'csv': f'{TESTS_DATA_DIR}/precise_iv_curves_parameter_sets1.csv', + 'json': f'{TESTS_DATA_DIR}/precise_iv_curves1.json' }, { - 'csv': f'{DATA_DIR}/precise_iv_curves_parameter_sets2.csv', - 'json': f'{DATA_DIR}/precise_iv_curves2.json' + 'csv': f'{TESTS_DATA_DIR}/precise_iv_curves_parameter_sets2.csv', + 'json': f'{TESTS_DATA_DIR}/precise_iv_curves2.json' } ], ids=[1, 2]) def precise_iv_curves(request): diff --git a/pvlib/tests/test_snow.py b/tests/test_snow.py similarity index 100% rename from pvlib/tests/test_snow.py rename to tests/test_snow.py diff --git a/pvlib/tests/test_soiling.py b/tests/test_soiling.py similarity index 95% rename from pvlib/tests/test_soiling.py rename to tests/test_soiling.py index e774e62963..53acc1c723 100644 --- a/pvlib/tests/test_soiling.py +++ b/tests/test_soiling.py @@ -6,7 +6,7 @@ from .conftest import assert_series_equal from pvlib.soiling import hsu, kimber from pvlib.iotools import read_tmy3 -from .conftest import DATA_DIR +from .conftest import TESTS_DATA_DIR, PVLIB_DATA_DIR import pytest @@ -147,15 +147,16 @@ def test_hsu_variable_time_intervals(rainfall_input, expected_output_3): @pytest.fixture def greensboro_rain(): # get TMY3 data with rain - greensboro, _ = read_tmy3(DATA_DIR / '723170TYA.CSV', coerce_year=1990, - map_variables=True) - return greensboro['Lprecip depth (mm)'] + greensboro, _ = read_tmy3( + PVLIB_DATA_DIR / "723170TYA.CSV", coerce_year=1990, map_variables=True + ) + return greensboro["Lprecip depth (mm)"] @pytest.fixture def expected_kimber_nowash(): return pd.read_csv( - DATA_DIR / 'greensboro_kimber_soil_nowash.dat', + TESTS_DATA_DIR / 'greensboro_kimber_soil_nowash.dat', parse_dates=True, index_col='timestamp') @@ -172,7 +173,7 @@ def test_kimber_nowash(greensboro_rain, expected_kimber_nowash): @pytest.fixture def expected_kimber_manwash(): return pd.read_csv( - DATA_DIR / 'greensboro_kimber_soil_manwash.dat', + TESTS_DATA_DIR / 'greensboro_kimber_soil_manwash.dat', parse_dates=True, index_col='timestamp') diff --git a/pvlib/tests/test_solarposition.py b/tests/test_solarposition.py similarity index 100% rename from pvlib/tests/test_solarposition.py rename to tests/test_solarposition.py diff --git a/pvlib/tests/test_spa.py b/tests/test_spa.py similarity index 100% rename from pvlib/tests/test_spa.py rename to tests/test_spa.py diff --git a/pvlib/tests/test_temperature.py b/tests/test_temperature.py similarity index 99% rename from pvlib/tests/test_temperature.py rename to tests/test_temperature.py index 1cc32a732a..bf72a16e22 100644 --- a/pvlib/tests/test_temperature.py +++ b/tests/test_temperature.py @@ -2,11 +2,10 @@ import numpy as np import pytest -from .conftest import DATA_DIR, assert_series_equal +from .conftest import TESTS_DATA_DIR, assert_series_equal from numpy.testing import assert_allclose from pvlib import temperature, tools -from pvlib._deprecation import pvlibDeprecationWarning import re @@ -196,7 +195,7 @@ def _read_pvwatts_8760(filename): ]) def test_fuentes(filename, inoct): # Test against data exported from pvwatts.nrel.gov - data = _read_pvwatts_8760(DATA_DIR / filename) + data = _read_pvwatts_8760(TESTS_DATA_DIR / filename) data = data.iloc[:24*7, :] # just use one week inputs = { 'poa_global': data['Plane of Array Irradiance (W/m^2)'], diff --git a/pvlib/tests/test_tools.py b/tests/test_tools.py similarity index 100% rename from pvlib/tests/test_tools.py rename to tests/test_tools.py diff --git a/pvlib/tests/test_tracking.py b/tests/test_tracking.py similarity index 99% rename from pvlib/tests/test_tracking.py rename to tests/test_tracking.py index 03536762b5..8f3cb5824d 100644 --- a/pvlib/tests/test_tracking.py +++ b/tests/test_tracking.py @@ -7,8 +7,7 @@ import pvlib from pvlib import tracking -from .conftest import DATA_DIR, assert_frame_equal, assert_series_equal -from pvlib._deprecation import pvlibDeprecationWarning +from .conftest import TESTS_DATA_DIR, assert_frame_equal, assert_series_equal SINGLEAXIS_COL_ORDER = ['tracker_theta', 'aoi', 'surface_azimuth', 'surface_tilt'] @@ -310,7 +309,7 @@ def test_calc_axis_tilt(): # expected values expected_axis_tilt = 2.239 # [degrees] expected_side_slope = 9.86649274360294 # [degrees] - expected = DATA_DIR / 'singleaxis_tracker_wslope.csv' + expected = TESTS_DATA_DIR / 'singleaxis_tracker_wslope.csv' expected = pd.read_csv(expected, index_col='timestamp', parse_dates=True) # solar positions starttime = '2017-01-01T00:30:00-0300' diff --git a/pvlib/tests/test_transformer.py b/tests/test_transformer.py similarity index 100% rename from pvlib/tests/test_transformer.py rename to tests/test_transformer.py