Skip to content

Commit 37ed487

Browse files
committed
Fix tests
1 parent 3962929 commit 37ed487

File tree

4 files changed

+21
-26
lines changed

4 files changed

+21
-26
lines changed

src/metatrain/cli/train.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -421,10 +421,7 @@ def train_model(
421421
# TRAIN MODEL #############
422422
###########################
423423

424-
# logger.info("Calling trainer")
425-
# from torch.profiler import profile, ProfilerActivity
426-
# with profile(activities=[ProfilerActivity.CPU, ProfilerActivity.CUDA]) as prof:
427-
# if True:
424+
logger.info("Calling trainer")
428425
trainer.train(
429426
model=model,
430427
dtype=dtype,
@@ -433,8 +430,6 @@ def train_model(
433430
val_datasets=val_datasets,
434431
checkpoint_dir=str(checkpoint_dir),
435432
)
436-
# print(prof.key_averages().table(sort_by="self_cpu_time_total", row_limit=20))
437-
# exit()
438433

439434
if not is_main_process():
440435
return # only save and evaluate on the main process

src/metatrain/experimental/phace/tests/test_equivariance.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def test_rotational_invariance():
6464
torch.set_default_dtype(torch.float32) # change back
6565

6666

67-
@pytest.mark.parametrize("o3_lambda", [0, 1, 2, 3, 4])
67+
@pytest.mark.parametrize("o3_lambda", [0, 1, 2, 3])
6868
@pytest.mark.parametrize("o3_sigma", [1])
6969
def test_equivariance_rotations(o3_lambda, o3_sigma):
7070
"""Tests that the model is rotationally equivariant when predicting
@@ -128,7 +128,7 @@ def test_equivariance_rotations(o3_lambda, o3_sigma):
128128

129129

130130
@pytest.mark.parametrize("dataset_path", [DATASET_PATH, DATASET_PATH_PERIODIC])
131-
@pytest.mark.parametrize("o3_lambda", [0, 1, 2, 3, 4])
131+
@pytest.mark.parametrize("o3_lambda", [0, 1, 2, 3])
132132
@pytest.mark.parametrize("o3_sigma", [1])
133133
def test_equivariance_inversion(dataset_path, o3_lambda, o3_sigma):
134134
"""Tests that the model is equivariant with respect to inversions."""

src/metatrain/experimental/phace/tests/test_functionality.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def test_output_last_layer_features():
164164
]
165165
assert features.values.shape == (
166166
4,
167-
32,
167+
192,
168168
)
169169
assert features.properties.names == [
170170
"properties",
@@ -178,7 +178,7 @@ def test_output_last_layer_features():
178178
assert last_layer_features.values.shape == (
179179
4,
180180
1,
181-
32,
181+
192,
182182
)
183183
assert last_layer_features.properties.names == [
184184
"properties",
@@ -208,7 +208,7 @@ def test_output_last_layer_features():
208208
]
209209
assert features.values.shape == (
210210
1,
211-
32,
211+
192,
212212
)
213213
assert features.properties.names == [
214214
"properties",
@@ -220,7 +220,7 @@ def test_output_last_layer_features():
220220
assert outputs["mtt::aux::energy_last_layer_features"].block().values.shape == (
221221
1,
222222
1,
223-
32,
223+
192,
224224
)
225225
assert outputs["mtt::aux::energy_last_layer_features"].block().properties.names == [
226226
"properties",

src/metatrain/experimental/phace/tests/test_regression.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,17 @@ def test_regression_init():
4545

4646
expected_output = torch.tensor(
4747
[
48-
[-3.736138916016e01],
49-
[6.381711363792e-02],
50-
[1.800283813477e01],
51-
[-2.970426513672e03],
52-
[1.789148712158e01],
48+
[0.002085668733],
49+
[-0.003157143714],
50+
[0.000328244379],
51+
[0.004316798877],
52+
[0.001980246045],
5353
]
5454
)
5555

5656
# if you need to change the hardcoded values:
57-
torch.set_printoptions(precision=12)
58-
print(output["mtt::U0"].block().values)
57+
# torch.set_printoptions(precision=12)
58+
# print(output["mtt::U0"].block().values)
5959

6060
torch.testing.assert_close(output["mtt::U0"].block().values, expected_output)
6161

@@ -115,16 +115,16 @@ def test_regression_train():
115115

116116
expected_output = torch.tensor(
117117
[
118-
[2.120110988617],
119-
[0.246357604861],
120-
[0.113200485706],
121-
[0.136439576745],
122-
[0.023953542113],
118+
[0.101170130074],
119+
[0.038209509104],
120+
[0.012803453952],
121+
[0.151425197721],
122+
[0.050753910094],
123123
]
124124
)
125125

126126
# if you need to change the hardcoded values:
127-
torch.set_printoptions(precision=12)
128-
print(output["mtt::U0"].block().values)
127+
# torch.set_printoptions(precision=12)
128+
# print(output["mtt::U0"].block().values)
129129

130130
torch.testing.assert_close(output["mtt::U0"].block().values, expected_output)

0 commit comments

Comments
 (0)