From 87316456e9017bf49465371ff8fd106ebaebd9eb Mon Sep 17 00:00:00 2001 From: Simon Liu <69875423+sliu008@users.noreply.github.com> Date: Wed, 11 Dec 2024 13:34:14 -0800 Subject: [PATCH] update test to test that lon lat have some valid data (#3358) --- tests/verify_collection.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/verify_collection.py b/tests/verify_collection.py index d9a8e9ff42..3ae707655f 100644 --- a/tests/verify_collection.py +++ b/tests/verify_collection.py @@ -535,11 +535,13 @@ def test_spatial_subset(collection_concept_id, env, granule_json, collection_var lat_var_fill_value = subsetted_ds_new[lat_var_name].encoding.get('_FillValue') lon_var_fill_value = subsetted_ds_new[lon_var_name].encoding.get('_FillValue') + partial_pass = False if lat_var_fill_value: if (lat_max <= north or np.isclose(lat_max, north)) and (lat_min >= south or np.isclose(lat_min, south)): logging.info("Successful Latitude subsetting") elif np.isnan(lat_max) and np.isnan(lat_min): logging.info("Partial Lat Success - no Data") + partial_pass = True else: assert False @@ -548,9 +550,17 @@ def test_spatial_subset(collection_concept_id, env, granule_json, collection_var logging.info("Successful Longitude subsetting") elif np.isnan(lon_max) and np.isnan(lon_min): logging.info("Partial Lon Success - no Data") + partial_pass = True else: assert False + if partial_pass: + valid_lon = np.isfinite(llon) & (llon != lon_var_fill_value) + valid_lat = np.isfinite(llat) & (llat != lat_var_fill_value) + + if not np.any(valid_lon) or not np.any(valid_lat): + pytest.fail("No data in lon and lat") + @pytest.mark.timeout(600) def test_temporal_subset(collection_concept_id, env, granule_json, collection_variables, harmony_env, tmp_path: pathlib.Path, bearer_token, skip_temporal):