Skip to content

Commit f3a0d62

Browse files
committed
Update unit tests to reflect feature change
1 parent 8543154 commit f3a0d62

File tree

4 files changed

+21
-18
lines changed

4 files changed

+21
-18
lines changed

.readthedocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ build:
2525
tools:
2626
python: "3.8"
2727
commands:
28-
# `pip install -e .` or `python setup.py develop` will _not_ let python find the tiledbsc package
28+
# `pip install -e .` or `python setup.py develop` will _not_ let python find the tiledbsoma package
2929
# within sphinx build
3030
#- apt-get install python3-sphinx
3131
- python -m pip install -r doc/requirements_doc.txt

apis/python/tests/test_ascii_and_unicode.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import anndata as ad
22
import numpy as np
33
import pandas as pd
4+
import pytest
45

56
import tiledbsoma.io as io
67
from tiledbsoma import SOMA
78

89

10+
# TODO: restore once https://github.com/single-cell-data/TileDB-SingleCell/issues/274 is in place.
11+
@pytest.mark.skip(reason="Unicode attributes temporarily unsupported")
912
def test_readback(tmp_path):
1013
"""
1114
Validate correct encode/decode of non-ASCII attribute text.

apis/python/tests/test_dim_select.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def test_dim_select(adata):
140140
"VDAC3",
141141
]
142142

143-
df = soma.obs.dim_select([b"AAGCGACTTTGACG", b"AATGCGTGGACGGA"])
143+
df = soma.obs.dim_select(["AAGCGACTTTGACG", "AATGCGTGGACGGA"])
144144
assert df.shape == (2, 7)
145145
assert df.at["AAGCGACTTTGACG", "groups"] == "g1"
146146
assert df.at["AATGCGTGGACGGA", "nFeature_RNA"] == 73
@@ -150,23 +150,23 @@ def test_dim_select(adata):
150150
# AATGCGTGGACGGA 0 389.0 73 1 1 g1 1
151151
assert soma.obs.dim_select(None).shape == (80, 7)
152152

153-
df = soma.var.dim_select([b"AKR1C3", b"MYL9"])
153+
df = soma.var.dim_select(["AKR1C3", "MYL9"])
154154
assert df.shape == (2, 5)
155155
assert df.at["AKR1C3", "vst.variable"] == 1
156156
assert df.at["MYL9", "vst.variable"] == 1
157157
assert soma.var.dim_select(None).shape == (20, 5)
158158

159159
assert sorted(soma.obsm.keys()) == sorted(["X_tsne", "X_pca"])
160160

161-
df = soma.obsm["X_tsne"].dim_select([b"AAGCGACTTTGACG", b"AATGCGTGGACGGA"])
161+
df = soma.obsm["X_tsne"].dim_select(["AAGCGACTTTGACG", "AATGCGTGGACGGA"])
162162
assert df.shape == (2, 2)
163163

164-
df = soma.obsm["X_pca"].dim_select([b"AAGCGACTTTGACG", b"AATGCGTGGACGGA"])
164+
df = soma.obsm["X_pca"].dim_select(["AAGCGACTTTGACG", "AATGCGTGGACGGA"])
165165
assert df.shape == (2, 19)
166166

167-
assert soma.X["data"].dim_select([b"AAGCGACTTTGACG"], [b"AKR1C3"]).shape == (1, 1)
168-
assert soma.X["data"].dim_select(None, [b"AKR1C3"]).shape == (80, 1)
169-
assert soma.X["data"].dim_select([b"AAGCGACTTTGACG"], None).shape == (20, 1)
167+
assert soma.X["data"].dim_select(["AAGCGACTTTGACG"], ["AKR1C3"]).shape == (1, 1)
168+
assert soma.X["data"].dim_select(None, ["AKR1C3"]).shape == (80, 1)
169+
assert soma.X["data"].dim_select(["AAGCGACTTTGACG"], None).shape == (20, 1)
170170
assert soma.X["data"].dim_select(None, None).shape == (1600, 1)
171171

172172
tempdir.cleanup()
@@ -211,7 +211,8 @@ def test_zeroes_handling():
211211
n_obs = len(obs_ids)
212212
n_var = len(var_ids)
213213

214-
cell_types = ["blööd" if obs_id[1] == "A" else "lung" for obs_id in obs_ids]
214+
# TODO: restore once https://github.com/single-cell-data/TileDB-SingleCell/issues/274 is in place.
215+
cell_types = ["blood" if obs_id[1] == "A" else "lung" for obs_id in obs_ids]
215216
feature_names = [
216217
"ENSG00000999999" if var_id[1] < "M" else "ENSG00000123456"
217218
for var_id in var_ids

apis/python/tests/test_type_diversity.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,10 @@ def test_from_anndata_DataFrame_type(tmp_path):
108108
df_col_type_sweep = [
109109
("bool", lambda a: a.astype(bool)),
110110
("str", lambda a: a.astype(str)),
111-
("bytes", lambda a: a.astype(str).astype(bytes)),
112-
# ("float16", lambda a: a.astype(np.dtype("float16"))), TODO: Enable when #39 is fixed
111+
# TODO: restore once #274 is in place.
112+
# ("bytes", lambda a: a.astype(str).astype(bytes)),
113+
# TODO: Enable when #39 is fixed
114+
# ("float16", lambda a: a.astype(np.dtype("float16"))),
113115
("float32", lambda a: a.astype("float32")),
114116
("float64", lambda a: a.astype("float64")),
115117
("int8", lambda a: a.astype("int8")),
@@ -147,9 +149,7 @@ def test_from_anndata_DataFrame_type(tmp_path):
147149
),
148150
),
149151
]
150-
index = (
151-
np.arange(1, n + 1).astype(str).astype(bytes)
152-
) # AnnData requires string indices, TileDB wants bytes. Use LCD
152+
index = np.arange(1, n + 1).astype(str).astype(str)
153153
df = pd.DataFrame(
154154
data={
155155
f"col_{name}": cast(pd.Series(index=index, data=np.arange(n)))
@@ -176,7 +176,7 @@ def cmp_dtype(series, tdb: tiledb.Attr) -> bool:
176176
# TODO: see annotation_dataframe.py. Once Unicode attributes are queryable, we'll need
177177
# to remove this check which is verifying the current force-to-ASCII workaround.
178178
if ad_dtype.name == "str":
179-
ad_dtype = np.dtype("S")
179+
ad_dtype = np.dtype("U")
180180

181181
return ad_dtype == tdb.dtype
182182

@@ -212,9 +212,8 @@ def test_from_anndata_annotations_empty(tmp_path):
212212
n_obs = 100
213213
n_var = 10
214214

215-
# AnnData requires a string index. TileDB does not support UTF8, so use ASCII.
216-
obs = pd.DataFrame(index=np.arange(n_obs).astype(bytes))
217-
var = pd.DataFrame(index=np.arange(n_var).astype(bytes))
215+
obs = pd.DataFrame(index=np.arange(n_obs).astype(str))
216+
var = pd.DataFrame(index=np.arange(n_var).astype(str))
218217

219218
X = np.ones((n_obs, n_var))
220219
adata = ad.AnnData(X=X, obs=obs, var=var, dtype=X.dtype)

0 commit comments

Comments
 (0)