Skip to content

Commit

Permalink
Add lazy creation of obsm
Browse files Browse the repository at this point in the history
 As mentioned in scverse#363 (comment)
  • Loading branch information
fhausmann committed Jun 30, 2020
1 parent af24e3e commit ddceb40
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions anndata/_core/anndata.py
Original file line number Diff line number Diff line change
Expand Up @@ -904,11 +904,15 @@ def obsm(self) -> Union[AxisArrays, AxisArraysView]:
of length `n_obs`.
Is sliced with `data` and `obs` but behaves otherwise like a :term:`mapping`.
"""
return self._obsm
if self.is_view:
obsm = AxisArrays(self._adata_ref, 0, self._obsm)
return obsm._view(self, self.obs_names)
else:
return AxisArrays(self, 0, self._obsm)

@obsm.setter
def obsm(self, value):
obsm = AxisArrays(self, 0, vals=convert_to_dict(value))
obsm = convert_to_dict(value)
if self.is_view:
self._init_as_actual(self.copy())
self._obsm = obsm
Expand Down

0 comments on commit ddceb40

Please sign in to comment.