Parses a move in UCI notation and puts it on the move stack.

        Returns the move.

        :raises: :exc:`ValueError` if the move is invalid or illegal in the
            current position (but not a null move).
15990
def push_uci(self, uci: str) -> Move:
        
        move = self.parse_uci(uci)
        self.push(move)
        return move
1043314
def parse_motion_state(val):
        """"""
        number = val & 0b00111111
        unit = (val & 0b11000000) >> 6
        if unit == 1:
            number *= 60 # minutes
        elif unit == 2:
            number *= 60 * 60 # hours
        elif unit == 3 and number < 32:
            number *= 60 * 60 * 24 # days
        elif unit == 3:
            number -= 32
            number *= 60 * 60 * 24 * 7 # weeks
        return number
184939
def parse(cls, format):
        

        fmt = cls()

        # Return an empty Format if format is empty
        if not format:
            return fmt

        # Initialize the state for parsing
        state = ParseState(fmt, format)

        # Loop through the format string with a state-based parser
        for idx, char in enumerate(format):
            # Some characters get ignored
            if state.check_ignore():
                continue

            if state == 'string':
                if char == '%':
                    # Handle '%%'
                    if format[idx:idx + 2] == '%%':
                        # Add one % to the string context
                        state.add_text(idx + 1, idx + 2)
                        state.set_ignore(1)
                    else:
                        state.add_text(idx)
                        state.conversion(idx)
                elif char == '\\':
                    state.add_text(idx)
                    state.escape(idx)
            elif state == 'escape':
                state.add_escape(idx + 1, char)
                state.pop_state(idx + 1)
            elif state == 'param':
                if char == '}':
                    state.set_param(idx)
                    state.pop_state()
            elif state == 'conv':
                if char == ')':
                    state.set_conversion(idx)
                    state.pop_state()  # now in 'conversion'
                    state.pop_state(idx + 1)  # now in 'string'
            else:  # state == 'conversion'
                if char in '<>':
                    # Allowed for Apache compatibility, but ignored
                    continue
                elif char == '!':
                    state.set_reject()
                    continue
                elif char == ',' and state.code_last:
                    # Syntactically allowed ','
                    continue
                elif char.isdigit():
                    # True if the code is valid
                    if state.set_code(idx):
                        continue
                elif char == '{' and state.param_begin is None:
                    state.param(idx + 1)
                    continue
                elif char == '(' and state.conv_begin is None:
                    state.conv(idx + 1)
                    continue

                # OK, we have a complete conversion
                state.set_conversion(idx)
                state.pop_state(idx + 1)

        # Finish the parse and return the completed format
        return state.end_state()
951974
def parse(bin_payload):
    
    
    if len(bin_payload) != LENGTHS['name_consensus_hash'] + LENGTHS['value_hash']:
        log.error("Invalid update length %s" % len(bin_payload))
        return None 

    name_consensus_hash_bin = bin_payload[:LENGTHS['name_consensus_hash']]
    value_hash_bin = bin_payload[LENGTHS['name_consensus_hash']:]
    
    name_consensus_hash = hexlify( name_consensus_hash_bin )
    value_hash = hexlify( value_hash_bin )
  
    try:
        rc = update_sanity_test( None, name_consensus_hash, value_hash )
        if not rc:
            raise Exception("Invalid update data")
    except Exception, e:
        log.error("Invalid update data")
        return None

    return {
        'opcode': 'NAME_UPDATE',
        'name_consensus_hash': name_consensus_hash,
        'value_hash': value_hash
    }
515467
def parse_san(self, board: chess.Board, san: str) -> chess.Move:
        
        # Replace zeros with correct castling notation.
        if san == "0-0":
            san = "O-O"
        elif san == "0-0-0":
            san = "O-O-O"

        return board.parse_san(san)
827005
def move(self, d, add_tile=True):
        
        if d == Board.LEFT or d == Board.RIGHT:
            chg, get = self.setLine, self.getLine
        elif d == Board.UP or d == Board.DOWN:
            chg, get = self.setCol, self.getCol
        else:
            return 0

        moved = False
        score = 0

        for i in self.__size_range:
            # save the original line/col
            origin = get(i)
            # move it
            line = self.__moveLineOrCol(origin, d)
            # merge adjacent tiles
            collapsed, pts = self.__collapseLineOrCol(line, d)
            # move it again (for when tiles are merged, because empty cells are
            # inserted in the middle of the line/col)
            new = self.__moveLineOrCol(collapsed, d)
            # set it back in the board
            chg(i, new)
            # did it change?
            if origin != new:
                moved = True
            score += pts

        # don't add a new tile if nothing changed
        if moved and add_tile:
            self.addTile()

        return score
1262714
def possible_moves(self, position):
        
        for direction in [0, 1, 2, 3]:
            angles = self._rotate_direction_ninety_degrees(direction)
            for angle in angles:
                try:
                    end_loc = self.location.shift(angle).shift(direction).shift(direction)
                    if position.is_square_empty(end_loc):
                        status = notation_const.MOVEMENT
                    elif not position.piece_at_square(end_loc).color == self.color:
                        status = notation_const.CAPTURE
                    else:
                        continue

                    yield Move(end_loc=end_loc,
                               piece=self,
                               status=status,
                               start_loc=self.location)

                except IndexError:
                    pass
