A generator over all subsystems in a valid state.
557569
def _reachable_subsystems(network, indices, state):
    """"""
    validate.is_network(network)

    # Return subsystems largest to smallest to optimize parallel
    # resource usage.
    for subset in utils.powerset(indices, nonempty=True, reverse=True):
        try:
            yield Subsystem(network, state, subset)
        except exceptions.StateUnreachableError:
            pass
606535
function collect_states_recursive( array &$states, Grammar $Grammar, array $excluded, $threadId ){
		// recursion check
		if( $this->threadId === $threadId ){
			//echo "Recursion in $this \n";
			return;
		}
		$this->threadId = $threadId;
		// add denied first terminals into array
		$excluded = array_merge( $excluded, $Grammar->excluded_terminals($this->nt) );
		// Follow e-transitions recursively to gather all possible states
		foreach( $this->etransitions as $s => $State ){
			$State->collect_states_passthru( $states, $Grammar, $excluded, $threadId );
		}
	}
130646
def _generate_standard_transitions(cls):
        """"""
        allowed_transitions = cls.context.get_config('transitions', {})
        for key, transitions in allowed_transitions.items():
            key = cls.context.new_meta['translator'].translate(key)

            new_transitions = set()
            for trans in transitions:
                if not isinstance(trans, Enum):
                    trans = cls.context.new_meta['translator'].translate(trans)
                new_transitions.add(trans)

            cls.context.new_transitions[key] = new_transitions

        for state in cls.context.states_enum:
            if state not in cls.context.new_transitions:
                cls.context.new_transitions[state] = set()
719343
def basis_state(i, n):
    """"""
    v = sympy.zeros(n, 1)
    v[i] = 1
    return v
39239
def state(self, states=None):
        
        if states is None or not states:
            return self
        nodes = []
        for node in self.nodes:
            if any(state.lower() == node.state.lower() for state in states):
                nodes.append(node)
        self.nodes = nodes
        return self
185736
private AbstractState createState(CopycatServer.State state) {
    switch (state) {
      case INACTIVE:
        return new InactiveState(this);
      case RESERVE:
        return new ReserveState(this);
      case PASSIVE:
        return new PassiveState(this);
      case FOLLOWER:
        return new FollowerState(this);
      case CANDIDATE:
        return new CandidateState(this);
      case LEADER:
        return new LeaderState(this);
      default:
        throw new AssertionError();
    }
  }
715616
def _construct_state_machines(self):
        
        state_machines = dict()
        for state_machine in [StateMachineRecomputing(self.logger, self),
                              StateMachineContinuous(self.logger, self),
                              StateMachineDiscrete(self.logger, self),
                              StateMachineFreerun(self.logger)]:
            state_machines[state_machine.name] = state_machine
        return state_machines
558197
def global_state(self):
        
        self._generate_func_code()

        return dict(
            REGEX_PATTERNS=self._compile_regexps,
            re=re,
            JsonSchemaException=JsonSchemaException,
        )
1277462
def state_reachable(subsystem):
    """"""
    # If there is a row `r` in the TPM such that all entries of `r - state` are
    # between -1 and 1, then the given state has a nonzero probability of being
    # reached from some state.
    # First we take the submatrix of the conditioned TPM that corresponds to
    # the nodes that are actually in the subsystem...
    tpm = subsystem.tpm[..., subsystem.node_indices]
    # Then we do the subtraction and test.
    test = tpm - np.array(subsystem.proper_state)
    if not np.any(np.logical_and(-1 < test, test < 1).all(-1)):
        raise exceptions.StateUnreachableError(subsystem.state)
254006
def use_internal_state(self):
        """"""
        old_state = random.getstate()
        random.setstate(self._random_state)
        yield
        self._random_state = random.getstate()
        random.setstate(old_state)
94860
def state_subpattern(self, value):
        """"""
        num, *_, parsed = value
        if num in self.groups:
            return (yield required(self.groups[num]))

        yield from Traverser(parsed, groups=self.groups)
1082002
def p_state_invariant_list(self, p):
        ''''''
        if len(p) == 3:
            p[1].append(p[2])
            p[0] = p[1]
        elif len(p) == 2:
            p[0] = [p[1]]
277471
def all_subclasses(cls):
    """"""
    for s in cls.__subclasses__():
      yield s
      for c in s.all_subclasses():
        yield c
209898
def generator(self,gen,*args,**kwargs):
        
        with self(*args,**kwargs):
            for i in gen:
                yield i
822310
def satisfy_all(self, **params):
        """"""
        verbosity = params.get('verbosity', 0)
        default_phase = params.get('default_phase', 2)
        propagation_limit = params.get('propagation_limit', -1)
        decision_limit = params.get('decision_limit', -1)
        seed = params.get('seed', 1)
        yield from picosat.satisfy_all(self.nvars, self.clauses, verbosity,
                                       default_phase, propagation_limit,
                                       decision_limit, seed)
773572
def just(*args):
    ''' 
    '''
    assert len(args) >= 1, 'generators.just needs at least one arg'

    if len(args) == 1: # if only one arg is given
        try:
            # try to cycle in a set for iteration speedup
            return cycle(set(args))
        except:
            # revert to cycling args as a tuple
            return cycle(args)
    else:
        return cycle({args})
104263
def all_generators(self):
        
        for arg_gen in self.arg_gens:
            yield arg_gen

        for kwarg_gen in self.kwarg_gens.values():
            yield kwarg_gen