`get_feature_index_mapping` does not support `global_species`
Luthaf opened this issue · 1 comments
Here is a script demonstrating the issue:
import ase
from rascal.representations import SphericalInvariants
HYPERS = {
"soap_type": "PowerSpectrum",
"interaction_cutoff": 4.5,
"max_radial": 6,
"max_angular": 6,
"gaussian_sigma_constant": 0.3,
"gaussian_sigma_type": "Constant",
"cutoff_smooth_width": 0.5,
"radial_basis": "GTO",
"compute_gradients": False,
"normalize": True,
"expansion_by_species_method": "user defined",
"global_species": [1, 6, 7, 8],
}
soap = SphericalInvariants(**HYPERS)
frame = ase.Atoms(
symbols="CO2",
positions=[
(5, 5, 5),
(5, 5, 5 - 2),
(5, 5, 5 + 2),
],
cell=[10, 10, 10],
)
X = soap.transform([frame]).get_features(soap)
mapping = soap.get_feature_index_mapping([frame])
print(len(mapping))
print(X.shape)
assert len(mapping) == X.shape[1]
This will print 756 2520
and then fail the assertion.
I understand why get_feature_index_mapping
need to take the managers as parameter, since the features could change depending on which species are present in the structures. But get_feature_index_mapping
should deal with all possible expansion_by_species_method
.
A temporary workaround is to call get_feature_index_mapping
with a specially constructed frame:
mapping = soap.get_feature_index_mapping([ase.Atoms("CHNO")])
Hi! Adding a note to this issue. When masking several species, I still want them to come up in the mapping, e.g. if I only get the soap vectors for oxygen centers but there are hydrogens present, I want to see the mapping including all 1-1, 1-8, and 8-8, not just 8-8.