mosaik.in_or_out_set – Classes for attribute specifications¶
InOrOutSet is an abstraction used to represent sets of
attributes used by a model.
Normally, a simulator model specifies a (finite) list of input
attributes. However, it can also specify any_inputs=True, in which
case any string is a valid attribute. This can furthermore be combined
with listing a finite list of them as trigger or non-trigger attributes,
in which case the other type of attribute allows all but a finite number
of strings.
An OutSet represents a set consisting of all elements of a type
(string, for attribute names), except for a finite number. An
InOrOutSet represents either a normal frozenset or an
OutSet. (So it is a set that is finite or co-finite.)
Set operations between InOrOutSet instances are well-defined and
always result in another InOrOutSet.
- type InOrOutSet[E] = OutSet | frozenset[source]¶
(The type parameter
Eis actually passed on toOutSetandfrozenset, which we cannot properly document due to limitations in Sphinx.)An InOrOutSet is either a FrozenSet or an OutSet. This means that it can represent either - a finite number of elements of the type E or - all but a finite number of element of the type E.
Standard set-theoretic operations (union, intersection, etc.) can still be computed for InOrOutSets and will result in a InOrOutSet again.
- class OutSet(elems=())[source]¶
An OutSet[E] represents all elements of the type E except for a finite number.
In particular,
x in OutSet(elems)isTruewheneverx not in elems. Set operations between instances ofOutSetand Python’sfrozensetwork as excepted.Note that by their nature it is not possible to iterate over an OutSet.
- Parameters:
elems (Iterable) – An iterable of elements of the generic type. (We cannot properly document the type parameter
Ehere due to limitations in Sphinx.)
- parse_set_triple(union, part_a, part_b, union_name='union', part_a_name='part_a', part_b_name='part_b')[source]¶
Take three sets and make sure that the first is the disjoint union of the other two. If one of the sets is None, find the value for it that ensures this, if possible. Return the two parts.
- Parameters:
union (InOrOutSet | None)
part_a (InOrOutSet | None)
part_b (InOrOutSet | None)
union_name (str)
part_a_name (str)
part_b_name (str)
- Return type:
- wrap_set(set)[source]¶
Wrap an iterable or OutSet, resulting in an InOrOutSet. Pass through None unchanged.
- Parameters:
- Return type:
InOrOutSet | None