Skip to content

fix(dtype_converter): coerce unconvertible values to na_value instead… - #112

Open
MocStepan wants to merge 1 commit into
mainfrom
SM-fix-values-conversions
Open

fix(dtype_converter): coerce unconvertible values to na_value instead…#112
MocStepan wants to merge 1 commit into
mainfrom
SM-fix-values-conversions

Conversation

@MocStepan

Copy link
Copy Markdown
Collaborator

… of raising

@MocStepan MocStepan self-assigned this May 25, 2026
@MocStepan
MocStepan requested a review from jbrezmorf as a code owner May 25, 2026 15:07
@MocStepan MocStepan linked an issue May 25, 2026 that may be closed by this pull request

@jbrezmorf jbrezmorf left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Po doporučených úpravách sloučit.

Comment thread zarr_fuse/zarr_schema.py
return to_typed_array(arr, dtype, self._address)
except (ValueError, TypeError):
if self.na_value is None:
raise ValueError(f"Variable '{self.name}' has values not-convertible to type {dtype}.")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More specific error message:
f"Can not convert input vector to variable '{self.name}' with na_value None of type {dtype}.
Input value: {the_value}"

We should report the value for which that failed, since a missing na_value may be intentional.

Comment thread zarr_fuse/zarr_schema.py
def _opt_arg(arg, default):
return default if arg is None else arg

def _to_typed_array(self, values, dtype: Optional[np.dtype]) -> np.ndarray:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this try directly into dtype_converter.to_typed_array, there we should catch just the np.asarray calls. That would be more specific about what is actually caught.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

values conversions

2 participants