Skip to content

Commit

Permalink
allow for uint (#623)
Browse files Browse the repository at this point in the history
  • Loading branch information
melonora authored Jul 9, 2024
1 parent 95d69ff commit cf7a84d
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/spatialdata/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -853,12 +853,19 @@ def _validate_table_annotation_metadata(self, data: AnnData) -> None:
raise ValueError(f"`{attr[self.REGION_KEY_KEY]}` not found in `adata.obs`. Please create the column.")
if attr[self.INSTANCE_KEY] not in data.obs:
raise ValueError(f"`{attr[self.INSTANCE_KEY]}` not found in `adata.obs`. Please create the column.")
if (dtype := data.obs[attr[self.INSTANCE_KEY]].dtype) not in [int, np.int16, np.int32, np.int64, "O"] or (
dtype == "O" and (val_dtype := type(data.obs[attr[self.INSTANCE_KEY]].iloc[0])) is not str
):
if (dtype := data.obs[attr[self.INSTANCE_KEY]].dtype) not in [
int,
np.int16,
np.uint16,
np.int32,
np.uint32,
np.int64,
np.uint64,
"O",
] or (dtype == "O" and (val_dtype := type(data.obs[attr[self.INSTANCE_KEY]].iloc[0])) is not str):
dtype = dtype if dtype != "O" else val_dtype
raise TypeError(
f"Only int, np.int16, np.int32, np.int64 or string allowed as dtype for "
f"Only int, np.int16, np.int32, np.int64, uint equivalents or string allowed as dtype for "
f"instance_key column in obs. Dtype found to be {dtype}"
)
expected_regions = attr[self.REGION_KEY] if isinstance(attr[self.REGION_KEY], list) else [attr[self.REGION_KEY]]
Expand Down

0 comments on commit cf7a84d

Please sign in to comment.