-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initalize clebsch_gordan submodule in rascaline.torch
- Loading branch information
1 parent
c0fc125
commit 667c1ef
Showing
5 changed files
with
541 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
python/rascaline-torch/rascaline/torch/utils/clebsch_gordan.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import importlib | ||
import sys | ||
from typing import List, Optional, Union | ||
|
||
import torch | ||
from metatensor.torch import Labels, TensorBlock, TensorMap | ||
|
||
import rascaline.utils.clebsch_gordan | ||
|
||
|
||
# For details what is happening here take a look an `rascaline.torch.calculators`. | ||
|
||
# Step 1: create te `_classes` module as an empty module | ||
spec = importlib.util.spec_from_loader( | ||
"rascaline.torch.utils.clebsch_gordan._classes", | ||
loader=None, | ||
) | ||
module = importlib.util.module_from_spec(spec) | ||
# This module only exposes a handful of things, defined here. Any changes here MUST also | ||
# be made to the `metatensor/operations/_classes.py` file, which is used in non | ||
# TorchScript mode. | ||
module.__dict__["Labels"] = Labels | ||
module.__dict__["TensorBlock"] = TensorBlock | ||
module.__dict__["TensorMap"] = TensorMap | ||
|
||
# register the module in sys.modules, so future import find it directly | ||
sys.modules[spec.name] = module | ||
|
||
|
||
# Step 2: create a module named `rascaline.torch.utils.clebsch_gordan` using code from | ||
# `rascaline.utils.clebsch_gordan` | ||
spec = importlib.util.spec_from_file_location( | ||
"rascaline.torch.utils.clebsch_gordan", | ||
rascaline.utils.clebsch_gordan.__file__, | ||
) | ||
|
||
module = importlib.util.module_from_spec(spec) | ||
sys.modules[spec.name] = module | ||
spec.loader.exec_module(module) |
Oops, something went wrong.