Skip to content

Commit 57ee6fe

Browse files
committed
Fix #99
1 parent 2b6f6d4 commit 57ee6fe

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/mudata/_core/mudata.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -697,8 +697,14 @@ def _update_attr(
697697

698698
data_global = data_global.rename_axis(col_index, axis=0).reset_index()
699699
for mod in self.mod.keys():
700-
data_global[mod + ":" + rowcol] = getattr(self, attr + "map")[mod]
701-
attrmap_columns = (mod + ":" + rowcol for mod in self.mod.keys())
700+
# Only add mapping for modalities that exist in attrmap
701+
if mod in getattr(self, attr + "map"):
702+
data_global[mod + ":" + rowcol] = getattr(self, attr + "map")[mod]
703+
attrmap_columns = [
704+
mod + ":" + rowcol
705+
for mod in self.mod.keys()
706+
if mod in getattr(self, attr + "map")
707+
]
702708

703709
data_mod = data_mod.merge(
704710
data_global, on=[col_index, *attrmap_columns], how="left", sort=False
@@ -803,8 +809,11 @@ def _update_attr(
803809
data_global[col_range] = np.arange(len(data_global))
804810

805811
for mod in self.mod.keys():
806-
data_global[mod + ":" + rowcol] = getattr(self, attr + "map")[mod]
807-
attrmap_columns = [mod + ":" + rowcol for mod in self.mod.keys()]
812+
if mod in getattr(self, attr + "map"):
813+
data_global[mod + ":" + rowcol] = getattr(self, attr + "map")[mod]
814+
attrmap_columns = [
815+
mod + ":" + rowcol for mod in self.mod.keys() if mod in getattr(self, attr + "map")
816+
]
808817

809818
data_mod = data_mod.merge(data_global, on=attrmap_columns, how="left", sort=False)
810819

0 commit comments

Comments
 (0)