Beispiel #1
0
 def mk_hybrid_flag___if_only_active_keys(ops4hybrid_flag, hybrid_flag, active_keys, /):
     r'''
     hybrid_flag -> active_keys -> hybrid_flag
         if there is only active_key_set in args/hybrid_flag-instance-state
     #'''
     active_key_set = mk_frozenset(active_keys)
     del active_keys
     assert type(active_key_set) is frozenset
     if not ops4hybrid_flag.is_active_key_set_valid_configuration_of_hybrid_flag(hybrid_flag, active_key_set): raise ValueError('active_key_set is invalid configuration')
     valid_active_key_frozenset = active_key_set
     return ops4hybrid_flag._ooo__mk_hybrid_flag_from_valid_active_key_frozenset__ooo_(hybrid_flag, valid_active_key_frozenset)
Beispiel #2
0
 def __init__(sf, active_key_set=null_frozenset, /):
     cls = type(sf)
     if cls.___partition_at_hybrid_flag_cls___ is NotImplemented: raise TypeError
     if cls.___constraints_at_hybrid_flag_cls___ is NotImplemented: raise TypeError
     #################################
     active_key_set = mk_frozenset(active_key_set)
     ops4hybrid_flag = get_ops4hybrid_flag_of_hybrid_flag(sf)
     if not ops4hybrid_flag.is_active_key_set_valid_configuration_of_hybrid_flag(sf, active_key_set): raise ValueError('active_key_set is invalid configuration')
     valid_active_key_frozenset = active_key_set
     del active_key_set
     sf._active_keys = valid_active_key_frozenset
Beispiel #3
0
 def to_immutable___constraints___static(constraints, /):
     def _4constraint(constraint):
         (lhs_all__false0s, lhs_all__true1s, rhs_any__alternatives) = constraint
         (lhs_all__false0s, lhs_all__true1s) = _4fs_ts((lhs_all__false0s, lhs_all__true1s))
         rhs_any__alternatives = mk_frozenset(map(_4fs_ts, rhs_any__alternatives))
         constraint = (lhs_all__false0s, lhs_all__true1s, rhs_any__alternatives)
         return constraint
     def _4fs_ts(fs_ts):
         fs, ts = map(_4legal_keys, fs_ts)
         return fs, ts
     def _4legal_keys(legal_keys):
         return mk_frozenset(legal_keys)
     return mk_frozenset(map(_4constraint, constraints))
Beispiel #4
0
 def _4legal_keys(legal_keys):
     return mk_frozenset(legal_keys)
Beispiel #5
0
 def _4constraint(constraint):
     (lhs_all__false0s, lhs_all__true1s, rhs_any__alternatives) = constraint
     (lhs_all__false0s, lhs_all__true1s) = _4fs_ts((lhs_all__false0s, lhs_all__true1s))
     rhs_any__alternatives = mk_frozenset(map(_4fs_ts, rhs_any__alternatives))
     constraint = (lhs_all__false0s, lhs_all__true1s, rhs_any__alternatives)
     return constraint
Beispiel #6
0
 def immutable_set_opAND_configuration_of_hybrid_flag(ops4hybrid_flag, hybrid_flag, keys, /):
     r'''
     #raise TypeError/KeyError/ValueError
     hybrid_flag & active_keys
         if there is only active_key_set in args/hybrid_flag-instance-state
     #'''
     return ops4hybrid_flag.immutable__apply_set_op_on_configuration_of_hybrid_flag(hybrid_flag, opss.__and__, mk_frozenset(keys))
Beispiel #7
0
                #raise TypeError/KeyError
        except KeyError:
            return False
        return True
    def are_keys_legal(ops4partition, partition, keys, /):
        return all(ops4partition.is_key_legal(partition, key) for key in keys)
            #raise TypeError
    def to_immutable___legal_key2xgroup_descriptor__mapping(ops4partition, legal_key2xgroup_descriptor__mapping, /):
        return FrozenDict(legal_key2xgroup_descriptor__mapping)
    r'''
    def to_immutable_amd_filter___legal_key_mutex_groups(ops4partition, legal_key_mutex_groups, /):
        legal_key_mutex_groups = mk_frozenset(filter(bool, map(mk_frozenset, legal_key_mutex_groups)))
        return legal_key_mutex_groups
    #'''
    def mk_partition_members___if_legal_keys_finite(ops4partition, partition, legal_key_mutex_groups, /,*, allow_illegal_keys:bool):
        legal_key_mutex_groups = mk_frozenset(filter(bool, map(mk_frozenset, legal_key_mutex_groups)))
        assert all(legal_key_mutex_groups)
        if allow_illegal_keys:
            _check = ops4partition.check__objs_are_keys
                # raise TypeError
        else:
            _check = ops4partition.check__objs_are_legal_keys
                # raise TypeError/KeyError
        _check(partition, itertools.chain.from_iterable(legal_key_mutex_groups))
            # raise TypeError/KeyError

        #legal_keys = frozenset().union(*legal_key_mutex_groups)
        legal_key2xgroup_descriptor__mapping = {}
        #keys4discrete_mutex_groups = set()
        num_discrete_mutex_groups = 0
        for i, legal_key_group in enumerate(legal_key_mutex_groups):