Commit 77695d5f authored by alat-rights's avatar alat-rights
Browse files

Minor bug fix

parent 66389eca
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ ZINC_CHARSET = [
    'n', 'p', 's', 'r'
]


class OneHotFeaturizer(MolecularFeaturizer):
  """Encodes SMILES as a one-hot array.

@@ -139,7 +140,7 @@ class OneHotFeaturizer(MolecularFeaturizer):
    str
      SMILES string space padded to self.pad_length
    """
    return pad_string(smiles)
    return self.pad_string(smiles)

  def pad_string(self, string: str) -> str:
    """Pad string to `self.pad_length`
+10 −5
Original line number Diff line number Diff line
@@ -97,9 +97,14 @@ class TestOneHotFeaturizert(unittest.TestCase):
    string = "12345"
    featurizer = OneHotFeaturizer(charset=charset, max_length=100)
    feature = featurizer([string])
    assert np.allclose(feature[0][0], np.array([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]))
    assert np.allclose(feature[0][1], np.array([0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]))
    assert np.allclose(feature[0][2], np.array([0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]))
    assert np.allclose(feature[0][3], np.array([0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]))
    assert np.allclose(feature[0][4], np.array([0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]))
    assert np.allclose(feature[0][0],
                       np.array([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]))
    assert np.allclose(feature[0][1],
                       np.array([0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]))
    assert np.allclose(feature[0][2],
                       np.array([0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]))
    assert np.allclose(feature[0][3],
                       np.array([0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]))
    assert np.allclose(feature[0][4],
                       np.array([0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]))
    assert "This test case has not yet been written."