Skip to content

[Code scan] Fix NumPy API mistakes in AtomicDataDict vector lengths #36

Description

@njzjz

This issue comes from a Codex global repository scan.

Problem

AtomicDataDict.with_env_vectors() and with_onsitenv_vectors() call np.linalg.norm(..., dim=-1), but dim is a Torch argument, not a NumPy argument:

data[_keys.ENV_VECTORS_KEY] = env_vec
if with_lengths:
data[_keys.ENV_LENGTH_KEY] = np.linalg.norm(env_vec, dim=-1)
return data

data[_keys.ONSITENV_VECTORS_KEY] = env_vec
if with_lengths:
data[_keys.ONSITENV_LENGTH_KEY] = np.linalg.norm(env_vec, dim=-1)
return data

This raises TypeError whenever lengths are requested.

Suggested fix

Use axis=-1 for NumPy:

np.linalg.norm(env_vec, axis=-1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions