Internal: Finds the pivot state between the receiver and the given state. The pivot state is the first common ancestor between the two states.  Returns a `State` object. Throws `Error` if the two states do not belong to the same statechart.
165514
function findPivot(other) {
    var p1 = _path.call(this), p2 = _path.call(other), i, len, p;

    for (i = 0, len = p1.length < p2.length ? p1.length : p2.length; i < len; i++) {
      if (p1[i] === p2[i]) { p = p1[i]; } else { break; }
    }

    if (!p) {
      throw new Error('State#findPivot: states ' + this + ' and ' + other + ' do not belong to the same statechart');
    }

    return p;
  }
612702
private PlayState1 findPlayState1() {
        PlayState1 result = PLAY_STATE_1_MAP.get(packetBytes[123]);
        if (result == null) {
            return PlayState1.UNKNOWN;
        }
        return result;
    }
592444
function findInstance(state, stateKey, instanceKey, payload) {
    return state[stateKey].find(obj => obj[instanceKey] === payload[instanceKey]);
}
16769
function(state) {
            // Check if state has explicit parent OR we try guess parent from its name
            var parent = state.parent || (/^(.+)\.[^.]+$/.exec(state.name) || [])[1];
            var isObjectParent = typeof parent === "object";
            // if parent is a object reference, then extract the name
            return isObjectParent ? parent.name : parent;
        }
879435
private Map<Transition<A, S>, N> predecessorsMap(S current){
        //Map<Transition, Node> containing predecessors relations
        Map<Transition<A, S>, N> mapPredecessors = new HashMap<Transition<A, S>, N>();
        //Fill with non-null pairs of <Transition, Node>
        for (Transition<A, S> predecessor : predecessorFunction.transitionsFrom(current)) {
            N predecessorNode = visited.get(predecessor.getState());
            if (predecessorNode != null) {
                mapPredecessors.put(predecessor, predecessorNode);
            }
        }
        return mapPredecessors;
    }
229915
private State getNextState(State state) {

        State nextState = null;
        switch (state) {
            case off:
                nextState = State.on;
                break;
            case on:
                nextState = State.off;
                break;
            case middle:
            default:
                nextState = m_nextStateAfterMiddle;
        }
        return nextState;
    }
1107761
def step_state(self, state, successor_func=None, **run_args):
        
        try:
            successors = self.successors(state, successor_func=successor_func, **run_args)
            stashes = {None: successors.flat_successors,
                       'unsat': successors.unsat_successors,
                       'unconstrained': successors.unconstrained_successors}

        except (SimUnsatError, claripy.UnsatError) as e:
            if self._hierarchy:
                self._hierarchy.unreachable_state(state)
                self._hierarchy.simplify()
            stashes = {'pruned': [state]}

        except tuple(self._resilience) as e:
            self._errored.append(ErrorRecord(state, e, sys.exc_info()[2]))
            stashes = {}

        return stashes
409569
def p_state(self, state):
        ''''''
        state[0] = State(state[1][0], state[1][1], state[1][2], state[1][3], state[2])
586253
function(previousState, event) {
    var state = {};
    state.center = getCenter(event.targetTouches);
    state.pointers = [];
    for (var i = 0; i < event.targetTouches.length; ++i) {
      var t = event.targetTouches[i];
      state.pointers.push({ x: t.clientX, y : t.clientY });
    }
    state.numTouches = event.targetTouches.length;
    state.rotation = 0;
    state.scale = 1.0;
    state.deltaScale = 0.0;
    state.deltaRotation = 0.0;

    if (previousState.center) {
      state.deltaCenter = {
        x : state.center.x - previousState.center.x, 
        y : state.center.y - previousState.center.y
      };
    }

    if (previousState.numTouches !== 2 || state.numTouches !== 2) {
      return state;
    }
    if (previousState.initialPointers) {
      state.initialPointers = previousState.initialPointers;
    } else {
      state.initialPointers = previousState.pointers;
    }

    state.scale = getScale(state.initialPointers, state.pointers);
    state.deltaScale = state.scale - previousState.scale;
    state.rotation = getRotationAngle(state.initialPointers, state.pointers);
    state.deltaRotation = state.rotation - previousState.rotation;
    return state;
  }