1036164
def stack_push(self, value: Union[int, bytes]) -> None:
        
        return self._stack.push(value)
452318
def steps(current, target, max_steps):
    
    if current < 0 or current > 1.0:
        raise ValueError("current value %s is out of bounds (0.0-1.0)", current)
    if target < 0 or target > 1.0:
        raise ValueError("target value %s is out of bounds (0.0-1.0)", target)
    return int(abs((current * max_steps) - (target * max_steps)))
75012
def expand_move(m)
      if match = m.match(Chess::MOVE_REGEXP)
        expand = {
          name: match[1] || 'P',    # Piece name [RNBQK]
          dis: match[2],            # Disambiguating move
          to: match[3],             # Move to
          promotion: match[4],      # Promote with
        }
        expand[:from] = match[2] if match[2] && match[2].size == 2
        return expand
      elsif m =~ SHORT_CASTLING_REGEXP
        if self.board.active_color # black king short castling
          return { name: 'K', dis: nil, from: 'e8', to: 'g8', promotion: nil }
        else # white king short castling
          return { name: 'K', dis: nil, from: 'e1', to: 'g1', promotion: nil }
        end
      elsif m =~ LONG_CASTLING_REGEXP
        if self.board.active_color # black king long castling
          return { name: 'K', dis: nil, from: 'e8', to: 'c8', promotion: nil }
        else # white king long castling
          return { name: 'K', dis: nil, from: 'e1', to: 'c1', promotion: nil }
        end
      end
      raise BadNotationError.new(m)
    end
348908
def _update_valid_moves(self):
        '''
        
        '''
        left_end = self.board.left_end()
        right_end = self.board.right_end()

        moves = []
        for d in self.hands[self.turn]:
            if left_end in d:
                moves.append((d, True))
            # do not double count moves if both of the board's ends have
            # the same value, and a domino can be placed on both of them
            if right_end in d and left_end != right_end:
                moves.append((d, False))

        self.valid_moves = tuple(moves)
930779
def handle_translocation_illegal(self, line: str, position: int, tokens: ParseResults) -> None:
        """"""
        raise MalformedTranslocationWarning(self.get_line_number(), line, position, tokens)
7780
def gnuchess_move
      pipe = IO.popen('gnuchess -x', 'r+')
      begin
        pipe.puts('depth 1')
        pipe.puts('manual')
        self.coord_moves.each do |m|
          pipe.puts(m)
        end
        pipe.puts('go')
        while line = pipe.gets
          raise IllegalMoveError if line.include?('Invalid move')
          match = line.match(/My move is : ([a-h][1-8][a-h][1-8][rkbq]?)/)
          return match[1] if match
        end
      ensure
        pipe.puts('quit')
        pipe.close
      end
      return moves
    end
964231
def _parse_mut(mut):
    
    multiplier = 1
    if mut.startswith("-"):
        mut = mut[1:]
        multiplier = -1
    nt = mut.strip('0123456789')
    pos = int(mut[:-2]) * multiplier
    return nt, pos
1317692
def parse_value(val, parsebool=False):
    
    try:
        return int(val)
    except ValueError:
        pass
    try:
        return float(val)
    except:
        pass
    if parsebool:
        if re.match('yes|on', str(val), re.IGNORECASE):
            return True
        elif re.match('no|off', str(val), re.IGNORECASE):
            return False
    return val
372181
def parse_column(column):
    
    try:
        float_attempt = [float(i) for i in column]
    except ValueError:
        return column
    else:
        try:
            int_attempt = [int(j) for j in column]
        except ValueError:
            return float_attempt
        else:
            return int_attempt
627183
def callable(cls, nans=False, reverse=False, scalar=False):
        
        _valgetter = cls._valgetter_scalar if scalar else cls._valgetter
        valgetter = nb.njit(_valgetter)
        outersetter = nb.njit(cls._outersetter)

        _cls_inner = nb.njit(cls._inner)
        if nans:
            def _inner(ri, val, ret, counter, mean):
                if not np.isnan(val):
                    _cls_inner(ri, val, ret, counter, mean)
            inner = nb.njit(_inner)
        else:
            inner = _cls_inner

        def _loop(group_idx, a, ret, counter, mean, outer, fill_value, ddof):
            # fill_value and ddof need to be present for being exchangeable with loop_2pass
            size = len(ret)
            rng = range(len(group_idx) - 1, -1 , -1) if reverse else range(len(group_idx))
            for i in rng:
                ri = group_idx[i]
                if ri < 0:
                    raise ValueError("negative indices not supported")
                if ri >= size:
                    raise ValueError("one or more indices in group_idx are too large")
                val = valgetter(a, i)
                inner(ri, val, ret, counter, mean)
                outersetter(outer, i, ret[ri])
        return nb.njit(_loop, nogil=True)