Skip to content

Commit 91ed068

Browse files
authored
Merge pull request #88 from YosefLab/release_hub
Python 3.11 changes.
2 parents d87d799 + d4fbdbe commit 91ed068

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

popv/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
if sys.version_info[:2] != (3, 10):
77
warnings.warn(
88
"Pretrained models on huggingface are trained with Python 3.11. "
9-
f"Detected Python {sys.version.split()[0]} will not load these models.",
9+
"Detected Python {sys.version.split()[:2]} will not load these models.",
1010
UserWarning,
1111
stacklevel=3,
1212
)

popv/algorithms/_svm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,14 @@ def predict(self, adata):
7676
if adata.uns["_prediction_mode"] == "retrain":
7777
train_idx = adata.obs["_ref_subsample"]
7878
train_x = adata[train_idx].layers[self.layer_key] if self.layer_key else adata[train_idx].X
79+
train_x = np.array(train_x.todense())
7980
train_y = adata.obs.loc[train_idx, self.labels_key].cat.codes.to_numpy()
8081
if settings.cuml:
8182
from cuml.svm import LinearSVC
8283
from sklearn.multiclass import OneVsRestClassifier
8384

8485
self.classifier_dict["probability"] = self.return_probabilities
8586
clf = OneVsRestClassifier(LinearSVC(**self.classifier_dict))
86-
train_x = train_x.todense()
8787
clf.fit(train_x, train_y)
8888
joblib.dump(
8989
clf,
@@ -131,7 +131,7 @@ def predict(self, adata):
131131
for i in range(0, adata.n_obs, shard_size):
132132
tmp_x = test_x[i : i + shard_size]
133133
names_x = adata.obs_names[i : i + shard_size]
134-
tmp_x = tmp_x.todense()
134+
tmp_x = np.array(tmp_x.todense())
135135
result_df.loc[names_x, self.result_key] = adata.uns["label_categories"][clf.predict(tmp_x).astype(int)]
136136
if self.return_probabilities:
137137
result_df.loc[names_x, f"{self.result_key}_probabilities"] = np.max(

popv/hub/_metadata.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import json
44
import os
5+
import sys
56
from dataclasses import asdict, dataclass, field
67

78
from anndata import AnnData
@@ -194,6 +195,7 @@ def _to_model_card(self) -> ModelCard:
194195
"genomics",
195196
"single-cell",
196197
f"anndata_version:{self.anndata_version}",
198+
f"python_version:{'.'.join([str(i) for i in sys.version_info[:3]])}",
197199
"popV",
198200
]
199201
for t in self.tissues:

0 commit comments

Comments
 (0)