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: Compute one-hot featurization of string.
  
  Parameters
  ----------
  string: str
      An arbitrary string to be featurized.
  
  Returns
  -------
  np.ndarray
      An one hot vector encoded from arbitrary input string.
      The shape is `(max_length, len(charset) + 1)`.
      The index of unknown character is `len(charset)`.
docstr_tok: ["Compute","one-hot","featurization","of","string",".","Parameters","--","--","--","--","--","string",":","str","An","arbitrary","string","to","be","featurized",".","Returns","--","--","--","-","np.ndarray","An","one","hot","vector","encoded","from","arbitrary","input","string",".","The","shape","is","`","(","max_length",",","len","(","charset",")","+","1",")","`",".","The","index","of","unknown","character","is","`","len","(","charset",")","`","."]
code: def _featurize_string(self, string: str) -> np.ndarray:
      """Compute one-hot featurization of string.
  
      Parameters
      ----------
      string: str
          An arbitrary string to be featurized.
  
      Returns
      -------
      np.ndarray
          An one hot vector encoded from arbitrary input string.
          The shape is `(max_length, len(charset) + 1)`.
          The index of unknown character is `len(charset)`.
  
      """
      if isinstance(self.max_length, int):
          if len(string) > self.max_length:  # Validation
              raise ValueError(
                  "The length of {} is longer than `max_length`."
              )
          string = self.pad_string(string)  # Padding
  
      return np.array(
          [
              one_hot_encode(
                  val, self.charset, include_unknown_set=True
              )
              for val in string
          ]
      )
  
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 4 for calling the OneHotFeaturizer obj's underlying member method code with example usage: obj._featurize_string(string) and returns: np