679759
def cartesian(n, states):
    
    length = 1. / n  # arm_length
    pos_x = hstack((states[0], zeros(n)))
    pos_y = zeros(n + 1)
    for j in arange(1, n + 1):
        pos_x[j] = pos_x[j - 1] + length * cos(states[j])
        pos_y[j] = pos_y[j - 1] + length * sin(states[j])
    pos = hstack((pos_x, pos_y))
    return pos
171422
def event(from_states=None, to_state=None):
    
    from_states_tuple = (from_states, ) if isinstance(from_states, State) else tuple(from_states or [])
    if not len(from_states_tuple) >= 1:
        raise ValueError()
    if not all(isinstance(state, State) for state in from_states_tuple):
        raise TypeError()
    if not isinstance(to_state, State):
        raise TypeError()

    def wrapper(wrapped):

        @functools.wraps(wrapped)
        def transition(instance, *a, **kw):
            if instance.current_state not in from_states_tuple:
                raise InvalidStateTransition()
            try:
                result = wrapped(instance, *a, **kw)
            except Exception as error:
                error_handlers = getattr(instance, '___pystatemachine_transition_failure_handlers', [])
                for error_handler in error_handlers:
                    error_handler(instance, wrapped, instance.current_state, to_state, error)
                if not error_handlers:
                    raise error
            else:
                StateInfo.set_current_state(instance, to_state)
                return result

        return transition

    return wrapper
951822
def prev_position(self, pos):
        """"""
        candidate = None
        if pos is not None:
            prevsib = self.prev_sibling_position(pos)  # is None if first
            if prevsib is not None:
                candidate = self.last_decendant(prevsib)
            else:
                parent = self.parent_position(pos)
                if parent is not None:
                    candidate = parent
        return candidate
434702
function(state) {
      if (state.parent && state.parent.data) {
        state.data = state.self.data = extend({}, state.parent.data, state.data);
      }
      return state.data;
    }
152908
int nextState(int state, int input, int bufPos) {
    switch (state) {
    case CDATA_UNK:
    case CDATA_OUT:
      switch (input) {
      case CDATA_BEGIN:
        return CDATA_IN;
      case CDATA_END:
        if (state == CDATA_OUT) {
          //System.out.println("buggy XML " + bufPos);
        }
        return CDATA_OUT;
      case RECORD_MAYBE:
        return (state == CDATA_UNK) ? CDATA_UNK : RECORD_ACCEPT;
      }
      break;
    case CDATA_IN:
      return (input == CDATA_END) ? CDATA_OUT : CDATA_IN;
    }
    throw new IllegalStateException(state + " " + input + " " + bufPos + " " + splitName_);
  }
1250374
def initialState(self, state):
        

        if self._initialState is not _NO_STATE:
            raise ValueError(
                "initial state already set to {}".format(self._initialState))

        self._initialState = state
95023
def previous(self):
        
        return self.model.state.get_entity(
            self.entity_type, self.entity_id, self._history_index - 1,
            connected=False)
1269003
def select_action(self, state):
    
    value = 0
    if self.steps < self.min_steps:
      action = np.random.randint(self.actions)
    else:
      self.eps = max(self.eps_end, self.eps * self.eps_decay)
      if random.random() < self.eps:
        action = np.random.randint(self.actions)
      else:
        self.local.eval()
        with torch.no_grad():
          state = torch.tensor(state, device=self.device, dtype=torch.float).unsqueeze(0)
          Q = self.local(state)
          value, action = torch.max(Q, 1)

    return int(action), float(value)