class graphicle.data.MaskGroup(graphicle.base.MaskBase, MutableMapping[str, graphicle.data.MaskGeneric])[source]

Data structure to compose groups of masks over particle arrays. Can be nested to form complex hierarchies.

New in version 0.1.0.

Changed in version 0.2.6: Changed bitwise_or and bitwise_and properties into methods. Added generic type hinting for elements within MaskGroup.

Parameters:
mask_arrays : dict[str, MaskLike]

Dictionary of MaskArray objects to be composed.

agg_op : {'and', 'or', 'none'}

Defines the aggregation operation when accessing the data attribute. Default is 'and'.

Public members

property agg_op : MaskAggOp[source]

Aggregation operation set for reduction over constituent masks.

classmethod from_numpy_structured(arr) MaskGroup[source]
__repr__() str[source]

Return repr(self).

__str__() str[source]

Return str(self).

__getitem__(key) MaskArray | MaskGroup[MaskGeneric][source]

Subscripting for MaskGroup object.

__setitem__(key: str, mask: MaskBase | ndarray[Any, dtype[bool_]])[source]

Add a new MaskArray to the group, with given key.

__delitem__(key) None[source]

Remove a MaskArray from the group, using given key.

__array__() ndarray[Any, dtype[bool_]][source]

Numpy array representation of the data.

__or__(other: MaskBase | ndarray[Any, dtype[bool_]]) MaskArray[source]

Return self|value.

__eq__(other: MaskBase | ndarray[Any, dtype[bool_]]) MaskArray[source]

Return self==value.

__ne__(other: MaskBase | ndarray[Any, dtype[bool_]]) MaskArray[source]

Return self!=value.

copy() MaskGroup[MaskGeneric][source]

Copies the underlying data into a new MaskGroup instance.

bitwise_or() MaskArray[source]
bitwise_and() MaskArray[source]
property data : ndarray[Any, dtype[bool_]][source]

Same as MaskGroup.bitwise_and.

to_dict() dict[str, ndarray[Any, dtype[bool_]]][source]

Masks nested in a dictionary instead of a MaskGroup.

recursive_drop(key: str = 'latent', ...) MaskGroup[source]

Removes masks indexed by key at all levels of nesting.

flatten(...) MaskGroup[MaskArray][source]

Removes nesting such that the MaskGroup contains only MaskArray instances, and no other MaskGroup.

serialize() dict[str, Any][source]

Returns serialized data as a dictionary.

equal_to(other: MaskGroup, check_order: bool = False) bool[source]

Checks whether this instance is identical to other MaskGroup, comparing keys at all levels of nesting, and boolean array data at the leaf level.

__setattr__(name, val)[source]

Method generated by attrs for class MaskGroup.

MaskGroup(...)[source]

Method generated by attrs for class MaskGroup.

pop(...) v, remove specified key and return the corresponding value.[source]

If key is not found, d is returned if given, otherwise KeyError is raised.

popitem() (k, v), remove and return some (key, value) pair[source]

as a 2-tuple; but raise KeyError if D is empty.

clear() None.  Remove all items from D.[source]
update([E, ]**F) None.  Update D from mapping/iterable E and F.[source]

If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

setdefault(k[, d]) D.get(k,d), also set D[k]=d if k not in D[source]
get(k[, d]) D[k] if k in D, else d.  d defaults to None.[source]
keys() a set-like object providing a view on D's keys[source]
items() a set-like object providing a view on D's items[source]
values() an object providing a view on D's values[source]
classmethod __subclasshook__(C)[source]

Abstract classes can override this to customize issubclass().

MaskGroup = <bound method GenericAlias of <class 'collections.abc.Iterable'>>[source]
classmethod __init_subclass__(*args, **kwargs)[source]

This method is called when a class is subclassed.


Last update: Jun 27, 2025