gemd.entity.bounds.composition_bounds module
Bounds a composition to have a specified set of components.
- class gemd.entity.bounds.composition_bounds.CompositionBounds(components=None)
Bases:
BaseBounds
Composition bounds, parameterized by a set of string-valued category labels.
- Parameters
components (list, tuple, or set or strings) – A collection of the components that must be present in the composition.
- as_dict()
Convert bounds to a dictionary.
- Returns
A dictionary with “type” and “components” (a sorted list of the components).
- Return type
dict
- static build(d: Mapping[str, Any]) DictSerializableType
Build an object from a JSON dictionary.
This differs from from_dict in that the values themselves may also be dictionaries corresponding to serialized DictSerializable objects.
- Parameters
d (dict) – The object as a serialized dictionary.
- Returns
The deserialized object.
- Return type
- contains(bounds: Union[BaseBounds, BaseValueType]) bool
Check if another bounds or value object is contained by this bounds.
The other object must also be a Composition and its components must be a subset of this bounds’s set of allowed components.
- Parameters
bounds (BaseBounds or BaseValue) – Other object to check. If it’s a Value object, check against the smallest compatible bounds, as returned by the Value’s
_to_bounds()
method.- Returns
True if the other object is contained by this bounds.
- Return type
bool
- dump() Dict[str, Any]
Convert the object to a JSON dictionary, so that every entry is serialized.
Uses the json encoder client, so objects with uids are converted to LinkByUID dictionaries.
- Returns
A string representation of the object as a dictionary.
- Return type
str
- classmethod from_dict(d: Mapping[str, Any]) DictSerializableType
Reconstitute the object from a dictionary.
- Parameters
d (dict) – The object as a dictionary of key-value pairs that correspond to the object’s fields.
- Returns
The deserialized object.
- Return type
- union(*others: Union[CompositionBoundsType, CompositionValueType]) CompositionBoundsType
Return the union of this bounds and other bounds.
The others list must also be Composition Bounds or Values.
- Parameters
others (CompositionBounds or CompositionValue) – Other bounds or value objects to include. If they’re Value objects, increase by the smallest compatible bounds, as returned by the value’s
_to_bounds()
method.- Returns
The union of this bounds and the passed bounds
- Return type
- update(*others: Union[CompositionBoundsType, CompositionValueType])
Update this bounds to include other bounds.
The others list must also be Composition Bounds or Values.
- Parameters
others (CompositionBounds or CompositionValue) – Other bounds or value objects to include. If they’re Value objects, increase by the smallest compatible bounds, as returned by the value’s
_to_bounds()
method.
- property components: Set[str]
Get the collection of the components that are allowed in the composition.
- skip = {}
- typ = 'composition_bounds'