Skip to content

Commit 312dbf5

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent ccfacc9 commit 312dbf5

File tree

6 files changed

+75
-106
lines changed

6 files changed

+75
-106
lines changed

ipsuite/analysis/bin_property.py

+6-8
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,9 @@ def run(self):
205205
self.get_plots(counts[0], bin_edges[0], hydrostatic=True)
206206
self.get_plots(counts[1], bin_edges[1], hydrostatic=False)
207207

208-
self.labels_df = pd.DataFrame(
209-
{
210-
"hydro_bin_edges": bin_edges[0][1:],
211-
"hydro_counts": counts[0],
212-
"deviatoric_bin_edges": bin_edges[1][1:],
213-
"deviatoric_counts": counts[1],
214-
}
215-
)
208+
self.labels_df = pd.DataFrame({
209+
"hydro_bin_edges": bin_edges[0][1:],
210+
"hydro_counts": counts[0],
211+
"deviatoric_bin_edges": bin_edges[1][1:],
212+
"deviatoric_counts": counts[1],
213+
})

ipsuite/analysis/ensemble.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,9 @@ def run(self):
9494
figures[2].savefig(self.histogram)
9595

9696
def get_plots(self):
97-
energy = np.stack(
98-
[
99-
np.stack([x.get_potential_energy() for x in p])
100-
for p in self.prediction_list
101-
]
102-
)
97+
energy = np.stack([
98+
np.stack([x.get_potential_energy() for x in p]) for p in self.prediction_list
99+
])
103100

104101
figures = []
105102
# Plot the energy

ipsuite/analysis/model/predict.py

+30-42
Original file line numberDiff line numberDiff line change
@@ -105,18 +105,14 @@ def get_dataframes(self):
105105
"""Create a pandas dataframe from the given data."""
106106
true_data, pred_data = self.get_data()
107107

108-
self.energy_df = pd.DataFrame(
109-
{
110-
"true": (
111-
np.array([x.get_potential_energy() / len(x) for x in true_data])
112-
* 1000
113-
),
114-
"prediction": (
115-
np.array([x.get_potential_energy() / len(x) for x in pred_data])
116-
* 1000
117-
),
118-
}
119-
)
108+
self.energy_df = pd.DataFrame({
109+
"true": (
110+
np.array([x.get_potential_energy() / len(x) for x in true_data]) * 1000
111+
),
112+
"prediction": (
113+
np.array([x.get_potential_energy() / len(x) for x in pred_data]) * 1000
114+
),
115+
})
120116

121117
try:
122118
true_forces = [np.reshape(x.get_forces(), (-1, 3)) for x in true_data]
@@ -125,18 +121,16 @@ def get_dataframes(self):
125121
pred_forces = [np.reshape(x.get_forces(), (-1, 3)) for x in pred_data]
126122
pred_forces = np.concatenate(pred_forces, axis=0) * 1000
127123

128-
self.forces_df = pd.DataFrame(
129-
{
130-
"true": np.linalg.norm(true_forces, axis=-1),
131-
"true_x": true_forces[:, 0],
132-
"true_y": true_forces[:, 1],
133-
"true_z": true_forces[:, 2],
134-
"prediction": np.linalg.norm(pred_forces, axis=-1),
135-
"prediction_x": pred_forces[:, 0],
136-
"prediction_y": pred_forces[:, 1],
137-
"prediction_z": pred_forces[:, 2],
138-
}
139-
)
124+
self.forces_df = pd.DataFrame({
125+
"true": np.linalg.norm(true_forces, axis=-1),
126+
"true_x": true_forces[:, 0],
127+
"true_y": true_forces[:, 1],
128+
"true_z": true_forces[:, 2],
129+
"prediction": np.linalg.norm(pred_forces, axis=-1),
130+
"prediction_x": pred_forces[:, 0],
131+
"prediction_y": pred_forces[:, 1],
132+
"prediction_z": pred_forces[:, 2],
133+
})
140134
except PropertyNotImplementedError:
141135
self.forces_df = pd.DataFrame({})
142136

@@ -153,24 +147,18 @@ def get_dataframes(self):
153147
hydro_pred = np.reshape(hydro_pred, -1)
154148
deviat_pred = np.reshape(deviat_pred, -1)
155149

