Creates a :class:`~chess.Piece` instance from a piece symbol.

        :raises: :exc:`ValueError` if the symbol is invalid.
340587
def from_symbol(cls, symbol: str) -> "Piece":
        
        return cls(PIECE_SYMBOLS.index(symbol.lower()), symbol.isupper())
18724
def invalidate_value(
        cls,
        value: Any,
        exc: Type[Exception]=EncodingTypeError,
        msg: Optional[str]=None,
    ) -> None:
        
        raise exc(
            "Value `{rep}` of type {typ} cannot be encoded by {cls}{msg}".format(
                rep=abbr(value),
                typ=type(value),
                cls=cls.__name__,
                msg="" if msg is None else (": " + msg),
            )
        )
735595
def from_proto_dict(proto_dict: Dict) -> 'GridQubit':
        """"""
        if 'row' not in proto_dict or 'col' not in proto_dict:
            raise ValueError(
                'Proto dict does not contain row or col: {}'.format(proto_dict))
        return GridQubit(row=proto_dict['row'], col=proto_dict['col'])
909610
def from_untrusted(cls, value, lineno=None, environment=None):
        
        from .compiler import has_safe_repr
        if not has_safe_repr(value):
            raise Impossible()
        return cls(value, lineno=lineno, environment=environment)
344352
def from_binary(self, d):
    
    p = MsgEphemerisGPSDepF._parser.parse(d)
    for n in self.__class__.__slots__:
      setattr(self, n, getattr(p, n))
230195
def val(self, piece, ref_color):
        
        if piece is None:
            return 0

        if ref_color == piece.color:
            const = 1
        else:
            const = -1

        if isinstance(piece, Pawn):
            return self.PAWN_VALUE * const
        elif isinstance(piece, Queen):
            return self.QUEEN_VALUE * const
        elif isinstance(piece, Bishop):
            return self.BISHOP_VALUE * const
        elif isinstance(piece, Rook):
            return self.ROOK_VALUE * const
        elif isinstance(piece, Knight):
            return self.KNIGHT_VALUE * const
        elif isinstance(piece, King):
            return self.KING_VALUE * const
        return 0
124443
def symbol(self) -> str:
        
        symbol = piece_symbol(self.piece_type)
        return symbol.upper() if self.color else symbol
880687
def from_hex(cls, value):
        """"""
        if len(value) == 8:
            return cls(int(value, 16))
        elif len(value) == 32:
            return cls(int(value, 16))
        else:
            raise ValueError('%r: invalid hexadecimal notation' % (value,))
38817
def _make_value(self, value):
        """"""
        member = self.__new__(self, value)
        member.__init__(value)
        return member
1098905
def uci(self, move: Move, *, chess960: Optional[bool] = None) -> str:
        
        if chess960 is None:
            chess960 = self.chess960

        move = self._to_chess960(move)
        move = self._from_chess960(chess960, move.from_square, move.to_square, move.promotion, move.drop)
        return move.uci()
1075234
def from_chess960_pos(cls: Type[BaseBoardT], sharnagl: int) -> BaseBoardT:
        
        board = cls.empty()
        board.set_chess960_pos(sharnagl)
        return board
1290747
def symbols_to_prob(symbols):
    '''
    
    '''
    myCounter = Counter(symbols)

    N = float(len(list(symbols)))   # symbols might be a zip object in python 3

    for k in myCounter:
        myCounter[k] /= N

    return myCounter
914999
def from_dict(cls, d):
        
        defect = MontyDecoder().process_decoded( d["defect"])
        uncorrected_energy = d["uncorrected_energy"]
        corrections = d.get("corrections", None)
        parameters = d.get("parameters", None)
        entry_id = d.get("entry_id", None)

        return cls(defect, uncorrected_energy, corrections=corrections,
                   parameters=parameters, entry_id=entry_id)
331011
def node(self):
        

        if self.node_class is None:
            raise ValueError("You have to create an ``Item`` by calling ``__init__`` with ``node_class`` argument"
                             " or by decorating a ``Node`` class.")

        node = self.node_class(*self.node_args, **self.node_kwargs)
        node.__item__ = self

        return node
434762
def from_simple_str(cls, s):
        
        if not isinstance(s, str):
            raise TypeError("Expected an str instance, received %r" % (s,))
        return cls(cls.bits_from_simple_str(s))
513427
def from_dict(cls, d):
        
        atoms_n_occu = {}
        for sp_occu in d["species"]:
            if "oxidation_state" in sp_occu and Element.is_valid_symbol(
                    sp_occu["element"]):
                sp = Specie.from_dict(sp_occu)
            elif "oxidation_state" in sp_occu:
                sp = DummySpecie.from_dict(sp_occu)
            else:
                sp = Element(sp_occu["element"])
            atoms_n_occu[sp] = sp_occu["occu"]
        props = d.get("properties", None)
        return cls(atoms_n_occu, d["xyz"], properties=props)
19909
def from_epsg(cls, code):
        
        if int(code) <= 0:
            raise ValueError("EPSG codes are positive integers")
        return cls({'init': "epsg:{}".format(code), 'no_defs': True})