Skip to content

Commit

Permalink
Merge pull request #12 from janosh/filter-warnings-examples
Browse files Browse the repository at this point in the history
  • Loading branch information
shyuep authored Jul 10, 2022
2 parents 1cf8639 + 6afe9da commit 87173c1
Show file tree
Hide file tree
Showing 34 changed files with 1,971 additions and 599 deletions.
7 changes: 6 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repos:
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
- id: black-jupyter

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
Expand Down Expand Up @@ -46,3 +46,8 @@ repos:
rev: v0.960
hooks:
- id: mypy

- repo: https://github.com/nbQA-dev/nbQA
rev: 1.3.1
hooks:
- id: nbqa-isort
14 changes: 9 additions & 5 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# v0.0.4
- Fix model download
# Changelog

## v0.0.4

- Fix model download
- More documentation
- Bug fixes

# v0.0.2
## v0.0.2

- Fix edge cases for triple bonds
- Enable model weights download within code

# v0.0.1
## v0.0.1

- Initial release.
- Initial release.
294 changes: 154 additions & 140 deletions README.md

Large diffs are not rendered by default.

1,844 changes: 1,659 additions & 185 deletions examples/Cubic Crystal Test.ipynb

Large diffs are not rendered by default.

346 changes: 130 additions & 216 deletions examples/Relaxation of LiFePO4.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion m3gnet/graph/_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def _concatenate(list_of_arrays: List, name: AnyStr) -> Optional[np.ndarray]:
Returns: concatenated array
"""
num_none = sum([i is None for i in list_of_arrays])
num_none = sum(i is None for i in list_of_arrays)

if num_none == len(list_of_arrays):
return None
Expand Down
1 change: 0 additions & 1 deletion m3gnet/graph/_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ def convert(self, structure: StructureOrMolecule, **kwargs) -> MaterialGraph:
Returns:
"""
pass

def convert_many(self, structures: List[StructureOrMolecule], **kwargs) -> MaterialGraph:
"""
Expand Down
1 change: 0 additions & 1 deletion m3gnet/graph/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ def _check_graph(self) -> None:
"""
Check if the graph is valid
"""
pass

def replace(self, **kwargs):
"""
Expand Down
1 change: 0 additions & 1 deletion m3gnet/layers/_core.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
Core layers provide basic operations, e.g., MLP
"""
Expand Down
2 changes: 1 addition & 1 deletion m3gnet/layers/tests/data/test_NaCl.json
Original file line number Diff line number Diff line change
Expand Up @@ -729,4 +729,4 @@
]
]
]
]
]
1 change: 0 additions & 1 deletion m3gnet/layers/tests/test_aggregate.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import unittest

import numpy as np
Expand Down
1 change: 0 additions & 1 deletion m3gnet/layers/tests/test_atom_ref.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import unittest

import numpy as np
Expand Down
1 change: 0 additions & 1 deletion m3gnet/layers/tests/test_base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import unittest

import numpy as np
Expand Down
1 change: 0 additions & 1 deletion m3gnet/layers/tests/test_basis.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import unittest

import numpy as np
Expand Down
5 changes: 2 additions & 3 deletions m3gnet/layers/tests/test_bond.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# -*- coding: utf-8 -*-
import unittest

import numpy as np
from pymatgen.core import Lattice, Molecule, Structure

from m3gnet.graph import Index, RadiusCutoffGraphConverter, tf_compute_distance_angle
from m3gnet.layers import ConcatAtoms, PairRadialBasisExpansion, ThreeDInteraction
from m3gnet.graph import Index, RadiusCutoffGraphConverter
from m3gnet.layers import PairRadialBasisExpansion


class TestAgg(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion m3gnet/layers/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import tensorflow as tf
from pymatgen.core import Lattice, Structure

from m3gnet.graph import MaterialGraph, RadiusCutoffGraphConverter
from m3gnet.graph import RadiusCutoffGraphConverter
from m3gnet.layers import MLP, Embedding, GatedMLP, Pipe


Expand Down
1 change: 0 additions & 1 deletion m3gnet/layers/tests/test_gn.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import unittest

import numpy as np
Expand Down
1 change: 0 additions & 1 deletion m3gnet/layers/tests/test_readout.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import json
import os
import unittest
Expand Down
2 changes: 1 addition & 1 deletion m3gnet/models/_m3gnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def from_dir(cls, dirname: str, custom_objects: Optional[dict] = None) -> "M3GNe
fname = os.path.join(dirname, MODEL_NAME + ".json")
if not os.path.isfile(fname):
raise ValueError("Model does not exists")
with open(fname, "r") as f:
with open(fname) as f:
model_serialized = json.load(f)
# model_serialized = _replace_compatibility(model_serialized)
model = tf.keras.models.model_from_json(model_serialized, custom_objects=custom_objects)
Expand Down
1 change: 0 additions & 1 deletion m3gnet/models/tests/test_model.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import os
import unittest

Expand Down
1 change: 0 additions & 1 deletion m3gnet/trainers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""M3GNet trainers"""
# -*- coding: utf-8 -*-
from ._potential import PotentialTrainer
from ._property import Trainer

