def is_symmetric(mclan, _checked=True) -> bool: """Return whether ``mclan`` is symmetric. :return: ``True`` if ``mclan`` is :term:`symmetric`, ``False`` if it is not, or `Undef()` if ``mclan`` is not a :term:`multiclan`. """ if _checked: if not is_member(mclan): return _undef.make_or_raise_undef() else: assert is_member(mclan) if mclan.cached_symmetric == _mo.CacheStatus.UNKNOWN: symmetric = all(_relations.is_symmetric(rel, _checked=False) for rel in mclan.data) mclan.cache_symmetric(_mo.CacheStatus.from_bool(symmetric)) return mclan.cached_symmetric == _mo.CacheStatus.IS
def is_symmetric(clan, _checked=True) -> bool: """Return whether ``clan`` is symmetric. :return: ``True`` if every :term:`relation` in ``clan`` is :term:`symmetric`, ``False`` if not, or `Undef()` if ``clan`` is not a :term:`clan`. """ if _checked: if not is_member(clan): return _undef.make_or_raise_undef() else: assert is_member(clan) if clan.cached_symmetric == _mo.CacheStatus.UNKNOWN: # The empty set is already handled in Set().__init__ via flags initialization. symmetric = all(_relations.is_symmetric(rel, _checked=False) for rel in clan) clan.cache_symmetric(_mo.CacheStatus.from_bool(symmetric)) return clan.cached_symmetric == _mo.CacheStatus.IS
def is_symmetric(mclan, _checked=True) -> bool: """Return whether ``mclan`` is symmetric. :return: ``True`` if ``mclan`` is :term:`symmetric`, ``False`` if it is not, or `Undef()` if ``mclan`` is not a :term:`multiclan`. """ if _checked: if not is_member(mclan): return _undef.make_or_raise_undef2(mclan) else: assert is_member_or_undef(mclan) if mclan is _undef.Undef(): return _undef.make_or_raise_undef(2) if mclan.cached_symmetric == _mo.CacheStatus.UNKNOWN: symmetric = all( _relations.is_symmetric(rel, _checked=False) for rel in mclan.data) mclan.cache_symmetric(_mo.CacheStatus.from_bool(symmetric)) return mclan.cached_symmetric == _mo.CacheStatus.IS
def is_symmetric(clan, _checked=True) -> bool: """Return whether ``clan`` is symmetric. :return: ``True`` if every :term:`relation` in ``clan`` is :term:`symmetric`, ``False`` if not, or `Undef()` if ``clan`` is not a :term:`clan`. """ if _checked: if not is_member(clan): return _undef.make_or_raise_undef2(clan) else: assert is_member_or_undef(clan) if clan is _undef.Undef(): return _undef.make_or_raise_undef(2) if clan.cached_symmetric == _mo.CacheStatus.UNKNOWN: # The empty set is already handled in Set().__init__ via flags initialization. symmetric = all( _relations.is_symmetric(rel, _checked=False) for rel in clan) clan.cache_symmetric(_mo.CacheStatus.from_bool(symmetric)) return clan.cached_symmetric == _mo.CacheStatus.IS
def is_symmetric(mo: _mo.MathObject, _checked: bool = True) -> bool: r"""Return whether ``mo`` is :term:`symmetric` or `Undef()` if not applicable. Is implemented for :term:`relation`\s, :term:`clan`\s, :term:`multiclan`\s and :term:`set`\s of (sets of ...) clans. Is also defined (but not yet implemented) for any combination of sets or :term:`multiset`\s of relations. """ # pylint: disable=too-many-return-statements if _checked: if not isinstance(mo, _mo.MathObject): return _undef.make_or_raise_undef() # Check cache status. if mo.cached_symmetric == _mo.CacheStatus.IS: return True if mo.cached_symmetric == _mo.CacheStatus.IS_NOT: return False if mo.cached_symmetric == _mo.CacheStatus.N_A: return _undef.make_or_raise_undef(2) # Check type (symmetric is only defined on Sets and Multisets) and algebra memberships. if not mo.is_set and not mo.is_multiset: mo.cache_symmetric(_mo.CacheStatus.N_A) return _undef.make_or_raise_undef(2) if _relations.is_member(mo): return _relations.is_symmetric(mo, _checked=False) if _clans.is_member(mo): return _clans.is_symmetric(mo, _checked=False) if _multiclans.is_member(mo): return _multiclans.is_symmetric(mo, _checked=False) # Check higher (not yet defined) algebras. symmetric = _is_powerset_property(mo, _relations.get_ground_set(), is_symmetric) if symmetric is not _undef.Undef(): mo.cache_symmetric(_mo.CacheStatus.from_bool(symmetric)) return symmetric # Nothing applied: 'symmetric' is not defined. mo.cache_symmetric(_mo.CacheStatus.N_A) return _undef.make_or_raise_undef(2)
def is_symmetric(mo: _mo.MathObject, _checked: bool=True) -> bool: r"""Return whether ``mo`` is :term:`symmetric` or `Undef()` if not applicable. Is implemented for :term:`relation`\s, :term:`clan`\s, :term:`multiclan`\s and :term:`set`\s of (sets of ...) clans. Is also defined (but not yet implemented) for any combination of sets or :term:`multiset`\s of relations. """ # pylint: disable=too-many-return-statements if _checked: if not isinstance(mo, _mo.MathObject): return _undef.make_or_raise_undef() # Check cache status. if mo.cached_symmetric == _mo.CacheStatus.IS: return True if mo.cached_symmetric == _mo.CacheStatus.IS_NOT: return False if mo.cached_symmetric == _mo.CacheStatus.N_A: return _undef.make_or_raise_undef(2) # Check type (symmetric is only defined on Sets and Multisets) and algebra memberships. if not mo.is_set and not mo.is_multiset: mo.cache_symmetric(_mo.CacheStatus.N_A) return _undef.make_or_raise_undef(2) if _relations.is_member(mo): return _relations.is_symmetric(mo, _checked=False) if _clans.is_member(mo): return _clans.is_symmetric(mo, _checked=False) if _multiclans.is_member(mo): return _multiclans.is_symmetric(mo, _checked=False) # Check higher (not yet defined) algebras. symmetric = _is_powerset_property(mo, _relations.get_ground_set(), is_symmetric) if symmetric is not _undef.Undef(): mo.cache_symmetric(_mo.CacheStatus.from_bool(symmetric)) return symmetric # Nothing applied: 'symmetric' is not defined. mo.cache_symmetric(_mo.CacheStatus.N_A) return _undef.make_or_raise_undef(2)