From 20c8f0a856de737d331eddb9c51807d745faa2db Mon Sep 17 00:00:00 2001 From: bnb32 Date: Tue, 3 Jun 2025 05:58:29 -0600 Subject: [PATCH 1/9] bump sphinx version to 8.0.2 in development dependencies --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c674e48c..b6a7fc3a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,7 +43,7 @@ dev = [ "matplotlib>=3.10.0" ] doc = [ - "sphinx>=7.4.7", + "sphinx>=8.0.2", "sphinx_rtd_theme>=3.0.2", "sphinx-click>=5.2.1", ] From 3da71d79f594125a2b3adbd0918b7753007010f0 Mon Sep 17 00:00:00 2001 From: bnb32 Date: Tue, 3 Jun 2025 08:54:53 -0600 Subject: [PATCH 2/9] fix: update deps --- pyproject.toml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index b6a7fc3a..9cc7ba04 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,13 +26,14 @@ classifiers=[ "Programming Language :: Python :: 3.11", ] dependencies = [ - "netCDF4>=1.6,<1.7", - "NREL-gaps>=0.8.0,<0.9", + "NREL-gaps>=0.6.13", "NREL-cloud_fs>=0.0.8", "NREL-farms>=1.0.6", - "scikit-learn>=1.0", "NREL-rest2>=1.0.2", "NREL-mlclouds>=0.0.5", + "netCDF4>=1.5.8,<1.7", + "scikit-learn>=1.0", + "matplotlib>=3.1" ] [project.optional-dependencies] @@ -40,7 +41,6 @@ dev = [ "build>=0.5", "pre-commit", "ruff>=0.5.0", - "matplotlib>=3.10.0" ] doc = [ "sphinx>=8.0.2", From f695567a861e233ca30f744a92fe978c517f676d Mon Sep 17 00:00:00 2001 From: bnb32 Date: Tue, 3 Jun 2025 09:16:56 -0600 Subject: [PATCH 3/9] update deps --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 9cc7ba04..b9f7d010 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,6 +26,7 @@ classifiers=[ "Programming Language :: Python :: 3.11", ] dependencies = [ + "NREL-phygnn>=0.0.32", "NREL-gaps>=0.6.13", "NREL-cloud_fs>=0.0.8", "NREL-farms>=1.0.6", From 451f8594df3bc0699193fc4676830bc726299f7c Mon Sep 17 00:00:00 2001 From: bnb32 Date: Tue, 3 Jun 2025 09:37:58 -0600 Subject: [PATCH 4/9] sphinx tabs causing problems? --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index b9f7d010..aa614a32 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,7 +26,7 @@ classifiers=[ "Programming Language :: Python :: 3.11", ] dependencies = [ - "NREL-phygnn>=0.0.32", + "sphinx-tabs>=3.4.7,<4", "NREL-gaps>=0.6.13", "NREL-cloud_fs>=0.0.8", "NREL-farms>=1.0.6", From 1c7dd33c82b081a6bf97d656e7172d2c9f289d57 Mon Sep 17 00:00:00 2001 From: bnb32 Date: Tue, 3 Jun 2025 09:48:45 -0600 Subject: [PATCH 5/9] update deps --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index aa614a32..f600a182 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,6 +26,7 @@ classifiers=[ "Programming Language :: Python :: 3.11", ] dependencies = [ + "sphinx>=8.0.2", "sphinx-tabs>=3.4.7,<4", "NREL-gaps>=0.6.13", "NREL-cloud_fs>=0.0.8", From 3469da251da809de517fe162f228c4efcdfbdf0b Mon Sep 17 00:00:00 2001 From: bnb32 Date: Tue, 3 Jun 2025 10:08:17 -0600 Subject: [PATCH 6/9] update deps --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index f600a182..220a9254 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,6 +26,7 @@ classifiers=[ "Programming Language :: Python :: 3.11", ] dependencies = [ + "docutils>=0.20", "sphinx>=8.0.2", "sphinx-tabs>=3.4.7,<4", "NREL-gaps>=0.6.13", From 75fa2f74c5e9af799fb3b49e2af1102c8a6d373a Mon Sep 17 00:00:00 2001 From: bnb32 Date: Tue, 3 Jun 2025 11:51:03 -0600 Subject: [PATCH 7/9] sigh --- pyproject.toml | 3 --- 1 file changed, 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 220a9254..9cc7ba04 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,9 +26,6 @@ classifiers=[ "Programming Language :: Python :: 3.11", ] dependencies = [ - "docutils>=0.20", - "sphinx>=8.0.2", - "sphinx-tabs>=3.4.7,<4", "NREL-gaps>=0.6.13", "NREL-cloud_fs>=0.0.8", "NREL-farms>=1.0.6", From c7aa52421a5a7da2c0e6a38323b3c00c27c9affb Mon Sep 17 00:00:00 2001 From: bnb32 Date: Tue, 3 Jun 2025 13:04:07 -0600 Subject: [PATCH 8/9] narrow dep bounds --- pyproject.toml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 9cc7ba04..6a98a12b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,7 +26,9 @@ classifiers=[ "Programming Language :: Python :: 3.11", ] dependencies = [ - "NREL-gaps>=0.6.13", + "sphinx-tabs>=3.4.5,<3.4.6", + "sphinx>=8.0.2,<8.1.0", + "NREL-gaps>=0.6.14,<0.8.0", "NREL-cloud_fs>=0.0.8", "NREL-farms>=1.0.6", "NREL-rest2>=1.0.2", @@ -172,4 +174,4 @@ include-package-data = true packages = ["nsrdb"] [tool.setuptools_scm] -version_file = "nsrdb/_version.py" \ No newline at end of file +version_file = "nsrdb/_version.py" From 087b6f7c073a13959e6cbdb089cebaf86698b6c5 Mon Sep 17 00:00:00 2001 From: bnb32 Date: Tue, 3 Jun 2025 13:52:48 -0600 Subject: [PATCH 9/9] test fix: latest version of pytest doesn't like returns in test functions. --- tests/gap_fill/test_gap_fill.py | 145 ++++++++++++++++++-------------- tests/test_nearest_neighbor.py | 61 +++++--------- 2 files changed, 105 insertions(+), 101 deletions(-) diff --git a/tests/gap_fill/test_gap_fill.py b/tests/gap_fill/test_gap_fill.py index bbc7c9c3..b2b08396 100755 --- a/tests/gap_fill/test_gap_fill.py +++ b/tests/gap_fill/test_gap_fill.py @@ -5,6 +5,7 @@ @author: gbuster """ + from copy import deepcopy import numpy as np @@ -12,81 +13,99 @@ from nsrdb.gap_fill.cloud_fill import CloudGapFill from nsrdb.utilities.pytest import execute_pytest -CLOUD_TYPE = np.array([[0, 0, -128, 0, 0, 7], - [1, 1, -15, 0, 0, 7], - [7, 3, -15, 0, 0, 0], - [7, -15, -15, 0, 1, 0], - [3, 8, -15, 5, 1, 7], - [3, 8, -15, 5, 1, 7], - [7, 3, -15, -15, 4, -15], - [7, 3, -15, 5, 4, 7], - ]) - -CLD_OPD_DCOMP = np.array([[0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0], - [71, 43, 0, 0, 0, 0], - [73, 45, 0, 0, 0, 41], - [17, 29, 0, 0, 0, 0], - [14, 21, 0, 0, 0, 0], - ], dtype=np.int32) - -SZA = np.array([[0, 0, 0, 0, 0, 180], - [0, 0, 0, 0, 0, 180], - [0, 0, 0, 0, 180, 180], - [0, 0, 0, 0, 180, 180], - [0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 180, 0], - [180, 0, 0, 180, 180, 0], - ]) - -OUT_CTYPE = np.array([[0, 0, 0, 0, 0, 7], - [1, 1, 0, 0, 0, 7], - [7, 3, 0, 0, 0, 0], - [7, 3, 0, 0, 1, 0], - [3, 8, 0, 5, 1, 7], - [3, 8, 0, 5, 1, 7], - [7, 3, 0, 5, 4, 7], - [7, 3, 0, 5, 4, 7]], dtype=np.int8) - -OUT_PROP = np.array([[0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0], - [17, 29, 0, 0, 0, 0], - [17, 29, 0, 0, 0, 0], - [71, 43, 0, 10, 0, 41], - [73, 45, 0, 10, 0, 41], - [17, 29, 0, 10, 0, 41], - [0, 21, 0, 0, 0, 41]], dtype=np.int32) - -OUT_FILL_FLAG = np.array([[0, 0, 2, 0, 0, 0], - [0, 0, 2, 0, 0, 0], - [3, 3, 2, 0, 0, 0], - [3, 1, 2, 0, 0, 0], - [0, 0, 2, 4, 0, 3], - [0, 0, 2, 4, 0, 0], - [0, 0, 2, 1, 0, 1], - [0, 0, 2, 0, 0, 3]], dtype=np.int8) +CLOUD_TYPE = np.array([ + [0, 0, -128, 0, 0, 7], + [1, 1, -15, 0, 0, 7], + [7, 3, -15, 0, 0, 0], + [7, -15, -15, 0, 1, 0], + [3, 8, -15, 5, 1, 7], + [3, 8, -15, 5, 1, 7], + [7, 3, -15, -15, 4, -15], + [7, 3, -15, 5, 4, 7], +]) + +CLD_OPD_DCOMP = np.array( + [ + [0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0], + [71, 43, 0, 0, 0, 0], + [73, 45, 0, 0, 0, 41], + [17, 29, 0, 0, 0, 0], + [14, 21, 0, 0, 0, 0], + ], + dtype=np.int32, +) + +SZA = np.array([ + [0, 0, 0, 0, 0, 180], + [0, 0, 0, 0, 0, 180], + [0, 0, 0, 0, 180, 180], + [0, 0, 0, 0, 180, 180], + [0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 180, 0], + [180, 0, 0, 180, 180, 0], +]) + +OUT_CTYPE = np.array( + [ + [0, 0, 0, 0, 0, 7], + [1, 1, 0, 0, 0, 7], + [7, 3, 0, 0, 0, 0], + [7, 3, 0, 0, 1, 0], + [3, 8, 0, 5, 1, 7], + [3, 8, 0, 5, 1, 7], + [7, 3, 0, 5, 4, 7], + [7, 3, 0, 5, 4, 7], + ], + dtype=np.int8, +) + +OUT_PROP = np.array( + [ + [0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0], + [17, 29, 0, 0, 0, 0], + [17, 29, 0, 0, 0, 0], + [71, 43, 0, 10, 0, 41], + [73, 45, 0, 10, 0, 41], + [17, 29, 0, 10, 0, 41], + [0, 21, 0, 0, 0, 41], + ], + dtype=np.int32, +) + +OUT_FILL_FLAG = np.array( + [ + [0, 0, 2, 0, 0, 0], + [0, 0, 2, 0, 0, 0], + [3, 3, 2, 0, 0, 0], + [3, 1, 2, 0, 0, 0], + [0, 0, 2, 4, 0, 3], + [0, 0, 2, 4, 0, 0], + [0, 0, 2, 1, 0, 1], + [0, 0, 2, 0, 0, 3], + ], + dtype=np.int8, +) def test_type(): """Test the cloud property gap fill algorithm.""" - cloud_type, fill_flag = CloudGapFill.fill_cloud_type(deepcopy(CLOUD_TYPE)) + cloud_type, _ = CloudGapFill.fill_cloud_type(deepcopy(CLOUD_TYPE)) assert np.array_equal(cloud_type, OUT_CTYPE) - return cloud_type, fill_flag def test_opd(): """Test the cloud property gap fill algorithm.""" _, fill_flag = CloudGapFill.fill_cloud_type(deepcopy(CLOUD_TYPE)) - cloud_prop, fill_flag = CloudGapFill.fill_cloud_prop('cld_opd_dcomp', - CLD_OPD_DCOMP, - CLOUD_TYPE, SZA, - fill_flag=fill_flag) + cloud_prop, fill_flag = CloudGapFill.fill_cloud_prop( + 'cld_opd_dcomp', CLD_OPD_DCOMP, CLOUD_TYPE, SZA, fill_flag=fill_flag + ) assert np.array_equal(cloud_prop, OUT_PROP) assert np.array_equal(fill_flag, OUT_FILL_FLAG) - return cloud_prop, fill_flag if __name__ == '__main__': diff --git a/tests/test_nearest_neighbor.py b/tests/test_nearest_neighbor.py index 69e3587a..2568f31a 100755 --- a/tests/test_nearest_neighbor.py +++ b/tests/test_nearest_neighbor.py @@ -6,7 +6,6 @@ @author: gbuster """ - import numpy as np import pandas as pd @@ -21,38 +20,27 @@ lat_mesh = lat_mesh.flatten() source_meta = pd.DataFrame({'latitude': lat_mesh, 'longitude': lon_mesh}) -nsrdb_meta = pd.DataFrame( - {'latitude': [1.1, 12.8, 23.3, 43.4, 44.2], - 'longitude': [-120.4, -112.3, -101.1, -91.3, -88.4]}) - -baseline4 = np.array([[[1, -120], - [1, -121], - [2, -120], - [2, -121]], - [[13, -112], - [13, -113], - [12, -112], - [12, -113]], - [[23, -101], - [24, -101], - [23, -102], - [23, -100]], - [[43, -91], - [44, -91], - [43, -92], - [44, -92]], - [[44, -88], - [44, -89], - [45, -88], - [45, -89]]]) +nsrdb_meta = pd.DataFrame({ + 'latitude': [1.1, 12.8, 23.3, 43.4, 44.2], + 'longitude': [-120.4, -112.3, -101.1, -91.3, -88.4], +}) + +baseline4 = np.array([ + [[1, -120], [1, -121], [2, -120], [2, -121]], + [[13, -112], [13, -113], [12, -112], [12, -113]], + [[23, -101], [24, -101], [23, -102], [23, -100]], + [[43, -91], [44, -91], [43, -92], [44, -92]], + [[44, -88], [44, -89], [45, -88], [45, -89]], +]) # calculated using Vincenty: https://www.cqsrg.org/tools/GCDistance/ -baseline_dist = np.array([45.873, - 39.365, - 34.766, - 50.688, - 38.983, - ]) +baseline_dist = np.array([ + 45.873, + 39.365, + 34.766, + 50.688, + 38.983, +]) def test_geo_haversine_nn(): @@ -63,20 +51,19 @@ def test_geo_haversine_nn(): result = np.allclose(baseline4, coords_closest) msg = 'Haversine NN failed!' assert result, msg - return coords_closest def test_geo_haversine_dist(): """Test the geographic haversine nearest neighbor.""" - dist, ind = geo_nn(source_meta, nsrdb_meta, k=1) + dist, _ = geo_nn(source_meta, nsrdb_meta, k=1) dist = dist.flatten() result = np.allclose(baseline_dist, dist, rtol=0.01, atol=0.0) diff = np.abs(baseline_dist - dist) - msg = ('Haversine distance failed! ' - '\nDist: \n{}\nDiff:\n{}'.format(dist, diff)) + msg = 'Haversine distance failed! ' '\nDist: \n{}\nDiff:\n{}'.format( + dist, diff + ) assert result, msg - return dist def test_knn(): @@ -87,7 +74,6 @@ def test_knn(): result = np.allclose(baseline4, coords_closest) msg = 'KNN failed!' assert result, msg - return coords_closest def test_regular_grid_nn(): @@ -98,7 +84,6 @@ def test_regular_grid_nn(): coords_closest_knn = source_meta.values[ind] msg = 'Regular grid NN failed!' assert np.allclose(coords_closest_knn, coords_closest_reg), msg - return coords_closest_reg if __name__ == '__main__':