cap-anndata 0.2.1__tar.gz → 0.2.2__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cap_anndata
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: Partial read/write of AnnData (h5ad) files for low-memory operations with large datasets.
5
5
  Home-page: https://github.com/cellannotation/cap-anndata
6
6
  Author: R. Mukhin, A. Isaev
@@ -12,10 +12,10 @@ Classifier: Operating System :: OS Independent
12
12
  Requires-Python: >=3.9
13
13
  Description-Content-Type: text/markdown
14
14
  License-File: LICENSE
15
- Requires-Dist: numpy>=1.26.3
16
- Requires-Dist: pandas>=2.2.0
17
- Requires-Dist: anndata>=0.10.5
18
- Requires-Dist: h5py>=3.5.0
15
+ Requires-Dist: numpy~=1.26.3
16
+ Requires-Dist: pandas~=2.2.0
17
+ Requires-Dist: anndata~=0.10.5
18
+ Requires-Dist: h5py~=3.5.0
19
19
  Provides-Extra: dev
20
20
  Requires-Dist: pytest>=8.0.0; extra == "dev"
21
21
  Requires-Dist: setuptools~=69.1.1; extra == "dev"
@@ -91,8 +91,8 @@ class BaseLayerMatrixAndDf:
91
91
  df.column_order = df.column_order.astype(object)
92
92
  return df
93
93
 
94
- def _write_elem_lzf(self, dest_key: str, elem: any) -> None:
95
- write_elem(self._file, dest_key, elem, dataset_kwargs={"compression": "lzf"})
94
+ def _write_elem(self, dest_key: str, elem: any, compression: str) -> None:
95
+ write_elem(self._file, dest_key, elem, dataset_kwargs={"compression": compression})
96
96
 
97
97
  def _validate_cap_df(self, cap_df: CapAnnDataDF, axis: int) -> None:
98
98
  if not isinstance(cap_df, CapAnnDataDF):
@@ -210,7 +210,7 @@ class CapAnnData(BaseLayerMatrixAndDf):
210
210
  for col in df.columns:
211
211
  self._var[col] = df[col]
212
212
 
