Commit 0b9a0cb5 authored by Milosz Grabski's avatar Milosz Grabski
Browse files

workaround flake8 E125/ yapf issue

parent 255d1574
Loading
Loading
Loading
Loading
+31 −38
Original line number Diff line number Diff line
@@ -90,18 +90,18 @@ class test_molgan_model(unittest.TestCase):
                           [x.node_features for x in featurized])
    valid_attempts = 0
    for _ in range(10):
      # try to catch tensorflow internal errors
      try:
      # force clear tensor flow backend
      keras_clear_session()
      # create new model
      gan = MolGAN(learning_rate=ExponentialDecay(0.001, 0.9, 5000))

      # to avoid flake8 E125/yapf incompatibility
      s = gan.batch_size

      # generate input
      def iterbatches(epochs):
        for __ in range(epochs):
            for batch in dataset.iterbatches(
                    batch_size=gan.batch_size, pad_batches=True):
          for batch in dataset.iterbatches(batch_size=s, pad_batches=True):
            adjacency_tensor = one_hot(batch[0], gan.edges)
            node_tesor = one_hot(batch[1], gan.nodes)

@@ -111,8 +111,7 @@ class test_molgan_model(unittest.TestCase):
            }

      # train model
        gan.fit_gan(
            iterbatches(1000), generator_steps=0.2, checkpoint_interval=0)
      gan.fit_gan(iterbatches(1000), generator_steps=0.2, checkpoint_interval=0)

      # generate sample
      g = gan.predict_gan_generator(1000)
@@ -122,12 +121,6 @@ class test_molgan_model(unittest.TestCase):
          list(filter(lambda x: x is not None, generated_molecules)))
      if valid_molecules_count:
        valid_attempts = valid_attempts + 1
      except InternalError:
        print(
            'Tensor flow internal error raised. Make sure no other instance of tensorflow e.g. jupyter notebook, is running.'
        )
        break

    assert valid_attempts > 0