Skip to content

Commit 8d221e9

Browse files
authored
Merge pull request ACEsuit#265 from ACEsuit/testtut
Final Cleanup Before Registering 0.8.0
2 parents a937f62 + 1c7c050 commit 8d221e9

File tree

17 files changed

+77
-42
lines changed

17 files changed

+77
-42
lines changed

docs/src/tutorials/basic_julia_workflow.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ result = acefit!(train_data, model; solver=solver, prior = P, weights=weights);
6767
# We can display an error table as follows:
6868

6969
@info("Training Error Table")
70-
err_train = ACEpotentials.linear_errors(train_data, model; weights=weights);
70+
err_train = ACEpotentials.compute_errors(train_data, model; weights=weights);
7171

7272
# We should of course also look at test errors, which can be done as follows. Depending on the choice of solver, and solver parameters, the test errors might be very poor. Exploring different parameters in different applications can lead to significantly improved predictions.
7373

7474
@info("Test Error Table")
75-
err_test = ACEpotentials.linear_errors(test_data, model; weights=weights);
75+
err_test = ACEpotentials.compute_errors(test_data, model; weights=weights);
7676

7777
# If we want to save the fitted potentials to disk to later use we can simply save the hyperparameters and the parameters. At the moment this must be done manually but a more complete and convenient interface for this will be provided, also adding various sanity checks.
7878

docs/src/tutorials/smoothness_priors.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ for (prior_name, P) in priors
6161
set_parameters!(_modl, P \ c̃)
6262

6363
## compute errors and store them for later use (don't print them here)
64-
errs = linear_errors(rawdata, model; verbose=false, datakeys...)
64+
errs = compute_errors(rawdata, model; verbose=false, datakeys...)
6565
rmse[prior_name] = errs["rmse"]["set"]["F"]
6666
pots[prior_name] = _modl
6767
println(" force=rmse = ", rmse[prior_name])

docs/src_outdated/AtomsBase_interface.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ P = smoothness_prior(model; p = 4)
6060
acefit!(model, data_train; solver=solver, weights=weights, prior = P);
6161

