class_docstr: Encodes any arbitrary string or molecule as a one-hot array.
  
  This featurizer encodes the characters within any given string as a one-hot
  array. It also works with RDKit molecules: it can convert RDKit molecules to
  SMILES strings and then one-hot encode the characters in said strings.
  
  Standalone Usage:
  
  >>> import deepchem as dc
  >>> featurizer = dc.feat.OneHotFeaturizer()
  >>> smiles = ['CCC']
  >>> encodings = featurizer.featurize(smiles)
  >>> type(encodings[0])
  <class 'numpy.ndarray'>
  >>> encodings[0].shape
  (100, 35)
  >>> featurizer.untransform(encodings[0])
  'CCC'
  
  Note
  ----
  This class needs RDKit to be installed in order to accept RDKit molecules as
  inputs.
  
  It does not need RDKit to be installed to work with arbitrary strings.
class_docstr_tok: ["Encodes","any","arbitrary","string","or","molecule","as","a","one-hot","array",".","This","featurizer","encodes","the","characters","within","any","given","string","as","a","one-hot","array",".","It","also","works","with","RDKit","molecules",":","it","can","convert","RDKit","molecules","to","SMILES","strings","and","then","one-hot","encode","the","characters","in","said","strings",".","Standalone","Usage",":",">",">",">","import","deepchem","as","dc",">",">",">","featurizer","=","dc.feat.OneHotFeaturizer","(",")",">",">",">","smiles","=","[","'CCC","'","]",">",">",">","encodings","=","featurizer.featurize","(","smiles",")",">",">",">","type","(","encodings","[","0","]",")","<","class","'numpy.ndarray","'",">",">",">",">","encodings","[","0","]",".shape","(","100",",","35",")",">",">",">","featurizer.untransform","(","encodings","[","0","]",")","'CCC'","Note","--","--","This","class","needs","RDKit","to","be","installed","in","order","to","accept","RDKit","molecules","as","inputs",".","It","does","not","need","RDKit","to","be","installed","to","work","with","arbitrary","strings","."]
docstr: Initialize featurizer.
  
  Parameters
  ----------
  charset: List[str] (default ZINC_CHARSET)
      A list of strings, where each string is length 1 and unique.
  max_length: Optional[int], optional (default 100)
      The max length for string. If the length of string is shorter than
      max_length, the string is padded using space.
  
  If max_length is None, no padding is performed and arbitrary length
  strings are allowed.
docstr_tok: ["Initialize","featurizer",".","Parameters","--","--","--","--","--","charset",":","List","[","str","]","(","default","ZINC_CHARSET",")","A","list","of","strings",",","where","each","string","is","length","1","and","unique",".","max_length",":","Optional","[","int","]",",","optional","(","default","100",")","The","max","length","for","string",".","If","the","length","of","string","is","shorter","than","max_length",",","the","string","is","padded","using","space",".","If","max_length","is","None",",","no","padding","is","performed","and","arbitrary","length","strings","are","allowed","."]
code: def __init__(
      self,
      charset: List[str] = ZINC_CHARSET,
      max_length: Optional[int] = 100,
  ):
      """Initialize featurizer.
  
      Parameters
      ----------
      charset: List[str] (default ZINC_CHARSET)
          A list of strings, where each string is length 1 and unique.
      max_length: Optional[int], optional (default 100)
          The max length for string. If the length of string is shorter than
          max_length, the string is padded using space.
  
      If max_length is None, no padding is performed and arbitrary length
      strings are allowed.
      """
      if len(charset) != len(set(charset)):
          raise ValueError("All values in charset must be unique.")
      self.charset = charset
      self.max_length = Optional[int]
      if max_length is not None:
          self.max_length = int(max_length)
      else:
          self.max_length = None
  
file_path: deepchem/deepchem/feat/molecule_featurizers/one_hot_featurizer.py
imports: import logging
  from typing import List
  import numpy
  from deepchem.utils.typing import RDKitMol
  from deepchem.utils.molecule_feature_utils import one_hot_encode
  from deepchem.feat.base_classes import Featurizer
  from typing import Any, Iterable, Optional
label_desc: Use image node_id 1 to create a new OneHotFeaturizer object from inherited base classes: Featurizer with example: obj = OneHotFeaturizer(charset, max_length)