def is_absolute_member(obj: _mo.MathObject) -> bool: """Return whether ``obj`` is a member of the :term:`absolute ground set` of this algebra. :return: ``True`` if ``obj`` is an :term:`absolute clan`, ``False`` if not. .. note:: This function may call :meth:`~.MathObject.get_ground_set` on ``obj``. The result of this operation is cached. """ if obj.cached_is_not_multiclan: # If known to not be a multiclan, it's also not an absolute multiclan. No further caching. return False # The `or` clause in this `if` statement is a safety thing. It should never hit. if obj.cached_absolute == _mo.CacheStatus.UNKNOWN \ or obj.cached_multiclan == _mo.CacheStatus.UNKNOWN: # The 'absolute' state has not yet been cached. Determine whether obj is an absolute # multiclan. is_absolute_mclan = obj.get_ground_set().is_subset(get_absolute_ground_set()) if obj.cached_multiclan == _mo.CacheStatus.UNKNOWN: if is_absolute_mclan: # If it is an absolute multiclan, it is also a multiclan. obj.cache_multiclan(_mo.CacheStatus.IS) else: # If it is not an absolute multiclan, it may still be a multiclan. is_mclan = is_member(obj) if not is_mclan: # If it is neither an absolute multiclan nor a multiclan, exit. (That it is # not a multiclan has already been cached in is_member().) return False # At this point, cached_multiclan == IS. Cache whether this is an absolute multiclan. assert obj.cached_is_multiclan obj.cache_absolute(_mo.CacheStatus.from_bool(is_absolute_mclan)) # At this point, cached_multiclan == IS. Return whether it is an absolute multiclan. return obj.cached_is_absolute
def is_absolute_member(obj: _mo.MathObject) -> bool: """Return whether ``obj`` is a member of the :term:`absolute ground set` of this algebra. :return: ``True`` if ``obj`` is an :term:`absolute clan`, ``False`` if not. .. note:: This function may call :meth:`~.MathObject.get_ground_set` on ``obj``. The result of this operation is cached. """ if obj.cached_is_not_multiclan: # If known to not be a multiclan, it's also not an absolute multiclan. No further caching. return False # The `or` clause in this `if` statement is a safety thing. It should never hit. if obj.cached_absolute == _mo.CacheStatus.UNKNOWN \ or obj.cached_multiclan == _mo.CacheStatus.UNKNOWN: # The 'absolute' state has not yet been cached. Determine whether obj is an absolute # multiclan. is_absolute_mclan = obj.get_ground_set().is_subset( get_absolute_ground_set()) if obj.cached_multiclan == _mo.CacheStatus.UNKNOWN: if is_absolute_mclan: # If it is an absolute multiclan, it is also a multiclan. obj.cache_multiclan(_mo.CacheStatus.IS) else: # If it is not an absolute multiclan, it may still be a multiclan. is_mclan = is_member(obj) if not is_mclan: # If it is neither an absolute multiclan nor a multiclan, exit. (That it is # not a multiclan has already been cached in is_member().) return False # At this point, cached_multiclan == IS. Cache whether this is an absolute multiclan. assert obj.cached_is_multiclan obj.cache_absolute(_mo.CacheStatus.from_bool(is_absolute_mclan)) # At this point, cached_multiclan == IS. Return whether it is an absolute multiclan. return obj.cached_is_absolute
def is_member(obj: _mo.MathObject) -> bool: """Return whether ``obj`` is a member of the :term:`ground set` of this :term:`algebra`. :return: ``True`` if ``obj`` is a :term:`multiclan`, ``False`` if not. .. note:: This function may call :meth:`~.MathObject.get_ground_set` on ``obj``. The result of this operation is cached. """ if obj.cached_multiclan == _mo.CacheStatus.UNKNOWN: is_multiclan = obj.get_ground_set().is_subset(get_ground_set()) obj.cache_multiclan(_mo.CacheStatus.from_bool(is_multiclan)) return obj.cached_is_multiclan
def is_member(obj: _mo.MathObject) -> bool: """Return whether ``obj`` is a member of the :term:`ground set` of this :term:`algebra`. :return: ``True`` if ``obj`` is a :term:`multiclan`, ``False`` if not. .. note:: This function may call :meth:`~.MathObject.get_ground_set` on ``obj``. The result of this operation is cached. """ if obj.cached_multiclan == _mo.CacheStatus.UNKNOWN: is_multiclan = obj.get_ground_set().is_subset(get_ground_set()) obj.cache_multiclan(_mo.CacheStatus.from_bool(is_multiclan)) return obj.cached_is_multiclan