pyphi.models.cmp.Orderable#
- class pyphi.models.cmp.Orderable[source]#
Bases:
objectBase mixin for implementing rich object comparisons on phi-objects.
Both
__eq__andorder_byneed to be implemented on the subclass. Theorder_bymethod returns a list of attributes which are compared to implement the ordering.Subclasses can optionally override
is_orderable_withto enforce constraints (for example,AcSystemIrreducibilityAnalysisrequires both operands to have the samedirection).Ordering (
</>) comparesorder_by()values exactly, while__eq__on phi-objects is typically tolerance-aware (seenumpy_aware_eq()). Exact ordering keeps selection (max/min/sort) deterministic — with genuine ties handled explicitly bypyphi.resolve_ties— while tolerant equality absorbs float drift in structural comparison. A consequence is that<=/>=(defined as strict ordering or tolerant equality) can both hold for two objects whose values differ by less than the equality tolerance.