Commit 2dbbeef4 authored by peastman's avatar peastman
Browse files

Merged changes from master branch

parents f0f9b43c 5dbf3b0a
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -101,3 +101,4 @@ datasets/pdbbind_v2019_refined.tar.gz
datasets/qm8.csv

.vscode/
.python-version
+1 −5
Original line number Diff line number Diff line
@@ -7,11 +7,7 @@ version: 2

# Build documentation in the docs/ directory with Sphinx
sphinx:
  configuration: docs/conf.py

# Build documentation with MkDocs
# mkdocs:
#   configuration: mkdocs.yml
  configuration: docs/source/conf.py

# Optionally build your docs in additional formats such as PDF and ePub
formats: all
+1 −0
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ script:
  - if [[ "$CHECK_ONLY_DOCS" == "true" ]]; then
      cd docs && pip install -r requirements.txt;
      make clean html;
      make doctest_tutorials;
      make doctest_examples;
      travis_terminate $?;
    fi
+1 −1
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ materials science, quantum chemistry, and biology.

## Requirements

DeepChem currently supports Python 3.5 through 3.7 and requires these packages on any condition.
DeepChem currently supports Python 3.6 through 3.7 and requires these packages on any condition.

- [joblib](https://pypi.python.org/pypi/joblib)
- [NumPy](https://numpy.org/)
+14 −7
Original line number Diff line number Diff line
@@ -123,29 +123,36 @@ class GraphData:
        edge_attr=edge_features,
        pos=node_pos_features)

  def to_dgl_graph(self):
  def to_dgl_graph(self, self_loop: bool = False):
    """Convert to DGL graph data instance

    Returns
    -------
    dgl.DGLGraph
      Graph data for DGL
    self_loop: bool
      Whether to add self loops for the nodes, i.e. edges from nodes
      to themselves. Default to False.

    Notes
    -----
    This method requires DGL to be installed.
    """
    try:
      import dgl
      import torch
      from dgl import DGLGraph
    except ModuleNotFoundError:
      raise ImportError("This function requires DGL to be installed.")

    g = DGLGraph()
    g.add_nodes(self.num_nodes)
    g.add_edges(
        torch.from_numpy(self.edge_index[0]).long(),
        torch.from_numpy(self.edge_index[1]).long())
    src = self.edge_index[0]
    dst = self.edge_index[1]
    if self_loop:
      src = np.concatenate([src, np.arange(self.num_nodes)])
      dst = np.concatenate([dst, np.arange(self.num_nodes)])

    g = dgl.graph(
        (torch.from_numpy(src).long(), torch.from_numpy(dst).long()),
        num_nodes=self.num_nodes)
    g.ndata['x'] = torch.from_numpy(self.node_features).float()

    if self.node_pos_features is not None:
Loading