Skip to main content
`Ctrl`+`K`

# cogent3.core.alphabet.bytes_to_array

class bytes_to_array(chars: bytes, dtype: type[unsignedinteger], delete: bytes | None = None, dest: bytes | None = None)

  wrapper around convert_alphabet. It defines a linear mapping from provided characters to uint8. The resulting object is callable, taking a bytes object and returning a numpy array.

  Methods

  `__call__`(seq) | Call self as a function.

  __init__(chars: bytes, dtype: type[unsignedinteger], delete: bytes | None = None, dest: bytes | None = None) → None
    Parameters:
      chars

        series of characters in the source alphabet

      delete

        characters to be deleted from the result

      dest

        destination bytes that `chars` are mapped to. If None (the default), uses `bytes(bytearray(range(len(chars))))` and requires `chars` to be unique. If provided, must have the same length as `chars`; duplicates in `chars` are permitted so callers can collapse multiple source characters (eg case variants) onto the same index.

  Methods

  `__init__`(chars, dtype[, delete, dest]) |