Skip to content

Commit cf9350a

Browse files
Adding tests
1 parent db3ce89 commit cf9350a

42 files changed

Lines changed: 644 additions & 405 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/source/advanced_usage/descriptors.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ An example would be this:
7676

7777
.. code-block:: python
7878
79-
hyperoptimizer.add_snapshot("espresso-out", os.path.join(data_path, "Be_snapshot1.out"),
80-
"numpy", os.path.join(data_path, "Be_snapshot1.out.npy"),
79+
hyperoptimizer.add_snapshot("espresso-out", os.path.join(data_path_be, "Be_snapshot1.out"),
80+
"numpy", os.path.join(data_path_be, "Be_snapshot1.out.npy"),
8181
target_units="1/(Ry*Bohr^3)")
82-
hyperoptimizer.add_snapshot("espresso-out", os.path.join(data_path, "Be_snapshot2.out"),
83-
"numpy", os.path.join(data_path, "Be_snapshot2.out.npy"),
82+
hyperoptimizer.add_snapshot("espresso-out", os.path.join(data_path_be, "Be_snapshot2.out"),
83+
"numpy", os.path.join(data_path_be, "Be_snapshot2.out.npy"),
8484
target_units="1/(Ry*Bohr^3)")
8585
8686
Once this is done, you can start the optimization via

docs/source/advanced_usage/openpmd.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@ be left untouched. Specifically, set
3333
...
3434
# Changes for DataHandler
3535
data_handler = mala.DataHandler(parameters)
36-
data_handler.add_snapshot("Be_snapshot0.in.h5", data_path,
37-
"Be_snapshot0.out.h5", data_path, "tr",
36+
data_handler.add_snapshot("Be_snapshot0.in.h5", data_path_be,
37+
"Be_snapshot0.out.h5", data_path_be, "tr",
3838
snapshot_type="openpmd")
3939
...
4040
# Changes for DataShuffler
4141
data_shuffler = mala.DataShuffler(parameters)
4242
# Data can be shuffle FROM and TO openPMD - but also from
4343
# numpy to openPMD.
44-
data_shuffler.add_snapshot("Be_snapshot0.in.h5", data_path,
45-
"Be_snapshot0.out.h5", data_path,
44+
data_shuffler.add_snapshot("Be_snapshot0.in.h5", data_path_be,
45+
"Be_snapshot0.out.h5", data_path_be,
4646
snapshot_type="openpmd")
4747
data_shuffler.shuffle_snapshots(...,
4848
save_name="Be_shuffled*.h5")

docs/source/advanced_usage/trainingmodel.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,10 @@ descriptors is supported.
181181
parameters.data.shuffling_seed = 1234
182182
183183
data_shuffler = mala.DataShuffler(parameters)
184-
data_shuffler.add_snapshot("Be_snapshot0.in.npy", data_path,
185-
"Be_snapshot0.out.npy", data_path)
186-
data_shuffler.add_snapshot("Be_snapshot1.in.npy", data_path,
187-
"Be_snapshot1.out.npy", data_path)
184+
data_shuffler.add_snapshot("Be_snapshot0.in.npy", data_path_be,
185+
"Be_snapshot0.out.npy", data_path_be)
186+
data_shuffler.add_snapshot("Be_snapshot1.in.npy", data_path_be,
187+
"Be_snapshot1.out.npy", data_path_be)
188188
data_shuffler.shuffle_snapshots(complete_save_path="../",
189189
save_name="Be_shuffled*")
190190

docs/source/basic_usage/more_data.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ and fill it with data, e.g., by
100100
.. code-block:: python
101101
102102
data_converter = mala.DataConverter(parameters)
103-
outfile = os.path.join(data_path, "Be_snapshot0.out")
104-
ldosfile = os.path.join(data_path, "cubes/tmp.pp*Be_ldos.cube")
103+
outfile = os.path.join(data_path_be, "Be_snapshot0.out")
104+
ldosfile = os.path.join(data_path_be, "cubes/tmp.pp*Be_ldos.cube")
105105
106106
data_converter.add_snapshot(descriptor_input_type="espresso-out",
107107
descriptor_input_path=outfile,
@@ -133,12 +133,12 @@ Once data is provided, the conversion itself is simple.
133133
simulation_output_save_path="./",
134134
naming_scheme="Be_snapshot*.npy",
135135
descriptor_calculation_kwargs=
136-
{"working_directory": data_path})
136+
{"working_directory": data_path_be})
137137
# You can also provide only one path
138138
# data_converter.convert_snapshots(complete_save_path="./",
139139
# naming_scheme="Be_snapshot*.npy",
140140
# descriptor_calculation_kwargs=
141-
# {"working_directory": data_path})
141+
# {"working_directory": data_path_be})
142142
143143
The ``convert_snapshots`` function will convert ALL snapshots added via
144144
``add_snapshot`` and save the resulting volumetric numpy files to the

docs/source/basic_usage/predictions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ as a calculator and use the ASE interface to perform the calculation.
8787

8888
.. code-block:: python
8989
90-
atoms = read(os.path.join(data_path, "Be_snapshot1.out"))
90+
atoms = read(os.path.join(data_path_be, "Be_snapshot1.out"))
9191
atoms.set_calculator(calculator)
9292
atoms.get_potential_energy()
9393

docs/source/basic_usage/trainingmodel.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,10 @@ providing the respective types of data files.
101101
.. code-block:: python
102102
103103
data_handler = mala.DataHandler(parameters)
104-
data_handler.add_snapshot("Be_snapshot0.in.npy", data_path,
105-
"Be_snapshot0.out.npy", data_path, "tr")
106-
data_handler.add_snapshot("Be_snapshot1.in.npy", data_path,
107-
"Be_snapshot1.out.npy", data_path, "va")
104+
data_handler.add_snapshot("Be_snapshot0.in.npy", data_path_be,
105+
"Be_snapshot0.out.npy", data_path_be, "tr")
106+
data_handler.add_snapshot("Be_snapshot1.in.npy", data_path_be,
107+
"Be_snapshot1.out.npy", data_path_be, "va")
108108
109109
2. On-the-fly descriptors: The LDOS is sampled into either OpenPMD or numpy
110110
files, while the volumetric descriptor data is computed on-the-fly during
@@ -122,10 +122,10 @@ providing the respective types of data files.
122122
parameters.descriptors.bispectrum_cutoff = 4.67637
123123
124124
data_handler = mala.DataHandler(parameters)
125-
data_handler.add_snapshot("Be_snapshot0.info.json", data_path,
126-
"Be_snapshot0.out.npy", data_path, "tr")
127-
data_handler.add_snapshot("Be_snapshot1.info.json", data_path,
128-
"Be_snapshot1.out.npy", data_path, "va")
125+
data_handler.add_snapshot("Be_snapshot0.info.json", data_path_be,
126+
"Be_snapshot0.out.npy", data_path_be, "tr")
127+
data_handler.add_snapshot("Be_snapshot1.info.json", data_path_be,
128+
"Be_snapshot1.out.npy", data_path_be, "va")
129129
130130
The ``"tr"`` and ``"va"`` flag signal that the respective snapshots are added as
131131
training and validation data, respectively. Training data is data the model
@@ -176,7 +176,7 @@ coarseness, etc., are available at inference time. By
176176

177177
.. code-block:: python
178178
179-
additional_calculation_data = os.path.join(data_path, "Be_snapshot0.out")
179+
additional_calculation_data = os.path.join(data_path_be, "Be_snapshot0.out")
180180
trainer.save_run("be_model",
181181
additional_calculation_data=additional_calculation_data)
182182

examples/advanced/ex01_checkpoint_training.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import mala
44
from mala import printout
55

6-
from mala.datahandling.data_repo import data_path
6+
from mala.datahandling.data_repo import data_path_be
77

88
"""
99
Shows how a training run can be paused and
@@ -37,16 +37,16 @@ def initial_setup():
3737
data_handler = mala.DataHandler(parameters)
3838
data_handler.add_snapshot(
3939
"Be_snapshot0.in.npy",
40-
data_path,
40+
data_path_be,
4141
"Be_snapshot0.out.npy",
42-
data_path,
42+
data_path_be,
4343
"tr",
4444
)
4545
data_handler.add_snapshot(
4646
"Be_snapshot1.in.npy",
47-
data_path,
47+
data_path_be,
4848
"Be_snapshot1.out.npy",
49-
data_path,
49+
data_path_be,
5050
"va",
5151
)
5252
data_handler.prepare_data()

examples/advanced/ex02_shuffle_data.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import mala
22

3-
from mala.datahandling.data_repo import data_path
3+
from mala.datahandling.data_repo import data_path_be
44

55
"""
66
Shows how data can be shuffled amongst multiple
@@ -45,28 +45,28 @@
4545
# as well. Here, we use precomputed ones.
4646
data_shuffler.add_snapshot(
4747
"Be_snapshot0.in.npy",
48-
data_path,
48+
data_path_be,
4949
"Be_snapshot0.out.npy",
50-
data_path,
50+
data_path_be,
5151
)
5252
data_shuffler.add_snapshot(
5353
"Be_snapshot1.in.npy",
54-
data_path,
54+
data_path_be,
5555
"Be_snapshot1.out.npy",
56-
data_path,
56+
data_path_be,
5757
)
5858
# On-the-fly snapshots can be added as well.
5959
# data_shuffler.add_snapshot(
6060
# "Be_snapshot2.info.json",
61-
# data_path,
61+
# data_path_be,
6262
# "Be_snapshot2.out.npy",
63-
# data_path,
63+
# data_path_be,
6464
# )
6565

6666

6767
# Shuffle the snapshots using the "shuffle_to_temporary" option.
6868
data_shuffler.shuffle_snapshots(
69-
complete_save_path=data_path,
69+
complete_save_path=data_path_be,
7070
save_name="Be_shuffled*",
7171
shuffle_to_temporary=True,
7272
number_of_shuffled_snapshots=2,
@@ -116,10 +116,10 @@
116116

117117
data_shuffler = mala.DataShuffler(parameters)
118118
data_shuffler.add_snapshot(
119-
"Be_snapshot0.in.npy", data_path, "Be_snapshot0.out.npy", data_path
119+
"Be_snapshot0.in.npy", data_path_be, "Be_snapshot0.out.npy", data_path_be
120120
)
121121
data_shuffler.add_snapshot(
122-
"Be_snapshot1.in.npy", data_path, "Be_snapshot1.out.npy", data_path
122+
"Be_snapshot1.in.npy", data_path_be, "Be_snapshot1.out.npy", data_path_be
123123
)
124124
data_shuffler.shuffle_snapshots(
125125
complete_save_path=".", save_name="Be_shuffled*"

examples/advanced/ex03_tensor_board.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import mala
44
from mala import printout
55

6-
from mala.datahandling.data_repo import data_path
6+
from mala.datahandling.data_repo import data_path_be
77

88
"""
99
Shows how a NN training by MALA can be visualized using
@@ -33,19 +33,19 @@
3333
data_handler = mala.DataHandler(parameters)
3434
data_handler.add_snapshot(
3535
"Be_snapshot0.in.npy",
36-
data_path,
36+
data_path_be,
3737
"Be_snapshot0.out.npy",
38-
data_path,
38+
data_path_be,
3939
"tr",
40-
calculation_output_file=os.path.join(data_path, "Be_snapshot0.out"),
40+
calculation_output_file=os.path.join(data_path_be, "Be_snapshot0.out"),
4141
)
4242
data_handler.add_snapshot(
4343
"Be_snapshot1.in.npy",
44-
data_path,
44+
data_path_be,
4545
"Be_snapshot1.out.npy",
46-
data_path,
46+
data_path_be,
4747
"va",
48-
calculation_output_file=os.path.join(data_path, "Be_snapshot1.out"),
48+
calculation_output_file=os.path.join(data_path_be, "Be_snapshot1.out"),
4949
)
5050
data_handler.prepare_data()
5151
parameters.network.layer_sizes = [

examples/advanced/ex04_acsd.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22

33
import mala
4-
from mala.datahandling.data_repo import data_path
4+
from mala.datahandling.data_repo import data_path_be
55

66
"""
77
Shows how MALA can be used to optimize descriptor
@@ -32,16 +32,16 @@
3232
####################
3333
hyperoptimizer.add_snapshot(
3434
"espresso-out",
35-
os.path.join(data_path, "Be_snapshot1.out"),
35+
os.path.join(data_path_be, "Be_snapshot1.out"),
3636
"numpy",
37-
os.path.join(data_path, "Be_snapshot1.out.npy"),
37+
os.path.join(data_path_be, "Be_snapshot1.out.npy"),
3838
target_units="1/(Ry*Bohr^3)",
3939
)
4040
hyperoptimizer.add_snapshot(
4141
"espresso-out",
42-
os.path.join(data_path, "Be_snapshot2.out"),
42+
os.path.join(data_path_be, "Be_snapshot2.out"),
4343
"numpy",
44-
os.path.join(data_path, "Be_snapshot2.out.npy"),
44+
os.path.join(data_path_be, "Be_snapshot2.out.npy"),
4545
target_units="1/(Ry*Bohr^3)",
4646
)
4747

0 commit comments

Comments
 (0)