Unverified Commit 281a1e05 authored by Karl Leswing's avatar Karl Leswing Committed by GitHub
Browse files

Merge pull request #1113 from nitinprakash96/master

add logger instead of print statements
parents e8a77b2d 3b13e80f
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -21,7 +21,9 @@ install:
script:
- nosetests --with-flaky -a '!slow' --with-timer --with-coverage --cover-package=deepchem
  -v deepchem --nologcapture
- find ./deepchem | grep .py$ |xargs python -m doctest -v
- if [ $TRAVIS_PYTHON_VERSION == '3.5']; then
      find ./deepchem | grep .py$ |xargs python -m doctest -v;
  fi
- bash devtools/travis-ci/test_format_code.sh
after_success:
- echo $TRAVIS_SECURE_ENV_VARS
+1 −2
Original line number Diff line number Diff line
"""
Imports all submodules
"""
from __future__ import print_function
from __future__ import division
from __future__ import unicode_literals

+0 −1
Original line number Diff line number Diff line
"""
Process an input dataset into a format suitable for machine learning.
"""
from __future__ import print_function
from __future__ import division
from __future__ import unicode_literals
import os
+9 −10
Original line number Diff line number Diff line
"""
Contains wrapper class for datasets.
"""
from __future__ import print_function
from __future__ import division
from __future__ import unicode_literals
import json
@@ -200,9 +199,9 @@ class Dataset(object):

    >>> dataset = NumpyDataset(np.ones((2,2)))
    >>> for x, y, w, id in dataset.itersamples():
    ...   print(x, y, w, id)
    [1. 1.] [0.] [0.] 0
    [1. 1.] [0.] [0.] 1
    ...   print(x.tolist(), y.tolist(), w.tolist(), id)
    [1.0 1.0] [0.0] [0.0] 0
    [1.0 1.0] [0.0] [0.0] 1
    """
    raise NotImplementedError()

@@ -409,9 +408,9 @@ class NumpyDataset(Dataset):

    >>> dataset = NumpyDataset(np.ones((2,2)))
    >>> for x, y, w, id in dataset.itersamples():
    ...   print(x, y, w, id)
    [1. 1.] [0.] [0.] 0
    [1. 1.] [0.] [0.] 1
    ...   print(x.tolist(), y.tolist(), w.tolist(), id)
    [1.0 1.0] [0.0] [0.0] 0
    [1.0 1.0] [0.0] [0.0] 1
    """
    n_samples = self._X.shape[0]
    return ((self._X[i], self._y[i], self._w[i], self._ids[i])
@@ -889,9 +888,9 @@ class DiskDataset(Dataset):

    >>> dataset = DiskDataset.from_numpy(np.ones((2,2)), np.ones((2,1)), verbose=False)
    >>> for x, y, w, id in dataset.itersamples():
    ...   print(x, y, w, id)
    [1. 1.] [1.] [1.] 0
    [1. 1.] [1.] [1.] 1
    ...   print(x.tolist(), y.tolist(), w.tolist(), id)
    [1.0 1.0] [0.0] [0.0] 0
    [1.0 1.0] [0.0] [0.0] 1
    """

    def iterate(dataset):
+9 −7
Original line number Diff line number Diff line
"""
Sample supports from datasets.
"""
from __future__ import print_function
from __future__ import division
from __future__ import unicode_literals

import logging
import time
import numpy as np
from deepchem.data import NumpyDataset

logger = logging.getLogger(__name__)


def remove_dead_examples(dataset):
  """Removes compounds with no weight.
@@ -133,7 +135,7 @@ def get_task_test(dataset, n_episodes, n_test, task, log_every_n=50):
  tests = []
  for episode in range(n_episodes):
    if episode % log_every_n == 0:
      print("Sampling test %d" % episode)
      logger.info("Sampling test %d" % episode)
    inds = ids[episode]
    X_batch = X_task[inds]
    y_batch = np.squeeze(y_task[inds, task])
@@ -221,7 +223,7 @@ def get_task_support(dataset, n_episodes, n_pos, n_neg, task, log_every_n=50):
  supports = []
  for episode in range(n_episodes):
    if episode % log_every_n == 0:
      print("Sampling support %d" % episode)
      logger.info("Sampling support %d" % episode)
    # No replacement allowed for supports
    pos_ids = np.random.choice(len(pos_mols), (n_pos,), replace=False)
    neg_ids = np.random.choice(len(neg_mols), (n_neg,), replace=False)
@@ -285,7 +287,7 @@ class EpisodeGenerator(object):
    self.task_num = 0
    self.trial_num = 0
    time_end = time.time()
    print("Constructing EpisodeGenerator took %s seconds" %
    logger.info("Constructing EpisodeGenerator took %s seconds" %
                str(time_end - time_start))

  def __iter__(self):
Loading