gemd.entity.bounds.real_bounds module
Bound a real number to be between two values.
- class gemd.entity.bounds.real_bounds.RealBounds(lower_bound: float, upper_bound: float, default_units: str)
Bases:
BaseBounds
Bounded subset of the real numbers, parameterized by a lower and upper bound.
- Parameters
lower_bound (float) – The lower endpoint (inclusive) of the permitted range.
upper_bound (float) – The upper endpoint (inclusive) of the permitted range.
- as_dict() Dict[str, Any]
Convert the object to a dictionary.
- Returns
A dictionary representation of the object, where the keys are its fields.
- 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 a subset of this range.
The other object must also be Real and its lower and upper bound must both be within the range of this bounds object. Values that are unbounded distributions (e.g., Gaussian) are generally assumed to be truncated and logic around permissibility is delegated to the Value implementation.
- Parameters
bounds (BaseBounds or BaseValue) – Other bounds or value 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[RealBoundsType, ContinuousValueType]) RealBoundsType
Return the union of this bounds and other bounds.
The others list must also be Real Bounds or Values.
- Parameters
others (RealBounds or ContinuousValue) – 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[RealBoundsType, ContinuousValueType])
Update this bounds to include other bounds.
The others list must also be Real Bounds or Values.
- Parameters
others (RealBounds or ContinuousValue) – 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 default_units: str
A string describing the units.
Units must be present and parseable by Pint. An empty string can be used for the units of a dimensionless quantity.
- property lower_bound: float
The lower endpoint of the permitted range.
- skip = {}
- typ = 'real_bounds'
- property upper_bound: float
The upper endpoint of the permitted range.