Skip to content

Commit

Permalink
Fix reporting (#914)
Browse files Browse the repository at this point in the history
* fix extract component

* add to par

* fix par

* add more checks

* simplify

* use pd function

* fix function

* fix function

* update changelog
  • Loading branch information
rcannood authored Nov 8, 2024
1 parent a8f4e9d commit f0ee7b7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@

- Update `dataset_id` for `tenx_visium`, `zenodo_spatial`, `zenodo_spatial_slidetags` datasets and use `mouse_brain_coronal` as a test resource in the `spatially_variable_genes` task (PR #908).

## Bug fixes

- Fix extracting metadata from anndata files in the `extract_metadata` component (PR #914).

# openproblems v2.0.0

A major update to the OpenProblems framework, switching from a Python-based framework to a Viash + Nextflow-based framework. This update features the same concepts as the previous version, but with a new implementation that is more flexible, scalable, and maintainable.
Expand Down
11 changes: 6 additions & 5 deletions src/utils/extract_uns_metadata/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
'input': 'resources_test/common/pancreas/dataset.h5ad',
'schema': 'src/datasets/api/file_raw.yaml',
'output': 'output/meta.yaml',
'uns_length_cutoff': 100
}
## VIASH END

Expand All @@ -36,21 +37,21 @@
## Helper functions for extracting the dataset metadata in uns ##
####################################################################################################
def is_atomic(obj):
return isinstance(obj, str) or isinstance(obj, int) or isinstance(obj, bool) or isinstance(obj, float)
return pd.api.types.is_scalar(obj)

def to_atomic(obj):
if isinstance(obj, np.float64):
return float(obj)
elif isinstance(obj, np.int64):
if isinstance(obj, (np.int32,np.int64)):
return int(obj)
elif isinstance(obj, (np.float32,np.float64)):
return float(obj)
elif isinstance(obj, np.bool_):
return bool(obj)
elif isinstance(obj, np.str_):
return str(obj)
return obj

def is_list_of_atomics(obj):
if not isinstance(obj, (list,pd.core.series.Series,np.ndarray)):
if not isinstance(obj, (list, pd.core.series.Series, np.ndarray)):
return False
return all(is_atomic(elem) for elem in obj)

Expand Down

0 comments on commit f0ee7b7

Please sign in to comment.