Skip to content

Commit

Permalink
Graph, DB and IR module update (#162)
Browse files Browse the repository at this point in the history
* Wannier update (#136)

* Added OQMD, MP, QM9 CFID datasets.

* Added OQMD, MP, QM9 CFID datasets.

* vasp2xml schema update.

* Update config.yml

* XRD DB making bug fix, scattering.json update.

* Minor bug fix in vasp_to_xml.py

* Add license.

* Add license, pin versions

* Remove circle.

* Update shell.nix

* Vasprun single element bug fix.

* Minor updates.

* DB XML and VASP Workflow fix.

* AFLOW CFID added, VASP_PSP_DIR fix.

* Linting fix, new version release.

* Wannier update.

* Version update.

* VASP task update.

* Tempfile for downloading zipfiles.

* Pypi fix.

* Pypi fix.

* Updated wannier, vasp2xml, increased tests.

* Update setup.py

* Update action_build.yml

* Speed up test.

* Update DatasetSummary.rst

* Update outputs.py

* Enforce nk1==nk2 in spillage.

* Update test_spillage.py

* Multiple updates.

* Magtest update.

* Version update.

* Increase coverage. (#137)

* Added OQMD, MP, QM9 CFID datasets.

* Added OQMD, MP, QM9 CFID datasets.

* vasp2xml schema update.

* Update config.yml

* XRD DB making bug fix, scattering.json update.

* Minor bug fix in vasp_to_xml.py

* Add license.

* Add license, pin versions

* Remove circle.

* Update shell.nix

* Vasprun single element bug fix.

* Minor updates.

* DB XML and VASP Workflow fix.

* AFLOW CFID added, VASP_PSP_DIR fix.

* Linting fix, new version release.

* Wannier update.

* Version update.

* VASP task update.

* Tempfile for downloading zipfiles.

* Pypi fix.

* Pypi fix.

* Updated wannier, vasp2xml, increased tests.

* Update setup.py

* Update action_build.yml

* Speed up test.

* Update DatasetSummary.rst

* Update outputs.py

* Enforce nk1==nk2 in spillage.

* Update test_spillage.py

* Multiple updates.

* Magtest update.

* Version update.

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* WannierTB Phonons.

* phonopy TB.

* phonopy TB.

* Versionupdate.

* Wannier TB for phonons (#138)

* Added OQMD, MP, QM9 CFID datasets.

* Added OQMD, MP, QM9 CFID datasets.

* vasp2xml schema update.

* Update config.yml

* XRD DB making bug fix, scattering.json update.

* Minor bug fix in vasp_to_xml.py

* Add license.

* Add license, pin versions

* Remove circle.

* Update shell.nix

* Vasprun single element bug fix.

* Minor updates.

* DB XML and VASP Workflow fix.

* AFLOW CFID added, VASP_PSP_DIR fix.

* Linting fix, new version release.

* Wannier update.

* Version update.

* VASP task update.

* Tempfile for downloading zipfiles.

* Pypi fix.

* Pypi fix.

* Updated wannier, vasp2xml, increased tests.

* Update setup.py

* Update action_build.yml

* Speed up test.

* Update DatasetSummary.rst

* Update outputs.py

* Enforce nk1==nk2 in spillage.

* Update test_spillage.py

* Multiple updates.

* Magtest update.

* Version update.

* Update README.rst

* Update README.rst

* WannierTB Phonons.

* phonopy TB.

* phonopy TB.

* Versionupdate.

* QAlgo

* Create CODE_OF_CONDUCT.md (#139)

* Update README.rst

* Atoms POSCAR Order update.

* Qiskit tests.

* Lint fix.

* Wien2K extra test, ene file.

* WT.

* WT added.

* Qiskit depedendence.

* Qiskit version.

* Qiskit version.

* Qiskit version.

* Update requirements-ci.txt

* Update requirements-ci.txt

* Update action_build.yml

* Update shell.nix

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Ignore QAlgo tests.

* Make qiskit work.

* Make qiskit work.

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Delete __init__.py

* Qiskit fix attempt.

* Qiskit fix attempt.

* Qiskit fix attempt.

* Qiskit fix attempt.

* Qiskit fix attempt.

* Pennylane fix attempt.

* Update test_hermsolver.py

* Test ham.

* Test ham.

* Update inputs.py

* Test ham.

* Update action_build.yml

* Update inputs.py

* Create __init__.py

* Test ham.

* Update test_hermsolver.py

* Update test_hermsolver.py

* Test Circuit.

* Update test_hermsolver.py

* Update action_build.yml

* Aer

* Aer .

* Var circuit added.

* Increase test coverage, ASE, Tequila, Qiskit.

* Increase test coverage, ASE, Tequila, Qiskit.

* Increase test coverage, ASE, Tequila, Qiskit.

* Fix POSCAR order issue.

* Version change.

* Poscar write fix, CIF reader fix.

* Develop (#141)

* Added OQMD, MP, QM9 CFID datasets.

* Added OQMD, MP, QM9 CFID datasets.

* vasp2xml schema update.

* Update config.yml

* XRD DB making bug fix, scattering.json update.

* Minor bug fix in vasp_to_xml.py

* Add license.

* Add license, pin versions

* Remove circle.

* Update shell.nix

* Vasprun single element bug fix.

* Minor updates.

* DB XML and VASP Workflow fix.

* AFLOW CFID added, VASP_PSP_DIR fix.

* Linting fix, new version release.

* Wannier update.

* Version update.

* VASP task update.

* Tempfile for downloading zipfiles.

* Pypi fix.

* Pypi fix.

* Updated wannier, vasp2xml, increased tests.

* Update setup.py

* Update action_build.yml

* Speed up test.

* Update DatasetSummary.rst

* Update outputs.py

* Enforce nk1==nk2 in spillage.

* Update test_spillage.py

* Multiple updates.

* Magtest update.

* Version update.

* Update README.rst

* Update README.rst

* WannierTB Phonons.

* phonopy TB.

* phonopy TB.

* Versionupdate.

* QAlgo

* Atoms POSCAR Order update.

* Qiskit tests.

* Lint fix.

* Wien2K extra test, ene file.

* WT.

* WT added.

* Qiskit depedendence.

* Qiskit version.

* Qiskit version.

* Qiskit version.

* Update requirements-ci.txt

* Update requirements-ci.txt

* Update action_build.yml

* Update shell.nix

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Ignore QAlgo tests.

* Make qiskit work.

* Make qiskit work.

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Delete __init__.py

* Qiskit fix attempt.

* Qiskit fix attempt.

* Qiskit fix attempt.

* Qiskit fix attempt.

* Qiskit fix attempt.

* Pennylane fix attempt.

* Update test_hermsolver.py

* Test ham.

* Test ham.

* Update inputs.py

* Test ham.

* Update action_build.yml

* Update inputs.py

* Create __init__.py

* Test ham.

* Update test_hermsolver.py

* Update test_hermsolver.py

* Test Circuit.

* Update test_hermsolver.py

* Update action_build.yml

* Aer

* Aer .

* Var circuit added.

* Increase test coverage, ASE, Tequila, Qiskit.

* Increase test coverage, ASE, Tequila, Qiskit.

* Increase test coverage, ASE, Tequila, Qiskit.

* Ready for master branch.

* Update shell.nix

* Update __init__.py

* Version change.

* Poscar format fix. (#142)

* Fix POSCAR order issue.

* Version change.

* Poscar write fix, CIF reader fix.

* Develop (#141)

* Added OQMD, MP, QM9 CFID datasets.

* Added OQMD, MP, QM9 CFID datasets.

* vasp2xml schema update.

* Update config.yml

* XRD DB making bug fix, scattering.json update.

* Minor bug fix in vasp_to_xml.py

* Add license.

* Add license, pin versions

* Remove circle.

* Update shell.nix

* Vasprun single element bug fix.

* Minor updates.

* DB XML and VASP Workflow fix.

* AFLOW CFID added, VASP_PSP_DIR fix.

* Linting fix, new version release.

* Wannier update.

* Version update.

* VASP task update.

* Tempfile for downloading zipfiles.

* Pypi fix.

* Pypi fix.

* Updated wannier, vasp2xml, increased tests.

* Update setup.py

* Update action_build.yml

* Speed up test.

* Update DatasetSummary.rst

* Update outputs.py

* Enforce nk1==nk2 in spillage.

* Update test_spillage.py

* Multiple updates.

* Magtest update.

* Version update.

* Update README.rst

* Update README.rst

* WannierTB Phonons.

* phonopy TB.

* phonopy TB.

* Versionupdate.

* QAlgo

* Atoms POSCAR Order update.

* Qiskit tests.

* Lint fix.

* Wien2K extra test, ene file.

* WT.

* WT added.

* Qiskit depedendence.

* Qiskit version.

* Qiskit version.

* Qiskit version.

* Update requirements-ci.txt

* Update requirements-ci.txt

* Update action_build.yml

* Update shell.nix

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Ignore QAlgo tests.

* Make qiskit work.

* Make qiskit work.

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Delete __init__.py

* Qiskit fix attempt.

* Qiskit fix attempt.

* Qiskit fix attempt.

* Qiskit fix attempt.

* Qiskit fix attempt.

* Pennylane fix attempt.

* Update test_hermsolver.py

* Test ham.

* Test ham.

* Update inputs.py

* Test ham.

* Update action_build.yml

* Update inputs.py

* Create __init__.py

* Test ham.

* Update test_hermsolver.py

* Update test_hermsolver.py

* Test Circuit.

* Update test_hermsolver.py

* Update action_build.yml

* Aer

* Aer .

* Var circuit added.

* Increase test coverage, ASE, Tequila, Qiskit.

* Increase test coverage, ASE, Tequila, Qiskit.

* Increase test coverage, ASE, Tequila, Qiskit.

* Ready for master branch.

* Update shell.nix

* Update __init__.py

* Minor fix in figshare and spectrum.

* Minor fix in figshare and spectrum.

* Update README.rst

* Lint fix.

* Minor fix in figshare and spectrum. (#143)

* Added OQMD, MP, QM9 CFID datasets.

* Added OQMD, MP, QM9 CFID datasets.

* vasp2xml schema update.

* Update config.yml

* XRD DB making bug fix, scattering.json update.

* Minor bug fix in vasp_to_xml.py

* Add license.

* Add license, pin versions

* Remove circle.

* Update shell.nix

* Vasprun single element bug fix.

* Minor updates.

* DB XML and VASP Workflow fix.

* AFLOW CFID added, VASP_PSP_DIR fix.

* Linting fix, new version release.

* Wannier update.

* Version update.

* VASP task update.

* Tempfile for downloading zipfiles.

* Pypi fix.

* Pypi fix.

* Updated wannier, vasp2xml, increased tests.

* Update setup.py

* Update action_build.yml

* Speed up test.

* Update DatasetSummary.rst

* Update outputs.py

* Enforce nk1==nk2 in spillage.

* Update test_spillage.py

* Multiple updates.

* Magtest update.

* Version update.

* Update README.rst

* Update README.rst

* WannierTB Phonons.

* phonopy TB.

* phonopy TB.

* Versionupdate.

* QAlgo

* Atoms POSCAR Order update.

* Qiskit tests.

* Lint fix.

* Wien2K extra test, ene file.

* WT.

* WT added.

* Qiskit depedendence.

* Qiskit version.

* Qiskit version.

* Qiskit version.

* Update requirements-ci.txt

* Update requirements-ci.txt

* Update action_build.yml

* Update shell.nix

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Ignore QAlgo tests.

* Make qiskit work.

* Make qiskit work.

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Delete __init__.py

* Qiskit fix attempt.

* Qiskit fix attempt.

* Qiskit fix attempt.

* Qiskit fix attempt.

* Qiskit fix attempt.

* Pennylane fix attempt.

* Update test_hermsolver.py

* Test ham.

* Test ham.

* Update inputs.py

* Test ham.

* Update action_build.yml

* Update inputs.py

* Create __init__.py

* Test ham.

* Update test_hermsolver.py

* Update test_hermsolver.py

* Test Circuit.

* Update test_hermsolver.py

* Update action_build.yml

* Aer

* Aer .

* Var circuit added.

* Increase test coverage, ASE, Tequila, Qiskit.

* Increase test coverage, ASE, Tequila, Qiskit.

* Increase test coverage, ASE, Tequila, Qiskit.

* Fix POSCAR order issue.

* Version change.

* Poscar write fix, CIF reader fix.

* Develop (#141)

* Added OQMD, MP, QM9 CFID datasets.

* Added OQMD, MP, QM9 CFID datasets.

* vasp2xml schema update.

* Update config.yml

* XRD DB making bug fix, scattering.json update.

* Minor bug fix in vasp_to_xml.py

* Add license.

* Add license, pin versions

* Remove circle.

* Update shell.nix

* Vasprun single element bug fix.

* Minor updates.

* DB XML and VASP Workflow fix.

* AFLOW CFID added, VASP_PSP_DIR fix.

* Linting fix, new version release.

* Wannier update.

* Version update.

* VASP task update.

* Tempfile for downloading zipfiles.

* Pypi fix.

* Pypi fix.

* Updated wannier, vasp2xml, increased tests.

* Update setup.py

* Update action_build.yml

* Speed up test.

* Update DatasetSummary.rst

* Update outputs.py

* Enforce nk1==nk2 in spillage.

* Update test_spillage.py

* Multiple updates.

* Magtest update.

* Version update.

* Update README.rst

* Update README.rst

* WannierTB Phonons.

* phonopy TB.

* phonopy TB.

* Versionupdate.

* QAlgo

* Atoms POSCAR Order update.

* Qiskit tests.

* Lint fix.

* Wien2K extra test, ene file.

* WT.

* WT added.

* Qiskit depedendence.

* Qiskit version.

* Qiskit version.

* Qiskit version.

* Update requirements-ci.txt

* Update requirements-ci.txt

* Update action_build.yml

* Update shell.nix

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Ignore QAlgo tests.

* Make qiskit work.

* Make qiskit work.

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Delete __init__.py

* Qiskit fix attempt.

* Qiskit fix attempt.

* Qiskit fix attempt.

* Qiskit fix attempt.

* Qiskit fix attempt.

* Pennylane fix attempt.

* Update test_hermsolver.py

* Test ham.

* Test ham.

* Update inputs.py

* Test ham.

* Update action_build.yml

* Update inputs.py

* Create __init__.py

* Test ham.

* Update test_hermsolver.py

* Update test_hermsolver.py

* Test Circuit.

* Update test_hermsolver.py

* Update action_build.yml

* Aer

* Aer .

* Var circuit added.

* Increase test coverage, ASE, Tequila, Qiskit.

* Increase test coverage, ASE, Tequila, Qiskit.

* Increase test coverage, ASE, Tequila, Qiskit.

* Ready for master branch.

* Update shell.nix

* Update __init__.py

* Version change.

* Minor fix in figshare and spectrum.

* Update README.rst

* Lint fix.

* Minor update.

* Update figshare.py

* Fix build.

* Update README.rst

* docs update.

* Setup requirement change.

* Update version tag. (#145)

* Minor fix in figshare and spectrum.

* Setup requirement change.

* Cleanup graph (#146)

* revert jarvis.core.graph adjacency matrix weights to interatomic distances

* remove jarvis.core.graph.Graph edges with bond length past threshold max_cut

* fix jarvis.core.graph.Graph.adjacency_matrix to support sparse graphs (with no self edges), and update test file to reflect removal of self edges as well

* Update README.rst

* Update README.rst

* develop (#147)

* Update version tag. (#145)

* Minor fix in figshare and spectrum.

* Setup requirement change.

* Cleanup graph (#146)

* revert jarvis.core.graph adjacency matrix weights to interatomic distances

* remove jarvis.core.graph.Graph edges with bond length past threshold max_cut

* fix jarvis.core.graph.Graph.adjacency_matrix to support sparse graphs (with no self edges), and update test file to reflect removal of self edges as well

* Update README.rst

Co-authored-by: Brian DeCost <[email protected]>

* develop (#147)

* Update version tag. (#145)

* Minor fix in figshare and spectrum.

* Setup requirement change.

* Cleanup graph (#146)

* revert jarvis.core.graph adjacency matrix weights to interatomic distances

* remove jarvis.core.graph.Graph edges with bond length past threshold max_cut

* fix jarvis.core.graph.Graph.adjacency_matrix to support sparse graphs (with no self edges), and update test file to reflect removal of self edges as well

* Update README.rst

Co-authored-by: Brian DeCost <[email protected]>

* Travis update.

* Travis update.

* Travis update.

* Travis update.

* Travis update.

* Travis update.

* Travis update.

* Travis update.

* Update requirements-for-ci-only.txt

* Update requirements-for-ci-only.txt

* Update requirements-for-ci-only.txt

* Update requirements-for-ci-only.txt

* Update requirements-for-ci-only.txt

* Update requirements-for-ci-only.txt

* Update requirements-for-ci-only.txt

* Update requirements-for-ci-only.txt

* Update requirements-for-ci-only.txt

* Update requirements-for-ci-only.txt

* Update requirements-for-ci-only.txt

* Update requirements-for-ci-only.txt

* Adding Qiskit.

* Adding Qiskit.

* Adding Qiskit.

* Adding Qiskit.

* Version update.

* Version update.

* Adding Qiskit.

* Adding Qiskit.

* Fix travis.

* Fix travis.

* Fix travis.

* Fix travis.

* VASP outputs bug fix.

* Optics module and Dos module of VASP fixed.

* Fixing commit.

* Lint fix.

* Update inputs.py

* Version update.

* README update.

* Graph and dataset update.

* Graph and dataset update.

* Graph and dataset update.

* Graph module update.

* More datasets added.

* Update .travis.yml

* Update .travis.yml

* Exclude tequila tests.

* Exclude tequila tests.

* Extra tests.

* Pytest-cov added.

* Update action_build.yml

* Update action_build.yml

* Covergae update.

* Covergae update.

* StructureDataset test added.

* Graph tests fixed.

* Figshare update.

* STM image links added.

* Update test_figshare.py

* Update test_figshare.py

* Update .travis.yml

* Update .travis.yml

* Cache github action attempt.

* DB update.

* Update action.

* DB update.

* Figshare test update.

* JARVIS-FF DB added.

* Try to increase coverage.

* Polymer genome added.

* Graph update.

* Graph update.

* Graph update.

* Figshare update.

* Version update.

* Figshare update.

* Hot encoded species.

* STEM with Convolution and Pyprismatic added.

* STEM Conv update.

* Atoms module update.

* Lorentzian fix.

* Digitized features added.

* Graph angle,prdf added. QE parser update.

* Update outputs.py

* Graph angle update and cif2cell added.

* Reduced formula fix and linting fix.

* Test minor fix.

* Graph tests update.

* Pytestfix.

* See also check url in xml

* See also check url in xml

* Phonopy run update.

* Graph update with torch angle.

* Get all neighbors routine bug fix.

* Figshare lint fix.

* Version update, IR extended, graph torch fix.

* Fix IR pytest.

* IR test fix.

* Cache graph dataset (#161)

* modify graph StructureDataset to enable/disable computation of atomistic line graph.

* fix line length setting in black configuration and fix jarvis.core.specie and jarvis.core.graphs

* pin pennylane version to 0.14.1 in GH build action.

* update graph dataloader test.

* fix pennylane version pinning and fix missing pandas.DataFrame in dataloader test.

* bump version number.

Co-authored-by: Brian DeCost <[email protected]>
  • Loading branch information
knc6 and bdecost authored Apr 21, 2021
1 parent e19ec23 commit 6b5bfec
Show file tree
Hide file tree
Showing 7 changed files with 184 additions and 103 deletions.
11 changes: 5 additions & 6 deletions .github/workflows/action_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ jobs:
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ hashFiles('dev-requirements.txt') }}

- name: Install requirements
run: |
python setup.py develop
pip install --upgrade --upgrade-strategy eager -r dev-requirements.txt -e .
echo 'CONDA LIST'
conda list
echo 'PIP FREEZE'
pip freeze
#echo 'PYTEST-COV'
#pytest --cov-config=.coveragerc --cov=jarvis -n 2
#pytest --cov-config=.coveragerc --cov=jarvis -n 2
coverage run -m pytest
Expand All @@ -44,7 +44,7 @@ jobs:
# ./configure
# make pw
#jobs:
# miniconda:
Expand Down Expand Up @@ -77,7 +77,7 @@ jobs:
# run: |
# python setup.py develop
# #pip uninstall qiskit
# # pip install qiskit ase numpy==1.18.5 scipy==1.4.1 matplotlib>=3.0.0 phonopy==2.8.1 coverage lightgbm==2.1.0 flask joblib networkx scikit-learn pandas pennylane dgl tqdm codecov torch keras tensorflow==2.3.0 pytest pytest-cov bokeh pytest-xdist
# # pip install qiskit ase numpy==1.18.5 scipy==1.4.1 matplotlib>=3.0.0 phonopy==2.8.1 coverage lightgbm==2.1.0 flask joblib networkx scikit-learn pandas pennylane==0.14.1 dgl tqdm codecov torch keras tensorflow==2.3.0 pytest pytest-cov bokeh pytest-xdist
# # pip install git+https://github.com/aspuru-guzik-group/tequila.git
# # pip install -r requirements-for-ci-only.txt
# # pip install -r dev-requirements.txt
Expand All @@ -97,4 +97,3 @@ jobs:
# # cd q-e
# # ./configure
# # make pw

22 changes: 11 additions & 11 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
wheel
qiskit >= 0.24.0
ase>=3.21.1
numpy>=1.18.5
scipy>=1.4.1
matplotlib>=3.0.0
phonopy>=2.8.1
coverage>=5.5
lightgbm>=2.1.0
ase>=3.21.1
numpy>=1.18.5
scipy>=1.4.1
matplotlib>=3.0.0
phonopy>=2.8.1
coverage>=5.5
lightgbm>=2.1.0
flask >=1.1.2
joblib >=1.0.1
networkx >=2.5
networkx >=2.5
scikit-learn >=0.24.1
pandas >=1.2.3
dgl>=0.6.0.post1
tqdm>=4.59.0
pennylane>=0.14.1
tqdm>=4.59.0
pennylane==0.14.1
codecov >=2.1.11
torch >=1.8.0
keras >=2.4.3
tensorflow>=2.4.0
tensorflow>=2.4.0
cif2cell
pytest >=6.2.2
pytest-cov >=2.11.1
Expand Down
2 changes: 1 addition & 1 deletion jarvis/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""Version number."""
__version__ = "2021.4.19"
__version__ = "2021.4.21"
200 changes: 130 additions & 70 deletions jarvis/core/graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
from jarvis.core.specie import Specie
from jarvis.core.utils import random_colors
import numpy as np
import pandas as pd
from collections import OrderedDict
from jarvis.analysis.structure.neighbors import NeighborsAnalysis
from jarvis.core.specie import get_node_attributes
from jarvis.core.specie import chem_data, get_node_attributes
from jarvis.core.atoms import Atoms
from collections import defaultdict
from typing import List, Tuple, Sequence, Optional

try:
import torch
Expand Down Expand Up @@ -190,7 +192,8 @@ def atom_dgl_multigraph(
max_neighbors=12,
atom_features="cgcnn",
max_attempts=3,
id="JVASP-6172",
id: Optional[str] = None,
compute_line_graph: bool = True,
):
"""Obtain a DGLGraph for Atoms object."""
if neighbor_strategy == "k-nearest":
Expand All @@ -208,9 +211,8 @@ def atom_dgl_multigraph(
u, v, r = build_undirected_edgedata(atoms, edges)

# build up atom attribute tensor
species = atoms.elements
sps_features = []
for ii, s in enumerate(species):
for ii, s in enumerate(atoms.elements):
feat = list(get_node_attributes(s, atom_features=atom_features))
# if include_prdf_angles:
# feat=feat+list(prdf[ii])+list(adf[ii])
Expand All @@ -222,10 +224,16 @@ def atom_dgl_multigraph(
g = dgl.graph((u, v))
g.ndata["atom_features"] = node_features
g.edata["r"] = r
lg = g.line_graph(shared=True)
lg.apply_edges(compute_bond_cosines)

return g, lg
if compute_line_graph:
# construct atomistic line graph
# (nodes are bonds, edges are bond pairs)
# and add bond angle cosines as edge features
lg = g.line_graph(shared=True)
lg.apply_edges(compute_bond_cosines)
return g, lg
else:
return g

@staticmethod
def from_atoms(
Expand Down Expand Up @@ -441,27 +449,43 @@ def forward(self, g: dgl.DGLGraph):
return g


def prepare_dgl_batch(batch, device=None, non_blocking=False):
"""Send batched dgl graph to device."""
g, lg, t = batch
batch = ((g.to(device), lg.to(device)), t.to(device))
# g, t = batch
# batch = (g.to(device), t.to(device))
def prepare_dgl_batch(
batch: Tuple[dgl.DGLGraph, torch.Tensor], device=None, non_blocking=False
):
"""Send batched dgl crystal graph to device."""
g, t = batch
batch = (
g.to(device, non_blocking=non_blocking),
t.to(device, non_blocking=non_blocking),
)

return batch


def prepare_line_graph_batch(batch, device=None, non_blocking=False):
"""Send batched dgl graph to device."""
def prepare_line_graph_batch(
batch: Tuple[Tuple[dgl.DGLGraph, dgl.DGLGraph], torch.Tensor],
device=None,
non_blocking=False,
):
"""Send line graph batch to device.
Note: the batch is a nested tuple, with the graph and line graph together
"""
g, lg, t = batch
batch = ((g.to(device), lg.to(device)), t.to(device))
batch = (
(
g.to(device, non_blocking=non_blocking),
lg.to(device, non_blocking=non_blocking),
),
t.to(device, non_blocking=non_blocking),
)

return batch


def prepare_batch(batch, device=None):
"""Send tuple to device, including DGLGraphs."""
return tuple(x.to(device) for x in batch)
# def prepare_batch(batch, device=None):
# """Send tuple to device, including DGLGraphs."""
# return tuple(x.to(device) for x in batch)


def compute_bond_cosines(edges):
Expand Down Expand Up @@ -489,51 +513,78 @@ class StructureDataset(torch.utils.data.Dataset):

def __init__(
self,
structures,
targets,
ids=None,
cutoff=8.0,
maxrows=np.inf,
atom_features="cgcnn",
df: pd.DataFrame,
graphs: Sequence[dgl.DGLGraph],
target: str,
atom_features="atomic_number",
transform=None,
enforce_undirected=False,
max_neighbors=12,
neighbor_strategy="k-nearest",
line_graph=False,
classification=False,
):
"""Initialize the class."""
self.graphs = []
self.labels = []
self.ids = []
self.line_graphs = []

for idx, (structure, target, id) in enumerate(
tqdm(zip(structures, targets, ids))
):

if idx >= maxrows:
break
a = Atoms.from_dict(structure)
g, lg = Graph.atom_dgl_multigraph(
a,
atom_features=atom_features,
cutoff=cutoff,
max_neighbors=max_neighbors,
id=id,
)
"""Pytorch Dataset for atomistic graphs.
self.graphs.append(g)
self.line_graphs.append(lg)
self.labels.append(target)
self.ids.append(id)
`df`: pandas dataframe from e.g. jarvis.db.figshare.data
`graphs`: DGLGraph representations corresponding to rows in `df`
`target`: key for label column in `df`
"""
self.df = df
self.graphs = graphs
self.target = target
self.line_graph = line_graph

self.labels = self.df[target]
self.ids = self.df["jid"]
self.labels = torch.tensor(self.df[target]).type(
torch.get_default_dtype()
)
self.transform = transform

features = self._get_attribute_lookup(atom_features)

# load selected node representation
# assume graphs contain atomic number in g.ndata["atom_features"]
for g in graphs:
z = g.ndata.pop("atom_features")
g.ndata["atomic_number"] = z
z = z.type(torch.IntTensor).squeeze()
f = torch.tensor(features[z]).type(torch.FloatTensor)
if g.num_nodes() == 1:
f = f.unsqueeze(0)
g.ndata["atom_features"] = f

self.prepare_batch = prepare_dgl_batch
if line_graph:
self.prepare_batch = prepare_line_graph_batch

print("building line graphs")
self.line_graphs = []
for g in tqdm(graphs):
lg = g.line_graph(shared=True)
lg.apply_edges(compute_bond_cosines)
self.line_graphs.append(lg)

self.labels = torch.tensor(self.labels).type(torch.get_default_dtype())
if classification:
self.labels = self.labels.view(-1).long()
print("Classification dataset.", self.labels)

self.transform = transform
self.prepare_batch = prepare_line_graph_batch
@staticmethod
def _get_attribute_lookup(atom_features: str = "cgcnn"):
"""Build a lookup array indexed by atomic number."""
max_z = max(v["Z"] for v in chem_data.values())

# get feature shape (referencing Carbon)
template = get_node_attributes("C", atom_features)

features = np.zeros((1 + max_z, len(template)))

for element, v in chem_data.items():
z = v["Z"]
x = get_node_attributes(element, atom_features)

if x is not None:
features[z, :] = x

return features

def __len__(self):
"""Get length."""
Expand All @@ -546,12 +597,21 @@ def __getitem__(self, idx):

if self.transform:
g = self.transform(g)
# return g, label
return g, self.line_graphs[idx], label

def setup_standardizer(self):
if self.line_graph:
return g, self.line_graphs[idx], label

return g, label

def setup_standardizer(self, ids):
"""Atom-wise feature standardization transform."""
x = torch.cat([g.ndata["atom_features"] for g in self.graphs])
x = torch.cat(
[
g.ndata["atom_features"]
for idx, g in enumerate(self.graphs)
if idx in ids
]
)
self.atom_feature_mean = x.mean(0)
self.atom_feature_std = x.std(0)

Expand All @@ -560,21 +620,21 @@ def setup_standardizer(self):
)

@staticmethod
def collate(samples):
def collate(samples: List[Tuple[dgl.DGLGraph, torch.Tensor]]):
"""Dataloader helper to batch graphs cross `samples`."""
graphs, labels = map(list, zip(*samples))
batched_graph = dgl.batch(graphs)
return batched_graph, torch.tensor(labels)

@staticmethod
def collate_line_graph(
samples: List[Tuple[dgl.DGLGraph, dgl.DGLGraph, torch.Tensor]]
):
"""Dataloader helper to batch graphs cross `samples`."""
# device = "cpu"
# if torch.cuda.is_available():
# device = torch.device("cuda")
# graphs, labels = map(list, zip(*samples))
graphs, line_graphs, labels = map(list, zip(*samples))
batched_graph = dgl.batch(graphs)
batched_line_graph = dgl.batch(line_graphs)
# return batched_graph.to(device), torch.tensor(labels).to(device)
return (
batched_graph,
batched_line_graph,
torch.tensor(labels),
) # .to(device)
return batched_graph, batched_line_graph, torch.tensor(labels)


"""
Expand Down
Loading

0 comments on commit 6b5bfec

Please sign in to comment.