213
- def overwrite(self, fields: List[str] = None) -> None:
213
+ def overwrite(self, fields: List[str] = None, compression: str = "lzf") -> None:
214
214
  field_to_entity = {
215
215
  "obs": self.obs,
216
216
  "var": self.var,
@@ -237,7 +237,7 @@ class CapAnnData(BaseLayerMatrixAndDf):
237
237
  key = key.replace(".", "/") if key == "raw.var" else key
238
238
 
239
239
  for col in entity.columns:
240
- self._write_elem_lzf(f"{key}/{col}", entity[col].values)
240
+ self._write_elem(f"{key}/{col}", entity[col].values, compression=compression)
241
241
 
242
242
  column_order = entity.column_order
243
243
  if (
@@ -250,7 +250,7 @@ class CapAnnData(BaseLayerMatrixAndDf):
250
250
  for key in self.uns.keys():
251
251
  if self.uns[key] is not NotLinkedObject:
252
252
  dest = f"uns/{key}"
253
- self._write_elem_lzf(dest, self.uns[key])
253
+ self._write_elem(dest, self.uns[key], compression=compression)
254
254
  for key in self.uns.keys_to_remove:
255
255
  del self._file[f"uns/{key}"]
256
256
 
@@ -261,8 +261,8 @@ class CapAnnData(BaseLayerMatrixAndDf):
261
261
  for key in keys:
262
262
  existing_keys = self.uns.keys()
263
263
  if key in existing_keys:
264
- sourse = self._file[f"uns/{key}"]
265
- self.uns[key] = read_elem(sourse)
264
+ source = self._file[f"uns/{key}"]
265
+ self.uns[key] = read_elem(source)
266
266
 
267
267
  def _link_obsm(self) -> None:
268
268
  self._obsm = {}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cap_anndata
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: Partial read/write of AnnData (h5ad) files for low-memory operations with large datasets.
5
5
  Home-page: https://github.com/cellannotation/cap-anndata
6
6
  Author: R. Mukhin, A. Isaev
@@ -12,10 +12,10 @@ Classifier: Operating System :: OS Independent
12
12
  Requires-Python: >=3.9
13
13
  Description-Content-Type: text/markdown
14
14
  License-File: LICENSE
15
- Requires-Dist: numpy>=1.26.3
16
- Requires-Dist: pandas>=2.2.0
17
- Requires-Dist: anndata>=0.10.5
18
- Requires-Dist: h5py>=3.5.0
15
+ Requires-Dist: numpy~=1.26.3
16
+ Requires-Dist: pandas~=2.2.0
17
+ Requires-Dist: anndata~=0.10.5
18
+ Requires-Dist: h5py~=3.5.0
19
19
  Provides-Extra: dev
20
20
  Requires-Dist: pytest>=8.0.0; extra == "dev"
21
21
  Requires-Dist: setuptools~=69.1.1; extra == "dev"
@@ -0,0 +1,8 @@
1
+ numpy~=1.26.3
2
+ pandas~=2.2.0
3
+ anndata~=0.10.5
4
+ h5py~=3.5.0
5
+
6
+ [dev]
7
+ pytest>=8.0.0
8
+ setuptools~=69.1.1
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name='cap_anndata',
5
- version='0.2.1',
5
+ version='0.2.2',
6
6
  author='R. Mukhin, A. Isaev',
7
7
  author_email='roman@ebookapplications.com',
8
8
  packages=find_packages(exclude=["test"]),
@@ -20,10 +20,10 @@ setup(
20
20
  ],
21
21
  python_requires='>=3.9',
22
22
  install_requires=[
23
- "numpy>=1.26.3",
24
- "pandas>=2.2.0",
25
- "anndata>=0.10.5",
26
- "h5py>=3.5.0",
23
+ "numpy~=1.26.3",
24
+ "pandas~=2.2.0",
25
+ "anndata~=0.10.5",
26
+ "h5py~=3.5.0",
27
27
  ],
28
28
  extras_require={"dev": [
29
29
  "pytest>=8.0.0",
@@ -102,7 +102,8 @@ def test_partial_read():
102
102
  pd.testing.assert_index_equal(adata.raw.var.index, cap_adata.raw.var.index)
103
103
 
104
104
 
105
- def test_overwrite_df():
105
+ @pytest.mark.parametrize("compression", ["gzip", "lzf"])
106
+ def test_overwrite_df(compression):
106
107
  adata = get_filled_anndata()
107
108
  temp_folder = tempfile.mkdtemp()
108
109
  file_path = os.path.join(temp_folder, "test_overwrite_df.h5ad")
@@ -132,7 +133,7 @@ def test_overwrite_df():
132
133
  cap_adata.raw.var["extra_info"] = np.random.rand(cap_adata.shape[1])
133
134
  ref_raw_var = cap_adata.raw.var.copy()
134
135
 
135
- cap_adata.overwrite(["obs", "var", "raw.var"])
136
+ cap_adata.overwrite(["obs", "var", "raw.var"], compression=compression)
136
137
 
137
138
  adata = ad.read_h5ad(file_path)
138
139
  os.remove(file_path)
@@ -253,7 +254,8 @@ def test_read_uns():
253
254
  os.remove(file_path)
254
255
 
255
256
 
256
- def test_modify_uns():
257
+ @pytest.mark.parametrize("compression", ["gzip", "lzf"])
258
+ def test_modify_uns(compression):
257
259
  adata = get_base_anndata()
258
260
  adata.uns = {
259
261
  "field_to_ignore": list(range(100)),
@@ -278,7 +280,7 @@ def test_modify_uns():
278
280
  cap_adata.uns["field_to_expand"]["key1"] = d_to_exp
279
281
  cap_adata.uns["field_to_modify"] = v_to_mod
280
282
 
281
- cap_adata.overwrite(["uns"])
283
+ cap_adata.overwrite(["uns"], compression=compression)
282
284
 
283
285
  adata = ad.read_h5ad(file_path)
284
286
 
@@ -1,8 +0,0 @@
1
- numpy>=1.26.3
2
- pandas>=2.2.0
3
- anndata>=0.10.5
4
- h5py>=3.5.0
5
-
6
- [dev]
7
- pytest>=8.0.0
8
- setuptools~=69.1.1
File without changes
File without changes
File without changes