Commit 428b2f62 authored by Nathan Frey's avatar Nathan Frey
Browse files

complex featurizer output fix

parent 7ed0125d
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -174,12 +174,13 @@ class ComplexFeaturizer(Featurizer):

    if not isinstance(complexes, Iterable):
      complexes = [cast(Tuple[str, str], complexes)]
    features, failures = [], []
    features, failures, successes = [], [], []
    for idx, point in enumerate(complexes):
      if idx % log_every_n == 0:
        logger.info("Featurizing datapoint %i" % idx)
      try:
        features.append(self._featurize(point))
        successes.append(idx)
      except:
        logger.warning(
            "Failed to featurize datapoint %i. Appending empty array." % idx)
@@ -187,10 +188,13 @@ class ComplexFeaturizer(Featurizer):
        failures.append(idx)

    # Find a successful featurization
    try:
      i = np.argmax([f.shape[0] for f in features])
      dtype = features[i].dtype
      shape = features[i].shape
      dummy_array = np.zeros(shape, dtype=dtype)
    except AttributeError:
      dummy_array = features[successes[0]]

    # Replace failed featurizations with appropriate array
    for idx in failures:
+445 −1

File changed.

Preview size limit exceeded, changes collapsed.