Skip to content

Commit

Permalink
enabled MaskGroup instantiation from nested mappings #172
Browse files Browse the repository at this point in the history
  • Loading branch information
jacanchaplais committed Feb 27, 2024
1 parent f375988 commit e6cf1e6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion graphicle/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,9 @@ def _mask_neq(mask1: base.MaskLike, mask2: base.MaskLike) -> MaskArray:
return MaskArray(np.not_equal(mask1, mask2))


_IN_MASK_DICT = ty.OrderedDict[str, ty.Union[MaskArray, base.BoolVector]]
_IN_MASK_DICT = ty.Mapping[
str, ty.Union[MaskArray, base.BoolVector, ty.Iterable[bool]]
]
_MASK_DICT = ty.OrderedDict[str, MaskArray]


Expand All @@ -651,6 +653,8 @@ def _mask_dict_convert(masks: _IN_MASK_DICT) -> _MASK_DICT:
for key, val in masks.items():
if isinstance(val, MaskArray) or isinstance(val, MaskGroup):
mask = val
elif isinstance(val, cla.Mapping):
mask = MaskGroup(_mask_dict_convert(val))
else:
mask = MaskArray(val)
out_masks[key] = mask
Expand Down

0 comments on commit e6cf1e6

Please sign in to comment.