Skip to content

Commit 07ca8b0

Browse files
committed
make .obsmap/.varmap writeable again
closes #138
1 parent ac9c665 commit 07ca8b0

3 files changed

Lines changed: 17 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ and this project adheres to [Semantic Versioning][].
88
[keep a changelog]: https://keepachangelog.com/en/1.1.0/
99
[semantic versioning]: https://semver.org/spec/v2.0.0.html
1010

11+
## [0.3.6]
12+
13+
### Fixed
14+
15+
- `.obsmap` and `.varmap` are once again writeable
16+
1117
## [0.3.5]
1218

1319
### Fixed
@@ -150,6 +156,7 @@ To copy the annotations explicitly, you will need to use `pull_obs()` and/or `pu
150156

151157
Initial `mudata` release with `MuData`, previously a part of the `muon` framework.
152158

159+
[0.3.6]: https://github.com/scverse/mudata/releases/tag/v0.3.6
153160
[0.3.5]: https://github.com/scverse/mudata/releases/tag/v0.3.5
154161
[0.3.4]: https://github.com/scverse/mudata/releases/tag/v0.3.4
155162
[0.3.3]: https://github.com/scverse/mudata/releases/tag/v0.3.3

src/mudata/_core/mudata.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,7 +1482,7 @@ def obsmap(self) -> Mapping[str]:
14821482
in the array contains the numerical index of the observation in the respective modality corresponding to the :class:`MuData`
14831483
observation in that position. The index is 1-based, 0 indicates that the observation is missing in the modality.
14841484
"""
1485-
return MappingProxyType(self._obsmap)
1485+
return self._obsmap
14861486

14871487
@property
14881488
def varm(self) -> MutableMapping[str]:
@@ -1532,7 +1532,7 @@ def varmap(self) -> Mapping[str]:
15321532
in the array contains the numerical index of the feature in the respective modality corresponding to the :class:`MuData`
15331533
feature in that position. The index is 1-based, 0 indicates that the feature is missing in the modality.
15341534
"""
1535-
return MappingProxyType(self._varmap)
1535+
return self._varmap
15361536

15371537
# Unstructured annotations
15381538

tests/test_obs_var.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ def test_obs_vector(mdata: md.MuData):
4444
mdata.obs_vector("foo")
4545

4646

47+
def test_obsmap_writeable(mdata: md.MuData):
48+
mdata.obsmap["test_writeable"] = np.arange(mdata.n_obs)
49+
50+
4751
@pytest.mark.parametrize("mdata", (0, 1), indirect=True)
4852
def test_var_global_columns(mdata: md.MuData, filepath_h5mu: str | Path):
4953
mdata.var.drop(columns=mdata.var.columns, inplace=True)
@@ -89,6 +93,10 @@ def test_var_vector(rng: np.random.Generator, mdata: md.MuData):
8993
mdata.var_vector("assert-boolean-1")
9094

9195

96+
def test_varmap_writeable(mdata: md.MuData):
97+
mdata.varmap["test_writeable"] = np.arange(mdata.n_vars)
98+
99+
92100
@pytest.mark.parametrize("mdata", (0, 1), indirect=True)
93101
def test_names_make_unique(mdata: md.MuData):
94102
attr = "obs" if mdata.axis == 0 else "var"

0 commit comments

Comments
 (0)