From 9809ecefb2f293a7968278ebcae7a1cf9e233b6e Mon Sep 17 00:00:00 2001 From: Kai Zhang Date: Wed, 28 Feb 2024 16:21:00 +0800 Subject: [PATCH] minor --- pyanndata/Cargo.toml | 2 +- pyanndata/src/container.rs | 3 ++- python/setup.py | 1 + python/tests/test_base.py | 1 + 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pyanndata/Cargo.toml b/pyanndata/Cargo.toml index 6ee7c0e..2e327af 100644 --- a/pyanndata/Cargo.toml +++ b/pyanndata/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pyanndata" -version = "0.3.0" +version = "0.3.1" edition = "2021" rust-version = "1.70" authors = ["Kai Zhang "] diff --git a/pyanndata/src/container.rs b/pyanndata/src/container.rs index d4c234b..c92ff57 100644 --- a/pyanndata/src/container.rs +++ b/pyanndata/src/container.rs @@ -153,7 +153,8 @@ impl PyDataFrameElem { self.0.get(subscript) } - fn __setitem__(&self, key: &str, data: PySeries) -> Result<()> { + fn __setitem__(&self, key: &str, data: &PyAny) -> Result<()> { + let data: PySeries = data.py().import("polars")?.call_method1("Series", (data, ))?.extract()?; self.0.set(key, data.into()) } diff --git a/python/setup.py b/python/setup.py index f3ad3d0..6c87dcc 100644 --- a/python/setup.py +++ b/python/setup.py @@ -17,6 +17,7 @@ "anndata>=0.8", "numpy>=1.16", "pandas", + "pyarrow", "scipy>=1.4", "polars>=0.14", ], diff --git a/python/tests/test_base.py b/python/tests/test_base.py index 1e63110..d84d5c3 100644 --- a/python/tests/test_base.py +++ b/python/tests/test_base.py @@ -103,6 +103,7 @@ def test_creation(tmp_path): adata.uns['df'] = pd.DataFrame([[1, 2, 3], [4, 5, 6]], columns=["a", "b", "c"]) adata.obs = pl.DataFrame({"a": ['1', '2'], "b": [3, 4]}) + adata.obs['c'] = np.array([1, 2]) obs_names = list(adata.obs['a']) adata.obs_names = obs_names adata.obs = pl.DataFrame()