Skip to content

Commit

Permalink
fix tests to check list of cells and not individual cell embeddings s…
Browse files Browse the repository at this point in the history
…ince some are expected to be empty.
  • Loading branch information
amva13 committed Oct 23, 2024
1 parent 0a95547 commit 766dd7a
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions tdc/test/test_model_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,26 +88,23 @@ def testGeneformerTokenizer(self):
obs_value_filter = "sex == 'female' and cell_type in ['microglial cell', 'neuron']",
column_names = {"obs": ["assay", "cell_type", "tissue", "tissue_general", "suspension_type", "disease"]},
)
# adata.obs["ncounts"] = [2] * len(adata.obs)
# raise Exception("obs", adata.obs.columns, "var", adata.var.columns)
print("initializing tokenizer")
tokenizer = GeneformerTokenizer()
print("testing tokenizer")
x = tokenizer.tokenize_cell_vectors(adata, ensembl_id="feature_id", ncounts="n_measured_vars")
assert x[0]

# test Geneformer can serve the request
cells = x[0]
assert cells[0]
assert len(cells[0]) > 0
cells = x[0],
assert cells, "FAILURE: cells false-like. Value is = {}".format(cells)
assert len(cells) > 0, "FAILURE: length of cells <= 0 {}".format(cells)
from tdc import tdc_hf_interface
import torch
geneformer = tdc_hf_interface("Geneformer")
model = geneformer.load()
out = model(torch.tensor(cells).int())
assert out
assert out[0]
assert len(out[0]) > 0
assert out, "FAILURE: Geneformer output is false-like. Value = {}".format(out)
assert len(out) == len(cells), "FAILURE: Geneformer output and cells input don't have the same length. {} vs {}".format(len(out), len(cells))

def tearDown(self):
try:
Expand Down

0 comments on commit 766dd7a

Please sign in to comment.