Skip to content
This repository was archived by the owner on Jan 15, 2026. It is now read-only.
This repository was archived by the owner on Jan 15, 2026. It is now read-only.

get_feature_index_mapping does not support global_species #386

Description

@Luthaf

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")])

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions