From a296872251d95763e561aac8b1cfb02fcd3cd4e3 Mon Sep 17 00:00:00 2001 From: ram-from-tvl Date: Tue, 2 Sep 2025 16:57:15 +0530 Subject: [PATCH] finished the renaming --- .../internal/entities/tensorstore.py | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/nwp_consumer/internal/entities/tensorstore.py b/src/nwp_consumer/internal/entities/tensorstore.py index 6a99abb7..c60f0fb3 100644 --- a/src/nwp_consumer/internal/entities/tensorstore.py +++ b/src/nwp_consumer/internal/entities/tensorstore.py @@ -44,8 +44,8 @@ class ParameterScanResult: This is determined according to the parameter's limits and threshold. See `entities.parameters.Parameter`. """ - has_nulls: bool - """Whether the parameter's data contains null values.""" + has_nans: bool + """Whether the parameter's data contains nan values.""" @dataclasses.dataclass(slots=True) @@ -333,15 +333,15 @@ def _has_nans(store_da: xr.DataArray) -> ResultE[bool]: nans_in_image_threshold: float = 0.05 images_failing_nan_check_threshold: float = 0.02 - def _calc_null_percentage(data: np.typing.NDArray[np.float32]) -> float: - nulls = np.isnan(data) + def _calc_nan_percentage(data: np.typing.NDArray[np.float32]) -> float: + nans = np.isnan(data) if 0 in data.shape: log.warning( "Validation region has 0 area, check input slices correspond" "to coordinate values in the dataset", ) return 1.0 - return float(nulls.sum() / np.prod(nulls.shape)) + return float(nans.sum() / np.prod(nans.shape)) if "latitude" in store_da.dims: spatial_dims: list[str] = ["latitude", "longitude"] @@ -359,7 +359,7 @@ def _calc_null_percentage(data: np.typing.NDArray[np.float32]) -> float: ) result = xr.apply_ufunc( - _calc_null_percentage, + _calc_nan_percentage, store_da, input_core_dims=[spatial_dims], vectorize=True, @@ -373,14 +373,14 @@ def _calc_null_percentage(data: np.typing.NDArray[np.float32]) -> float: log.warning( f"Dataset failed validation. " f"{failed_image_percentage:.2%} of images have greater than " - f"{int(nans_in_image_threshold * 100)}% null values" + f"{int(nans_in_image_threshold * 100)}% nan values" f"({failed_image_count}/{total_image_count})", ) return Success(True) log.info( f"{failed_image_count}/{total_image_count} " f"({failed_image_percentage:.2%}) of images have greater than " - f"{int(nans_in_image_threshold * 100)}% null values", + f"{int(nans_in_image_threshold * 100)}% nan values", ) return Success(False) @@ -431,7 +431,7 @@ def validate_store(self) -> ResultE[None]: return Failure(e) case Success(scan): log.debug(f"Scanned parameter {param.name}: {scan.__repr__()}") - if not scan.is_valid or scan.has_nulls: + if not scan.is_valid or scan.has_nans: return Failure(ValueError("Parameter validation failed.")) """ @@ -507,7 +507,7 @@ def scan_parameter_values(self, p: Parameter) -> ResultE[ParameterScanResult]: ParameterScanResult( mean=mean, is_valid=True, - has_nulls=False, + has_nans=False, ), )