Skip to content

Use metatensor public API instead of private methods#438

Merged
Luthaf merged 3 commits into
mainfrom
use-public-metatensor-api
Jun 25, 2026
Merged

Use metatensor public API instead of private methods#438
Luthaf merged 3 commits into
mainfrom
use-public-metatensor-api

Conversation

@johannes-spies

@johannes-spies johannes-spies commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Description

featomic's Python package calls several metatensor methods that were made public in metatensor v0.2 (the leading underscore was dropped). metatensor only kept the private names around as backward-compat shims for featomic, with the note "used by featomic, kept here until we update featomic to use the public API."

This PR is that update, migrating calculator_base.py to the public API:

Before (private) After (public)
Labels._as_mts_labels_t() Labels.as_mts_labels_t()
TensorMap._ptr TensorMap.as_mts_tensormap_t()
TensorMap._from_ptr() TensorMap.unsafe_from_ptr()

Semantics are unchanged: as_mts_tensormap_t() returns a borrowed pointer (metatensor keeps ownership), matching the old ._ptr and the borrowed predefined field, while unsafe_from_ptr() takes ownership of the freshly-allocated result.

Once this lands, metatensor can drop the shims from metatensor#1146.

Fixes #437.

🤖 Generated with Claude Code

📚 Download documentation for this pull-request

Migrate the Python package off metatensor's private methods, which were
made public in metatensor v0.2 and only kept as shims for featomic:

- Labels._as_mts_labels_t() -> Labels.as_mts_labels_t()
- TensorMap._ptr            -> TensorMap.as_mts_tensormap_t()
- TensorMap._from_ptr()     -> TensorMap.unsafe_from_ptr()

This lets metatensor drop the backward-compat shims added in
metatensor#1146. Fixes #437.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@johannes-spies johannes-spies force-pushed the use-public-metatensor-api branch from 341965d to 93f2f5f Compare June 24, 2026 16:56
@johannes-spies johannes-spies requested a review from Luthaf June 24, 2026 16:59
johannes-spies and others added 2 commits June 24, 2026 19:12
The switch to the public `as_mts_tensormap_t()` API pushed this line
over the line-length limit; wrap it to satisfy `ruff format`.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
ASE moved its documentation; the old wiki.fysik.dtu.dk/ase/ URL now
redirects to ase-lib.org where objects.inv 404s, breaking the docs
build. The inventory now lives at https://docs.ase-lib.org/.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Luthaf Luthaf merged commit aaebbb6 into main Jun 25, 2026
21 checks passed
@Luthaf Luthaf deleted the use-public-metatensor-api branch June 25, 2026 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Featomic not consistent with metatensor>=0.2

2 participants