From d6710a64f90d41da50b8fa8236f82e5a922519af Mon Sep 17 00:00:00 2001 From: danielfromearth Date: Thu, 2 Jan 2025 16:56:45 -0500 Subject: [PATCH] fix None type check and assert number --- ncompare/getters.py | 10 +++++++--- tests/test_core.py | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ncompare/getters.py b/ncompare/getters.py index 090deff..58309e2 100644 --- a/ncompare/getters.py +++ b/ncompare/getters.py @@ -78,13 +78,17 @@ def get_subgroups(node: Union[netCDF4.Dataset, netCDF4.Group, h5py.Group], file_ Returns ------- - list + list or None subgroups under the node """ - if file_type == "hdf5": + if node is None: + return [] + elif file_type == "hdf5": return [key for key in node.keys() if isinstance(node[key], h5py.Group)] - else: # should be "netcdf" + elif file_type == "netcdf": # should be "netcdf" return list(node.groups) + else: + return [] def get_variables(node: Union[netCDF4.Dataset, netCDF4.Group, h5py.Group], file_type: str) -> list: diff --git a/tests/test_core.py b/tests/test_core.py index 2b2c95f..da2d0a3 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -84,4 +84,4 @@ def test_icesat(temp_data_dir): file_text=str(out_path), ) - assert num_differences == 4982 + assert num_differences == 5280