Skip to content

Update for h5ad reader#147

Merged
parashardhapola merged 6 commits into
NygenAnalytics:masterfrom
suu-yi:h5ad-patch-cat-codes
Nov 19, 2025
Merged

Update for h5ad reader#147
parashardhapola merged 6 commits into
NygenAnalytics:masterfrom
suu-yi:h5ad-patch-cat-codes

Conversation

@suu-yi

@suu-yi suu-yi commented Nov 19, 2025

Copy link
Copy Markdown
Contributor

Issue: Categorical feature names in H5AD files caused TypeError
Fix:

  • Removed [:] slice - pass object as-is to handler
  • Added categorical Group decoder in _replace_category_values():
  • Check if h5py.Group with codes/categories
  • Decode: categories[codes] → feature names
  • Handle Datasets normally

Result: H5AD files with categorical data now load

Comment thread scarf/readers.py Outdated
@@ -782,6 +782,25 @@ def feat_names(self) -> np.ndarray:
return self.feat_ids()

def _replace_category_values(self, v: np.ndarray, key: str, group: str):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we need to update this signature, as now we expect v to not just be np.ndarray

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

noted. fix made in new commits

Comment thread scarf/readers.py Outdated
values = self.h5[self.featureAttrsKey][self.featNamesKey]
else:
values = self.h5[self.featureAttrsKey][self.featNamesKey][:]
values = self.h5[self.featureAttrsKey][self.featNamesKey]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this is change because now you are feeddng values into _replace_category_values?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

looking at the return, i think values was always passed.
i've cleaned out the if else now

@parashardhapola parashardhapola merged commit a4b9d1a into NygenAnalytics:master Nov 19, 2025
1 of 3 checks passed
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.

2 participants