Skip to content

Commit

Permalink
add test for h5ad metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
nilchia committed Aug 7, 2024
1 parent c51d565 commit 51f986d
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions test/unit/data/datatypes/test_h5ad_metadata.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# type: ignore
from galaxy.datatypes.binary import (
Anndata
)
from .util import (
get_input_files,
MockDataset,
)

# Tests for h5ad_metadata:


def test_h5ad_sniff():
with get_input_files("anndata.h5ad") as input_files:
assert Anndata.sniff(input_files[0]) is True


def test_h5ad_set_meta():
with get_input_files("anndata.h5ad") as input_files:
dataset = MockDataset(1)
dataset.set_file_name(input_files[0])

Anndata.set_meta(dataset)

assert dataset.metadata.layers_count == "9"
assert dataset.metadata.layers_names == "['X', 'layers', 'obs', 'obsm', 'obsp', 'uns', 'var', 'varm', 'varp']"

assert Anndata.set_meta._layercountsize(dataset) == "['X', 'layers', 'obs', 'obsm', 'obsp', 'uns', 'var', 'varm', 'varp'], 9, 0"



def test_h5ad_set_peek():
with get_input_files("anndata.h5ad") as input_files:
dataset = MockDataset(1)
dataset.set_file_name(input_files[0])
assert Anndata.display_peek(dataset) == "Peek unavailable"

Anndata.set_meta(dataset)
Anndata.set_peek(dataset)

assert (
dataset.peek
== """
[n_obs x n_vars]
640 x 11
[obs]: 2 layers
blobs, index
[var]: 1 layer
index
[obsm]: 0 layer
[varm]: 0 layer
[uns]: 0 layer
"""
)

0 comments on commit 51f986d

Please sign in to comment.