Skip to content

Commit

Permalink
Adding better error messages, as well as changes to make newer versio…
Browse files Browse the repository at this point in the history
…n of mypy happy
  • Loading branch information
bryan-harter committed Jan 20, 2025
1 parent b2cdea0 commit ccf18f1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions cdflib/epochs.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ def breakdown_tt2000(tt2000: cdf_tt2000_type) -> np.ndarray:
tmpy = tmpy - 1
epoch = tmpy + CDFepoch.J2000Since0AD12hSec
# One more determination
xdate = CDFepoch._EPOCHbreakdownTT2000(epoch)
xdate = CDFepoch._EPOCHbreakdownTT2000(epoch).astype(np.float64).ravel()
nansecs[x] = nansec
toutcs[:6, x] = xdate[:6]

Expand Down Expand Up @@ -814,7 +814,7 @@ def _LoadLeapNanoSecondsTable() -> None:
)

@staticmethod
def _EPOCHbreakdownTT2000(epoch: npt.ArrayLike) -> npt.NDArray:
def _EPOCHbreakdownTT2000(epoch: npt.ArrayLike) -> npt.NDArray[np.int64]:
epoch = np.atleast_1d(epoch)

minute_AD, second_AD = np.divmod(epoch, 60)
Expand All @@ -835,7 +835,7 @@ def _EPOCHbreakdownTT2000(epoch: npt.ArrayLike) -> npt.NDArray:
j = j + 2 - 12 * l
i = 100 * (n - 49) + i + l

date = np.array([i, j, k, hour_AD, minute_AD, second_AD])
date = np.array([i, j, k, hour_AD, minute_AD, second_AD], dtype=np.int64)
return date

@staticmethod
Expand Down
4 changes: 2 additions & 2 deletions cdflib/xarray/xarray_to_cdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def _verify_depend_dimensions(
if dataset[primary_variable_name].attrs["VAR_TYPE"] == "data":
# Data variables should always have as many dimensions as their are DEPENDS
_warn_or_except(
f"ISTP Compliance Warning: {coordinate_variable_name} is listed as the DEPEND_{dimension_number} for variable {primary_variable_name}, but {primary_variable_name} does not have that many dimensions",
f"ISTP Compliance Warning: {coordinate_variable_name} is listed as the DEPEND_{dimension_number} for variable {primary_variable_name}, but {primary_variable_name} does not have that many dimensions. Variables with attribute VAR_TYPE=Data should always have the same number of DEPEND attributes and dimensions.",
terminate_on_warning,
)
return False
Expand All @@ -310,7 +310,7 @@ def _verify_depend_dimensions(
if key.lower() == "depend_0":
# support_data variables with a DEPEND_0 should always match the dimension number
_warn_or_except(
f"ISTP Compliance Warning: {coordinate_variable_name} is listed as the DEPEND_{dimension_number} for variable {primary_variable_name}, but {primary_variable_name} does not have that many dimensions",
f"ISTP Compliance Warning: {coordinate_variable_name} is listed as the DEPEND_{dimension_number} for variable {primary_variable_name}, but {primary_variable_name} does not have that many dimensions (DEPEND_0 attribute detected in {primary_variable_name}'s attributes).",
terminate_on_warning,
)
return False
Expand Down

0 comments on commit ccf18f1

Please sign in to comment.