Skip to content

Commit b88f254

Browse files
committed
Basic formatting
1 parent 848ff00 commit b88f254

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

docs/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ sphinx-gallery
66
sphinx-toggleprompt
77
setuptools # required for sphinxcontrib-bibtex together with Python 3.13
88
tomli
9-
sphericart-torch
9+
sphericart-torch # for SOAP-BPNN + tensor basis example

examples/programmatic/tensor_basis/save_tensor_map.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
from featomic.torch.clebsch_gordan import cartesian_to_spherical
66

77

8-
# %%
9-
#
10-
# Read a subset of 1000 molecules from the QM7x dataset in the XYZ format decorated with
8+
# Read a subset of 100 molecules from the QM7x dataset in the XYZ format decorated with
119
# the polarizability (Cartesian) tensor.
1210
# Extract the polarizability from the ase.Atoms.info dictionary.
1311
#
@@ -16,11 +14,8 @@
1614
[molecule.info["polarizability"].reshape(3, 3) for molecule in molecules]
1715
)
1816

19-
# %%
20-
#
2117
# Create a ``metatensor.torch.TensorMap`` containing the Cartesian polarizability tensor
2218
# values and the respective metadata
23-
2419
cartesian_tensormap = mts.TensorMap(
2520
keys=mts.Labels.single(),
2621
blocks=[
@@ -33,24 +28,18 @@
3328
],
3429
)
3530

36-
# %%
37-
#
3831
# Extract from the Cartesian polarizability tensor its irreducible spherical components
39-
4032
spherical_tensormap = mts.remove_dimension(
4133
cartesian_to_spherical(cartesian_tensormap, components=["xyz_1", "xyz_2"]),
4234
"keys",
4335
"_",
4436
)
4537

46-
# %%
47-
#
4838
# We drop the block with ``o3_sigma=-1``, as polarizability should be symmetric and
4939
# therefore any non-zero pseudo-vector component is spurious.
5040
spherical_tensormap = mts.drop_blocks(
5141
spherical_tensormap, mts.Labels(["o3_sigma"], torch.tensor([[-1]]))
5242
)
53-
# %%
54-
#
55-
# Let's save the spherical components of the polarizability tensor to disk
43+
44+
# Save the spherical components of the polarizability tensor to disk
5645
mts.save("spherical_polarizability.mts", spherical_tensormap)

examples/programmatic/tensor_basis/tensor_basis.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@
1818
import numpy as np
1919

2020

21+
# %%
22+
#
23+
# First, we need to prepare the dataset by saving the polarizability in
24+
# the form of spherical tensors. This is done using the ``metatensor`` library.
25+
#
26+
# .. literalinclude:: save_tensor_map.py
27+
# :language: python
28+
2129
# %%
2230
#
2331
# Write the metatrain ``options.yaml`` file for the training of the polarizability
@@ -57,7 +65,8 @@
5765

5866
# %%
5967
#
60-
# In case you need to export a specific checkpoints, you can do so using:
68+
# In case you need to export a specific checkpoint (most likely from the ``outputs``
69+
# directory), you can do so using:
6170
#
6271
# .. code:: bash
6372
#

0 commit comments

Comments
 (0)