156-
self.stress_df = pd.DataFrame(
157-
{
158-
"true": true_stress,
159-
"prediction": pred_stress,
160-
}
161-
)
162-
self.stress_hydro_df = pd.DataFrame(
163-
{
164-
"true": hydro_true,
165-
"prediction": hydro_pred,
166-
}
167-
)
168-
self.stress_deviat_df = pd.DataFrame(
169-
{
170-
"true": deviat_true,
171-
"prediction": deviat_pred,
172-
}
173-
)
150+
self.stress_df = pd.DataFrame({
151+
"true": true_stress,
152+
"prediction": pred_stress,
153+
})
154+
self.stress_hydro_df = pd.DataFrame({
155+
"true": hydro_true,
156+
"prediction": hydro_pred,
157+
})
158+
self.stress_deviat_df = pd.DataFrame({
159+
"true": deviat_true,
160+
"prediction": deviat_pred,
161+
})
174162
except PropertyNotImplementedError:
175163
self.stress_df = pd.DataFrame({})
176164
self.stress_hydro_df = pd.DataFrame({})

ipsuite/calculators/ase_md.py

+10-14
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,11 @@ def modify(self, thermostat, step, total_steps):
102102
[[self.end_cell, 0, 0], [0, self.end_cell, 0], [0, 0, self.end_cell]]
103103
)
104104
elif isinstance(self.end_cell, list):
105-
self.end_cell = np.array(
106-
[
107-
[self.end_cell[0], 0, 0],
108-
[0, self.end_cell[1], 0],
109-
[0, 0, self.end_cell[2]],
110-
]
111-
)
105+
self.end_cell = np.array([
106+
[self.end_cell[0], 0, 0],
107+
[0, self.end_cell[1], 0],
108+
[0, 0, self.end_cell[2]],
109+
])
112110

113111
percentage = step / (total_steps - 1)
114112
# if num_ramp_oscillations is set, the cell size is ramped to end_cell within
@@ -312,13 +310,11 @@ class NPTThermostat(base.IPSNode):
312310

313311
def get_thermostat(self, atoms):
314312
if self.tetragonal_strain:
315-
mask = np.array(
316-
[
317-
[True, False, False],
318-
[False, True, False],
319-
[False, False, True],
320-
]
321-
)
313+
mask = np.array([
314+
[True, False, False],
315+
[False, True, False],
316+
[False, False, True],
317+
])
322318
else:
323319
mask = None
324320
self.time_step *= units.fs

ipsuite/models/nequip.py

+7-9
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,13 @@ def get_metrics_from_plots(self):
137137

138138
def deploy_model(self):
139139
"""Deploy the model using nequip-deploy."""
140-
subprocess.check_call(
141-
[
142-
"nequip-deploy",
143-
"build",
144-
"--train-dir",
145-
(self.model_directory / "dvc-run").as_posix(),
146-
self.deployed_model.as_posix(),
147-
]
148-
)
140+
subprocess.check_call([
141+
"nequip-deploy",
142+
"build",
143+
"--train-dir",
144+
(self.model_directory / "dvc-run").as_posix(),
145+
self.deployed_model.as_posix(),
146+
])
149147

150148
def run(self):
151149
"""Primary method to run which executes all steps of the model training."""

tests/conftest.py

+19-27
Original file line numberDiff line numberDiff line change
@@ -131,35 +131,27 @@ def data_repo(tmp_path, request) -> pathlib.Path:
131131
def atoms_with_composed_forces():
132132
atoms = Atoms(
133133
"OH2",
134-
positions=np.array(
135-
[
136-
[0.0, 0.0, 0.0],
137-
[1.0, 0.0, 0.0],
138-
[0.0, 1.0, 0.0],
139-
]
140-
),
141-
)
142-
ft = np.array(
143-
[
144-
[0.0, 0.0, 1.0 * 15.999],
145-
[0.0, 0.0, 1.008],
146-
[0.0, 0.0, 1.008],
147-
]
148-
)
149-
fr = np.array(
150-
[
134+
positions=np.array([
151135
[0.0, 0.0, 0.0],
152-
[0.0, 0.0, 1.008],
153-
[0.0, 0.0, -1.008],
154-
]
155-
)
156-
fv = np.array(
157-
[
158-
[1.0, 1.0, 0.0],
159-
[-1.0, 0.0, 0.0],
160-
[0.0, -1.0, 0.0],
161-
]
136+
[1.0, 0.0, 0.0],
137+
[0.0, 1.0, 0.0],
138+
]),
162139
)
140+
ft = np.array([
141+
[0.0, 0.0, 1.0 * 15.999],
142+
[0.0, 0.0, 1.008],
143+
[0.0, 0.0, 1.008],
144+
])
145+
fr = np.array([
146+
[0.0, 0.0, 0.0],
147+
[0.0, 0.0, 1.008],
148+
[0.0, 0.0, -1.008],
149+
])
150+
fv = np.array([
151+
[1.0, 1.0, 0.0],
152+
[-1.0, 0.0, 0.0],
153+
[0.0, -1.0, 0.0],
154+
])
163155
atoms.calc = ase.calculators.singlepoint.SinglePointCalculator(
164156
atoms, forces=ft + fr + fv
165157
)

0 commit comments

Comments
 (0)