6262
@info("Training Error Table")
63-
ACEpotentials.linear_errors(data_train, model; weights=weights);
63+
ACEpotentials.compute_errors(data_train, model; weights=weights);
6464
```
6565

6666
### Training data in AtomsBase structures

docs/src_outdated/TiAl_basis.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ test = [ACEpotentials.AtomsData(t; weights=weights, v_ref=Vref, datakeys...) for
7676

7777
@info("Test Error Tables")
7878
@info("First Potential: ")
79-
ACEpotentials.linear_errors(test, pot_1);
79+
ACEpotentials.compute_errors(test, pot_1);
8080

8181
@info("Second Potential: ")
82-
ACEpotentials.linear_errors(test, pot_2);
82+
ACEpotentials.compute_errors(test, pot_2);
8383

8484
# If we want to save the fitted potentials to disk to later use we can use one of the following commands: the first saves the potential as an `ACE1.jl` compatible potential, while the second line exports it to a format that can be ready by the `pacemaker` code to be used within LAMMPS. This functionality is currently disabled.
8585
#

docs/src_outdated/first_example_model.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ acefit!(model, train; solver=solver, data_keys...);
5151
# To see the training errors we can use
5252

5353
@info("Training Errors")
54-
ACEpotentials.linear_errors(train, model; data_keys...);
54+
ACEpotentials.compute_errors(train, model; data_keys...);
5555

5656
# ### Step 4: Run some tests
5757
#
5858
# At a minimum one should have a test set, check the errors on that test set, and confirm that they are similar as the training errors.
5959

6060
@info("Test Errors")
6161
test = [gen_dat() for _=1:20]
62-
ACEpotentials.linear_errors(test, model; data_keys...);
62+
ACEpotentials.compute_errors(test, model; data_keys...);
6363

6464
# If we wanted to perform such a test ``manually'' it might look like this:
6565

examples/Tutorial/ACEpotentials-Tutorial.jl

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ Pkg.add(["LaTeXStrings", "MultivariateStats", "Plots", "PrettyTables",
2525
"Suppressor", "ExtXYZ", "Unitful", "Distributed", "AtomsCalculators",
2626
])
2727

28-
## ACEpotentials installation
29-
using Pkg
30-
Pkg.activate(".")
28+
## ACEpotentials installation:
29+
## If ACEpotentials has not been installed yet, uncomment the following lines
30+
## using Pkg; Pkg.activate(".")
3131
## Add the ACE registry, which stores the ACEpotential package information
32-
Pkg.Registry.add(RegistrySpec(url="https://github.com/ACEsuit/ACEregistry"))
33-
Pkg.add("ACEpotentials")
32+
## Pkg.Registry.add(RegistrySpec(url="https://github.com/ACEsuit/ACEregistry"))
33+
## Pkg.add("ACEpotentials")
3434

3535
# We can check the status of the installed packages.
3636

@@ -247,10 +247,10 @@ acefit!(Si_tiny_dataset, model;
247247
solver=solver, data_keys...);
248248

249249
@info("Training Errors")
250-
linear_errors(Si_tiny_dataset, model; data_keys...);
250+
compute_errors(Si_tiny_dataset, model; data_keys...);
251251

252252
@info("Test Error")
253-
linear_errors(Si_dataset, model; data_keys...);
253+
compute_errors(Si_dataset, model; data_keys...);
254254

255255
# Export to LAMMPS is currently not supported. Earlier versions of
256256
# `ACEpotentials` supported this via
@@ -376,6 +376,7 @@ assess_model(new_model, new_dataset)
376376
# structures in total.
377377

378378
for i in 1:4
379+
global new_dataset, new_model # declare these are global variables
379380
@show i
380381
new_dataset, new_model = augment(new_dataset, new_model; num=5);
381382
end
@@ -424,7 +425,7 @@ model = ace1_model(elements = [:Ti, :Al],
424425
# and it is fit in the same manner.
425426

426427
acefit!(tial_data[1:5:end], model);
427-
linear_errors(tial_data[1:5:end], model);
428+
compute_errors(tial_data[1:5:end], model);
428429

429430
# ## Part 6: Recreate data from the ACEpotentials.jl paper
430431
#
@@ -455,6 +456,7 @@ totaldegree = [ 20, 16, 12 ] # small model: ~ 300 basis functions
455456
errors = Dict("E" => Dict(), "F" => Dict())
456457

457458
for element in elements
459+
local model # treat `model` as a variable local to the scope of `for`
458460
## load the dataset
459461
@info("---------- loading $(element) dataset ----------")
460462
train, test, _ = ACEpotentials.example_dataset("Zuo20_$element")
@@ -464,7 +466,7 @@ for element in elements
464466
## train the model
465467
acefit!(train, model, solver = ACEfit.BLR(; factorization = :svd))
466468
## compute and store errors
467-
err = linear_errors(test, model)
469+
err = compute_errors(test, model)
468470
errors["E"][element] = err["mae"]["set"]["E"] * 1000
469471
errors["F"][element] = err["mae"]["set"]["F"]
470472
end
@@ -523,4 +525,4 @@ pretty_table(f_table; header = header)
523525
# - Use an `ACEpotentials.jl` potential with ASE:
524526
# https://acesuit.github.io/ACEpotentials.jl/dev/tutorials/python_ase/
525527
# - Install LAMMPS with `ACEpotentials` patch:
526-
# https://acesuit.github.io/ACEpotentials.jl/dev/tutorials/lammps/
528+
# https://acesuit.github.io/ACEpotentials.jl/dev/tutorials/lammps/

examples/zuobench/error_table.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ for sym in syms
3333
acefit!(train, model_lge; solver=solver); GC.gc()
3434

3535
# compute and store errors for later visualisation
36-
err_sm = ACEpotentials.linear_errors(test, model_sm)
37-
err_lge = ACEpotentials.linear_errors(test, model_lge)
36+
err_sm = ACEpotentials.compute_errors(test, model_sm)
37+
err_lge = ACEpotentials.compute_errors(test, model_lge)
3838
err["sm" ]["E"][sym] = err_sm["mae"]["set"]["E"] * 1000
3939
err["sm" ]["F"][sym] = err_sm["mae"]["set"]["F"]
4040
err["lge"]["E"][sym] = err_lge["mae"]["set"]["E"] * 1000

examples/zuobench/error_table_svd.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ for sym in syms
3535
acefit!(train, model_lge; solver=solver); GC.gc()
3636

3737
# compute and store errors for later visualisation
38-
err_sm = ACEpotentials.linear_errors(test, model_sm)
39-
err_lge = ACEpotentials.linear_errors(test, model_lge)
38+
err_sm = ACEpotentials.compute_errors(test, model_sm)
39+
err_lge = ACEpotentials.compute_errors(test, model_lge)
4040
err["sm_blr" ]["E"][sym] = err_sm["mae"]["set"]["E"] * 1000
4141
err["sm_blr" ]["F"][sym] = err_sm["mae"]["set"]["F"]
4242
err["lge_blr"]["E"][sym] = err_lge["mae"]["set"]["E"] * 1000
@@ -50,8 +50,8 @@ for sym in syms
5050
solver = ACEfit.TruncatedSVD() # truncation will be determined from validation set
5151
acefit!(train1, model_sm; validation_set = val1, solver=solver); GC.gc()
5252
acefit!(train1, model_lge; validation_set = val1, solver=solver); GC.gc()
53-
err_sm = ACEpotentials.linear_errors(test, model_sm)
54-
err_lge = ACEpotentials.linear_errors(test, model_lge)
53+
err_sm = ACEpotentials.compute_errors(test, model_sm)
54+
err_lge = ACEpotentials.compute_errors(test, model_lge)
5555
err["sm_svd" ]["E"][sym] = err_sm["mae"]["set"]["E"] * 1000
5656
err["sm_svd" ]["F"][sym] = err_sm["mae"]["set"]["F"]
5757
err["lge_svd"]["E"][sym] = err_lge["mae"]["set"]["E"] * 1000

examples/zuobench/zuo_asp.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ pot_300 = fast_evaluator(model_300; aa_static = true)
5555
pot_100 = fast_evaluator(model_100; aa_static = true)
5656

5757
@info("Evaluate errors on the test set")
58-
err_100 = ACEpotentials.linear_errors(test_data, pot_100)
59-
err_300 = ACEpotentials.linear_errors(test_data, pot_300)
60-
err_1000 = ACEpotentials.linear_errors(test_data, pot_1000)
58+
err_100 = ACEpotentials.compute_errors(test_data, pot_100)
59+
err_300 = ACEpotentials.compute_errors(test_data, pot_300)
60+
err_1000 = ACEpotentials.compute_errors(test_data, pot_1000)
6161

6262
##
6363

ext_tests/tutorial/run_tutorial.jl

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Run this test using
2+
# julia --project=. run_tutorial.jl
3+
# if the command fails, then clean the folder using
4+
# rm ACEpotentials-Tutorial.jl ACEpotentials-Tutorial.ipynb Project.toml Manifest.toml Si_dataset.xyz Si_tiny_tutorial.json
5+
6+
julia_cmd = Base.julia_cmd()
7+
appath = abspath(joinpath(@__DIR__(), "..", ".."))
8+
setuptutorial = """
9+
begin
10+
using Pkg;
11+
Pkg.develop(; path = \"$appath\");
12+
using ACEpotentials;
13+
ACEpotentials.copy_tutorial();
14+
end
15+
"""
16+
17+
run(`$julia_cmd --project=. -e $setuptutorial`)
18+
19+
if !isfile("ACEpotentials-Tutorial.ipynb")
20+
error("Tutorial notebook not installed.")
21+
end
22+
23+
tutorial_file = joinpath(appath, "examples", "Tutorial", "ACEpotentials-Tutorial.jl")
24+
cp(tutorial_file, joinpath(pwd(), "ACEpotentials-Tutorial.jl"); force=true)
25+
26+
run(`$julia_cmd --project=. ACEpotentials-Tutorial.jl`)
27+
28+
@info("Cleaning up")
29+
run(`rm ACEpotentials-Tutorial.jl ACEpotentials-Tutorial.ipynb Project.toml Manifest.toml Si_dataset.xyz Si_tiny_tutorial.json`)

0 commit comments

Comments
 (0)