We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f3acdcd commit af75ae2Copy full SHA for af75ae2
tests/test_readers.py
@@ -290,3 +290,27 @@ def test_get_nan_coordinates():
290
dataset1 = xr.Dataset.from_dataframe(df1.set_index(["region", "year"]))
291
nan_coords1 = get_nan_coordinates(dataset1)
292
assert nan_coords1 == [("R1", 2021)]
293
+
294
+ # Test 2: Missing coordinate combinations
295
+ df2 = pd.DataFrame(
296
+ {
297
+ "region": ["R1", "R1", "R2"], # Missing R2-2021
298
+ "year": [2020, 2021, 2020],
299
+ "value": [1.0, 2.0, 3.0],
300
+ }
301
+ )
302
+ dataset2 = xr.Dataset.from_dataframe(df2.set_index(["region", "year"]))
303
+ nan_coords2 = get_nan_coordinates(dataset2)
304
+ assert nan_coords2 == [("R2", 2021)]
305
306
+ # Test 3: No NaN values
307
+ df3 = pd.DataFrame(
308
309
+ "region": ["R1", "R1", "R2", "R2"],
310
+ "year": [2020, 2021, 2020, 2021],
311
+ "value": [1.0, 2.0, 3.0, 4.0],
312
313
314
+ dataset3 = xr.Dataset.from_dataframe(df3.set_index(["region", "year"]))
315
+ nan_coords3 = get_nan_coordinates(dataset3)
316
+ assert nan_coords3 == []
0 commit comments