metatensor 0.4.2

Self-describing sparse tensor data format for atomistic machine learning and beyond
# Changelog

All notable changes to the metatensor Rust crate are documented here, following
the [keep a changelog](https://keepachangelog.com/en/1.1.0/) format. This
project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]https://github.com/metatensor/metatensor/

<!--
### Added

### Fixed

### Changed

### Removed
-->

## [Version 0.4.2]https://github.com/metatensor/metatensor/releases/tag/metatensor-rust-v0.4.2 - 2026-07-03

### Added

- `load_custom_array`, `load_buffer_custom_array`, `load_block_custom_array`,
  and `load_block_buffer_custom_array` functions to load TensorMaps and
  TensorBlocks with custom array types.

## [Version 0.4.1]https://github.com/metatensor/metatensor/releases/tag/metatensor-rust-v0.4.1 - 2026-06-24

### Fixed

- Fix build issues with MSVC, where using metatensor inside another rust project
  could create too deeply nested path.

## [Version 0.4.0]https://github.com/metatensor/metatensor/releases/tag/metatensor-rust-v0.4.0 - 2026-06-10

### Added

- `TensorMap::device`, `TensorMap::dtype`, `TensorBlock::device`, and
  `TensorBlock::dtype` for retrieving the device and data type of the underlying
  arrays.
- `TensorMap::{from,into}_raw`, `TensorBlock::{from,into}_raw` and
  `Labels::{from,into}_raw` to enable conversion between Rust and C API types.
- `Labels::new_assume_unique`, replacing `LabelsBuilder::finish_assume_unique`.

### Removed

- Removed `LabelsBuilder`, and changed `Labels::new` to take something that can
  be converted into an `MtsArray` of i32 as the values.

### Changed

- Labels in a `TensorBlock` are now checked to be on the same device as the
  values. `TensorMap::new` also checks that the keys are on the same device as
  the blocks.

## [Version 0.3.0]https://github.com/metatensor/metatensor/releases/tag/metatensor-rust-v0.3.0 - 2026-05-13

### Added

- Added `MtsArray` as a safe wrapper around an owned `mts_array_t`

### Changed

- Renamed `ArrayRef{Mut}::{as,to}_array` to `ArrayRef{Mut}::{as,to}_ndarray`
- The default array is now based on `Arc<RwLock<ndarray::ArrayD<T>>>`, to allow
  passing data back to other languages through DLPack while enforcing Rust's
  mutable XOR shared rules.
- `Labels::select` now returns a `Vec<usize>` instead of a `Vec<i64>`

### Removed

- Removed `Array::data()` trait method and all implementations. Use
  `mts_array_t.as_dlpack` instead, which supports all numeric types via the
  DLPack standard rather than only float64.
- Removed `TensorMap::blocks_matching`, the same behavior can be achieved
  with `TensorMap::keys().select(...)`.

## [Version 0.2.4]https://github.com/metatensor/metatensor/releases/tag/metatensor-rust-v0.2.4 - 2026-03-05

### Changed

- Bumped the ndarray dependency to `0.17`

## [Version 0.2.3]https://github.com/metatensor/metatensor/releases/tag/metatensor-rust-v0.2.3 - 2025-12-05

### Added

- It is now possible to store and retrieve global metatadata about a TensorMap,
  in the form of string key/value pairs. You can use `TensorMap::set_info`,
  `TensorMap::get_info` and `TensorMap::info` to manipulate this information.

## [Version 0.2.2]https://github.com/metatensor/metatensor/releases/tag/metatensor-rust-v0.2.2 - 2025-07-29

### Added

- `LabelsBuilder::finish_assume_unique` which allows bypassing a check when the
  user can ensure beforehand that all entries will be unique.

## [Version 0.2.1]https://github.com/metatensor/metatensor/releases/tag/metatensor-rust-v0.2.1 - 2025-04-10

### Added

- `Labels::difference` for finding the set difference between two `Labels`

## [Version 0.2.0]https://github.com/metatensor/metatensor/releases/tag/metatensor-rust-v0.2.0 - 2024-09-24

### Changed

- The code now requires Rustc v1.74 to build.
- We now depend on `ndarray=^0.16`

## [Version 0.1.6]https://github.com/metatensor/metatensor/releases/tag/metatensor-rust-v0.1.6 - 2024-09-10

### Added

- Added support for serialization of TensorBlock with `TensorBlock::load`,
  `TensorBlock::load_buffer`, `TensorBlock::save`, `TensorBlock::save_buffer`
  and the corresponding functions in `metatensor::io`.
- `Labels::select` function, to sub-select labels entries.

## [Version 0.1.5]https://github.com/metatensor/metatensor/releases/tag/metatensor-rust-v0.1.5 - 2024-03-12

### Fixed

- Re-export C API bindings in the `metatensor::c_api` module (#549)

## [Version 0.1.4]https://github.com/metatensor/metatensor/releases/tag/metatensor-rust-v0.1.4 - 2024-03-12

### Changed

- Bindings to the raw C API are now part of the `metatensor-sys` crate (#535)

## [Version 0.1.3]https://github.com/metatensor/metatensor/releases/tag/metatensor-rust-v0.1.3 - 2024-02-12

### Fixed

- Fixed build with older versions of rustc by pinning dependencies of
  metatensor-core (#505 and #506)

## [Version 0.1.2]https://github.com/metatensor/metatensor/releases/tag/metatensor-rust-v0.1.2 - 2024-01-26

### Added

- Offer serialization functionality as associated functions (i.e. `TensorMap::load`)
  in addition to the existing free standing functions (i.e. `metatensor::io::load`) (#453)

- Serialization of labels with `Labels::save`, `Labels::load`,
  `Labels::save_buffer`, `Labels::load_buffer` and the corresponding free
  functions. (#455)

## [Version 0.1.1]https://github.com/metatensor/metatensor/releases/tag/metatensor-rust-v0.1.1 - 2024-01-05

### Fixed

- Fixed the build with Cargo 1.75

## [Version 0.1.0]https://github.com/metatensor/metatensor/releases/tag/metatensor-rust-v0.1.0 - 2023-10-11

### Added

- Rust bindings to all metatensor-core class: `Labels`, `LabelsEntry`,
  `TensorBlock`, and `TensorMap`;
- Rust binding of `mts_array_t` through the `Array` trait;
- Implementation of `Array` for [ndarray]https://docs.rs/ndarray/;
- Parallel iteration over labels entries and blocks using [rayon]https://docs.rs/rayon/;