Expand Down
2 changes: 1 addition & 1 deletion m3gnet/trainers/_property.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def train(
pbar.set_params({"verbose": verbose, "epochs": epochs})
callbacks.append(pbar)

if len(callbacks) > len(set(i.__class__ for i in callbacks)):
if len(callbacks) > len({i.__class__ for i in callbacks}):
logger.warning("Duplicated callbacks found")

callback_list = tf.keras.callbacks.CallbackList(callbacks)
Expand Down
2 changes: 1 addition & 1 deletion m3gnet/trainers/tests/Li-O.json

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions m3gnet/trainers/tests/test_trainer.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-
import json
import os
import unittest
from shutil import rmtree

import numpy as np
import tensorflow as tf
Expand Down
1 change: 0 additions & 1 deletion m3gnet/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
Utilities for m3gnet
"""
Expand Down
1 change: 0 additions & 1 deletion m3gnet/utils/_math.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
math functions and miscellaneous calculations
"""
Expand Down
1 change: 0 additions & 1 deletion m3gnet/utils/_tf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
Tensorflow related utility
"""
Expand Down
1 change: 0 additions & 1 deletion m3gnet/utils/tests/test_math.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import unittest

import numpy as np
Expand Down
1 change: 0 additions & 1 deletion m3gnet/utils/tests/test_tf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import unittest

import numpy as np
Expand Down
2 changes: 1 addition & 1 deletion pretrained/MP-2021.2.8-EFS/m3gnet.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"{\"class_name\": \"M3GNet\", \"config\": {\"name\": \"m3g_net\", \"max_n\": 3, \"max_l\": 3, \"n_blocks\": 3, \"units\": 64, \"cutoff\": 5.0, \"threebody_cutoff\": 4.0, \"include_states\": false, \"readout\": \"weighted_atom\", \"n_atom_types\": 94, \"task_type\": \"regression\", \"is_intensive\": false, \"mean\": 0.0, \"std\": 32.17109834917642, \"element_refs\": [0.0, -3.4843261911561028, -0.7929797687431355, -3.4573625172171165, -4.707765870771016, -8.011108016668768, -8.394581462422844, -7.750094492197886, -7.387677478973862, -4.946528796048113, -0.029288391672177685, -2.466164931685727, -2.0318155603403856, -5.122487716146491, -7.875463903751272, -6.908196189228034, -4.611218804437086, -3.027152379064371, -0.06279713634418577, -2.3532963902733193, -4.778241420229052, -8.066454839808204, -11.401003587685803, -8.927171971061405, -8.508408434441172, -8.170571408379823, -6.59277195296443, -5.234141518172957, -4.465330755509164, -3.296725580820661, -1.3526280480990915, -3.545950773762615, -4.6323977966864, -4.138259405833041, -3.6809167595262324, -2.840390787871695, 6.470248022224444, -2.230039686972397, -4.28467191958041, -10.288419163253234, -11.646994569088832, -11.897257027375439, -8.629010559078154, -9.868963036382208, -7.529920274034659, -5.566108785366125, -4.989987934464926, -1.8907720720017154, -0.7166445477628792, -2.7783827902612814, -3.8250237734025108, -3.3872574311610446, -2.540821374472112, -1.9316853365228492, 9.327723590340101, -2.631982538856448, -4.863763303187234, -8.941340884330346, -9.007528604842154, -7.925494962422752, -8.063533560475317, -6.535237679123891, -8.225441352062779, -12.392082038520687, -17.33760321554992, -7.479752317415126, -8.264982305581707, -8.248225450889509, -7.0921249481053525, -8.415686698628432, -3.419624756529247, -7.574452251703786, -12.67851552979807, -13.501372548858408, -9.474060607688976, -11.789707376091997, -9.746879324605413, -7.55581267880792, -5.675347011209681, -2.470084079873828, 0.3532971230155427, -2.3394321085720198, -3.5180003513248814, -3.1732941043540257, 1.0547455480334031e-16, -1.8536706833505882e-16, -5.78493996176134e-16, 1.3591855871025166e-15, 2.991253288696013e-28, -5.688410264859977, -10.404066708232437, -11.41133300856, -14.291848396754993, -14.633848842020615, -15.398398562127586]}, \"keras_version\": \"2.7.0\", \"backend\": \"tensorflow\"}"
"{\"class_name\": \"M3GNet\", \"config\": {\"name\": \"m3g_net\", \"max_n\": 3, \"max_l\": 3, \"n_blocks\": 3, \"units\": 64, \"cutoff\": 5.0, \"threebody_cutoff\": 4.0, \"include_states\": false, \"readout\": \"weighted_atom\", \"n_atom_types\": 94, \"task_type\": \"regression\", \"is_intensive\": false, \"mean\": 0.0, \"std\": 32.17109834917642, \"element_refs\": [0.0, -3.4843261911561028, -0.7929797687431355, -3.4573625172171165, -4.707765870771016, -8.011108016668768, -8.394581462422844, -7.750094492197886, -7.387677478973862, -4.946528796048113, -0.029288391672177685, -2.466164931685727, -2.0318155603403856, -5.122487716146491, -7.875463903751272, -6.908196189228034, -4.611218804437086, -3.027152379064371, -0.06279713634418577, -2.3532963902733193, -4.778241420229052, -8.066454839808204, -11.401003587685803, -8.927171971061405, -8.508408434441172, -8.170571408379823, -6.59277195296443, -5.234141518172957, -4.465330755509164, -3.296725580820661, -1.3526280480990915, -3.545950773762615, -4.6323977966864, -4.138259405833041, -3.6809167595262324, -2.840390787871695, 6.470248022224444, -2.230039686972397, -4.28467191958041, -10.288419163253234, -11.646994569088832, -11.897257027375439, -8.629010559078154, -9.868963036382208, -7.529920274034659, -5.566108785366125, -4.989987934464926, -1.8907720720017154, -0.7166445477628792, -2.7783827902612814, -3.8250237734025108, -3.3872574311610446, -2.540821374472112, -1.9316853365228492, 9.327723590340101, -2.631982538856448, -4.863763303187234, -8.941340884330346, -9.007528604842154, -7.925494962422752, -8.063533560475317, -6.535237679123891, -8.225441352062779, -12.392082038520687, -17.33760321554992, -7.479752317415126, -8.264982305581707, -8.248225450889509, -7.0921249481053525, -8.415686698628432, -3.419624756529247, -7.574452251703786, -12.67851552979807, -13.501372548858408, -9.474060607688976, -11.789707376091997, -9.746879324605413, -7.55581267880792, -5.675347011209681, -2.470084079873828, 0.3532971230155427, -2.3394321085720198, -3.5180003513248814, -3.1732941043540257, 1.0547455480334031e-16, -1.8536706833505882e-16, -5.78493996176134e-16, 1.3591855871025166e-15, 2.991253288696013e-28, -5.688410264859977, -10.404066708232437, -11.41133300856, -14.291848396754993, -14.633848842020615, -15.398398562127586]}, \"keras_version\": \"2.7.0\", \"backend\": \"tensorflow\"}"
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ exclude = '''
| test_files
)/
)
'''
'''
2 changes: 1 addition & 1 deletion requirements-ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ pydocstyle
black
flake8
types-tabulate==0.8.3
pylint
pylint
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ ignore = BLK999, W503, BLK100

[mypy]
ignore_missing_imports = True
exclude = pretrained, m3gnet.data-*, *.index, *.json
exclude = pretrained, m3gnet.data-*, *.index, *.json
22 changes: 1 addition & 21 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import json
import os
import re
import subprocess

import requests
from invoke import task
Expand Down Expand Up @@ -40,9 +39,7 @@ def make_doc(ctx):
else:
if not clean.endswith("tests"):
suboutput.append(line)
if clean.startswith("m3gnet") and not clean.endswith(
"tests"
):
if clean.startswith("m3gnet") and not clean.endswith("tests"):
newoutput.extend(suboutput)
subpackage = False
suboutput = []
Expand Down Expand Up @@ -91,23 +88,6 @@ def release_github(ctx):
print(response.text)


@task
def update_changelog(ctx):
output = subprocess.check_output(
["git", "log", "--pretty=format:%s", "v%s..HEAD" % CURRENT_VER]
)
lines = ["* " + l for l in output.decode("utf-8").strip().split("\n")]
with open("CHANGES.rst") as f:
contents = f.read()
l = "=========="
toks = contents.split(l)
head = "\n\nv%s\n" % NEW_VER + "-" * (len(NEW_VER) + 1) + "\n"
toks.insert(-1, head + "\n".join(lines))
with open("CHANGES.rst", "w") as f:
f.write(toks[0] + l + "".join(toks[1:]))
ctx.run("open CHANGES.rst")


@task
def release(ctx, notest=False):
ctx.run("rm -r dist build m3gnet.egg-info", warn=True)
Expand Down

0 comments on commit 87173c1

Please sign in to comment.