Unverified Commit 9ce7a2a4 authored by Bharath Ramsundar's avatar Bharath Ramsundar Committed by GitHub
Browse files

Merge pull request #2197 from micimize/examples_to_docs

sampl model examples to docs/examples.rst
parents cbab8a8e f1d98479
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -99,3 +99,5 @@ datasets/pdbbind_v2019_PP.tar.gz
datasets/pdbbind_v2019_other_PL.tar.gz
datasets/pdbbind_v2019_refined.tar.gz
datasets/qm8.csv

.vscode/
+11 −0
Original line number Diff line number Diff line
@@ -14,6 +14,12 @@ jobs:
      language: c
      python: '3.7'
      os: windows
    - name: DocTest Examples
      language: python
      python: '3.7'
      sudo: required
      dist: xenial
      env: DOCTEST_EXAMPLES=true
cache: pip
install:
  - if [[ "$TRAVIS_OS_NAME" != "windows" ]]; then
@@ -34,6 +40,11 @@ install:
  - conda activate deepchem
  - pip install -e .
script:
  - if [[ "$DOCTEST_EXAMPLES" == "true" ]]; then
      cd docs && pip install -r requirements.txt;
      make doctest_examples;
      travis_terminate $?;
    fi
  - bash devtools/run_yapf.sh
  - bash devtools/run_flake8.sh
  - mypy -p deepchem
+1 −1
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@ import random
import tempfile
import itertools
import logging
from typing import Any, Dict, List, Iterator, Optional, Sequence, Tuple, Union
from typing import Any, Dict, List, Iterator, Optional, Sequence, Tuple

import numpy as np
import pandas as pd
+26 −16
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@ import tarfile
import zipfile
import logging
from urllib.request import urlretrieve
from typing import Any, Iterator, List, Optional, Tuple, Union
from typing import Any, Iterator, List, Optional, Tuple, Union, cast, IO

import pandas as pd
import numpy as np
@@ -323,8 +323,30 @@ def load_json_files(input_files: List[str],
        yield df


def load_pickle_file(input_file: str) -> Any:
  """Load from single, possibly gzipped, pickle file.

  Parameters
  ----------
  input_file: str
    The filename of pickle file. This function can load from
    gzipped pickle file like `XXXX.pkl.gz`.

  Returns
  -------
  Any
    The object which is loaded from the pickle file.
  """
  if ".gz" in input_file:
    with gzip.open(input_file, "rb") as unzipped_file:
      return pickle.load(cast(IO[bytes], unzipped_file))
  else:
    with open(input_file, "rb") as opened_file:
      return pickle.load(opened_file)


def load_pickle_files(input_files: List[str]) -> Iterator[Any]:
  """Load dataset from pickle file.
  """Load dataset from pickle files.

  Parameters
  ----------
@@ -338,13 +360,7 @@ def load_pickle_files(input_files: List[str]) -> Iterator[Any]:
    Generator which yields the objects which is loaded from each pickle file.
  """
  for input_file in input_files:
    if ".gz" in input_file:
      with gzip.open(input_file, "rb") as f:
        df = pickle.load(f)
    else:
      with open(input_file, "rb") as f:
        df = pickle.load(f)
    yield df
    yield load_pickle_file(input_file)


def load_data(input_files: List[str],
@@ -442,13 +458,7 @@ def load_from_disk(filename: str) -> Any:
    name = os.path.splitext(name)[0]
  extension = os.path.splitext(name)[1]
  if extension == ".pkl":
    if ".gz" in filename:
      with gzip.open(filename, "rb") as f:
        df = pickle.load(f)
    else:
      with open(filename, "rb") as f:
        df = pickle.load(f)
    return df
    return load_pickle_file(filename)
  elif extension == ".joblib":
    return joblib.load(filename)
  elif extension == ".csv":
+4 −0
Original line number Diff line number Diff line
@@ -14,6 +14,10 @@ help:

.PHONY: help Makefile

doctest_examples:
	export PYTHONWARNINGS= 
	@$(SPHINXBUILD) -M doctest "$(SOURCEDIR)" "$(BUILDDIR)" examples.rst;

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option.  $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
Loading