Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type checking for scheduler is added #284

Merged
merged 17 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
improve SO3Net model class coverage and simplify TensorNet implementa…
…tions
  • Loading branch information
kenko911 committed Jun 23, 2024
commit 16abc3840201bd9c30f645669d862dc694ff844c
5 changes: 1 addition & 4 deletions src/matgl/models/_tensornet.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,7 @@ def __init__(
f"Invalid activation type, please try using one of {[af.name for af in ActivationFunction]}"
) from None

if element_types is None:
self.element_types = DEFAULT_ELEMENTS
else:
self.element_types = element_types # type: ignore
self.element_types = element_types # type: ignore

self.bond_expansion = BondExpansion(
cutoff=cutoff,
Expand Down
10 changes: 6 additions & 4 deletions tests/models/test_so3net.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,18 @@ def test_model_intensive(self, graph_MoS):
output = model(g=graph)
assert torch.numel(output) == 2

def test_model_intensive_with_weighted_atom(self, graph_MoS):
def test_model_intensive_reduce_atom_classification(self, graph_MoS):
structure, graph, state = graph_MoS
lat = torch.tensor(np.array([structure.lattice.matrix]), dtype=matgl.float_th)
graph.edata["pbc_offshift"] = torch.matmul(graph.edata["pbc_offset"], lat[0])
graph.ndata["pos"] = graph.ndata["frac_coords"] @ lat[0]
model = SO3Net(element_types=["Mo", "S"], is_intensive=True, readout_type="weighted_atom")
model = SO3Net(
element_types=["Mo", "S"], is_intensive=True, readout_type="reduce_atom", target_property="graph"
)
output = model(g=graph)
assert torch.numel(output) == 2
assert torch.numel(output) == 1

def test_model_intensive_with_classification(self, graph_MoS):
def test_model_intensive_weighted_atom_classification(self, graph_MoS):
structure, graph, state = graph_MoS
lat = torch.tensor(np.array([structure.lattice.matrix]), dtype=matgl.float_th)
graph.edata["pbc_offshift"] = torch.matmul(graph.edata["pbc_offset"], lat[0])
Expand Down
2 changes: 0 additions & 2 deletions tests/models/test_tensornet.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ def test_model(self, graph_MoS):
os.remove("model.pt")
os.remove("model.json")
os.remove("state.pt")
model = TensorNet(is_intensive=False, equivariance_invariance_group="SO(3)")
assert torch.numel(output) == 1

def test_exceptions(self):
with pytest.raises(ValueError, match="Invalid activation type"):
Expand Down