Skip to content

Commit 8a39cad

Browse files
authored
Add a changelog for Version 0.17.0 (#1527)
1 parent 0d75035 commit 8a39cad

File tree

1 file changed

+122
-0
lines changed

1 file changed

+122
-0
lines changed

RELEASES.md

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,125 @@
1+
Version 0.17.0 (2025-10-13)
2+
===========================
3+
Version 0.17.0 introduces a new **array reference type** — the preferred way to write functions and extension traits in `ndarray`.
4+
This release is fully backwards-compatible but represents a major usability improvement.
5+
The first section of this changelog explains the change in detail.
6+
7+
It also includes numerous new methods, math functions, and internal improvements — all credited below.
8+
9+
A New Way to Write Functions
10+
-------------
11+
12+
### TL;DR
13+
`ndarray` 0.17.0 adds new reference types for writing functions and traits that work seamlessly with owned arrays and views.
14+
15+
When writing functions that accept array arguments:
16+
- **Use `&ArrayRef<A, D>`** to read elements from any array.
17+
- **Use `&mut ArrayRef<A, D>`** to modify elements.
18+
- **Use `&T where T: AsRef<LayoutRef<A, D>>`** to inspect shape/stride only.
19+
- **Use `&mut T where T: AsMut<LayoutRef<A, D>>`** to modify shape/stride only.
20+
21+
All existing function signatures continue to work; these new types are fully opt-in.
22+
23+
### Background
24+
ndarray has multiple ways to write functions that take arrays (a problem captured well in issue [#1059](https://github.com/rust-ndarray/ndarray/issues/1059)).
25+
For example:
26+
```rust
27+
fn sum(a: ArrayView1<f64>) -> f64;
28+
fn sum(a: &ArrayView1<f64>) -> f64;
29+
fn sum(a: &Array1<f64>) -> f64;
30+
```
31+
All of these work, but having several equivalent forms causes confusion.
32+
The most general solution, writing generically over storage types:
33+
```rust
34+
fn sum<S>(a: &ArrayBase<S, Ix1>) -> f64
35+
where S: Data<Elem = f64>;
36+
```
37+
is powerful but verbose and often hard to read.
38+
Version 0.17.0 introduces a new, simpler pattern that expresses the same flexibility more clearly.
39+
40+
### Solution
41+
Three new reference types make it easier to write functions that accept any kind of array while clearly expressing what kind of access (data or layout) they need.
42+
43+
#### Reading / Writing Elements: `ArrayRef<A, D>`
44+
`ArrayRef` is the `Deref` target of `ArrayBase`.
45+
It behaves like `&[T]` for `Vec<T>`, giving access to elements and layout.
46+
Mutability is expressed through the reference itself (`&` vs `&mut`), not through a trait bound or the type itself.
47+
It is used as follows:
48+
```rust
49+
fn sum(a: &ArrayRef1<f64>) -> f64;
50+
fn cumsum_mut(a: &mut ArrayRef1<f64>);
51+
```
52+
(ArrayRef1 is available from the prelude.)
53+
54+
#### Reading / Writing Shape: `LayoutRef<A, D>`
55+
LayoutRef lets functions view or modify shape/stride information without touching data.
56+
This replaces verbose signatures like:
57+
```rust
58+
fn alter_view<S>(a: &mut ArrayBase<S, Ix1>)
59+
where S: Data<Elem = f64>;
60+
```
61+
Use AsRef / AsMut for best compatibility:
62+
```rust
63+
fn alter_shape<T>(a: &mut T)
64+
where T: AsMut<LayoutRef<f64>>;
65+
```
66+
(Accepting a `LayoutRef` directly can cause unnecessary copies; see [#1440](https://github.com/rust-ndarray/ndarray/pull/1440).)
67+
68+
#### Reading / Writing Unsafe Elements: `RawRef<A, D>`
69+
`RawRef` augments `RawArrayView` and `RawArrayViewMut` for power users needing unsafe element access (e.g. uninitialized buffers).
70+
Like `LayoutRef`, it is best used via `AsRef` / `AsMut`.
71+
72+
Added
73+
-----
74+
- A new "array reference" type by [@akern40](https://github.com/akern40) [#1440](https://github.com/rust-ndarray/ndarray/pull/1440)
75+
- A `diff` method for calculating the difference between elements by [@johann-cm](https://github.com/johann-cm) [#1437](https://github.com/rust-ndarray/ndarray/pull/1437)
76+
- A `partition` method for partially sorting an array by [@NewBornRustacean](https://github.com/NewBornRustacean) [#1498](https://github.com/rust-ndarray/ndarray/pull/1498)
77+
- A `meshgrid` method for building regular grids of values by [@akern40](https://github.com/akern40) [#1477](https://github.com/rust-ndarray/ndarray/pull/1477)
78+
- A `cumprod` method for cumulative products by [@NewBornRustacean](https://github.com/NewBornRustacean) [#1491](https://github.com/rust-ndarray/ndarray/pull/1491)
79+
- More element-wise math functions for floats by [@Waterdragen](https://github.com/Waterdragen) [#1507](https://github.com/rust-ndarray/ndarray/pull/1507)
80+
- Additions include `exp_m1`, `ln_1p`, `asin`, `acos`, `atan`, `sinh`, `cosh`, `tanh`, `asinh`, `acosh`, `atanh`, and `hypot`
81+
- Dot product support for dynamic arrays by [@NewBornRustacean](https://github.com/NewBornRustacean) [#1483](https://github.com/rust-ndarray/ndarray/pull/1483) and [@akern40](https://github.com/akern40) [#1494](https://github.com/rust-ndarray/ndarray/pull/1494)
82+
- An `axis_windows_with_stride` method for strided windows by [@goertzenator](https://github.com/goertzenator) [#1460](https://github.com/rust-ndarray/ndarray/pull/1460)
83+
- In-place methods for permuting (`permute_axes`) and reversing (`reverse_axes`) axes by [@NewBornRustacean](https://github.com/NewBornRustacean) [#1505](https://github.com/rust-ndarray/ndarray/pull/1505)
84+
- Adds `into_*_iter` functions as lifetime-preserving versions of into-iterator functionality by [@akern40](https://github.com/akern40) [#1510](https://github.com/rust-ndarray/ndarray/pull/1510)
85+
86+
Changed
87+
-------
88+
- `remove_index` can now be called on views, in addition to owned arrays by [@akern40](https://github.com/akern40)
89+
90+
Removed
91+
-------
92+
- Removed the `serde-1`, `test`, and `docs` feature flags; by [@akern40](https://github.com/akern40) [#1479](https://github.com/rust-ndarray/ndarray/pull/1479)
93+
- Use `approx,serde,rayon` instead of `docs`.
94+
- Use `serde` instead of `serde-1`
95+
96+
97+
Fixed
98+
-----
99+
- `last_mut()` now guarantees that the underlying data is uniquely held by [@bluss](https://github.com/bluss) [#1429](https://github.com/rust-ndarray/ndarray/pull/1429)
100+
- `ArrayView` is now covariant over lifetime by [@akern40](https://github.com/akern40) [#1480](https://github.com/rust-ndarray/ndarray/pull/1480), so that the following code now compiles
101+
```rust
102+
fn fn_cov<'a>(x: ArrayView1<'static, f64>) -> ArrayView1<'a, f64> {
103+
x
104+
}
105+
```
106+
107+
Documentation
108+
-----
109+
- Filled missing documentation and adds warn(missing_docs) by [@akern40](https://github.com/akern40)
110+
- Fixed a typo in the documentation of `select` by [@Drazhar](https://github.com/Drazhar)
111+
- Fixed a typo in the documentation of `into_raw_vec_and_offset` by [@benliepert](https://github.com/benliepert)
112+
- Documented `Array::zeros` with how to control the return type by [@akern40](https://github.com/akern40)
113+
114+
Other
115+
-----
116+
- Expanded the gitignore file for IDEs by [@XXMA16](https://github.com/XXMA16) and [@akern40](https://github.com/akern40)
117+
- Stabilized the MSRV to 1.64 by [@akern40](https://github.com/akern40)
118+
- Switched to nextest for testing by [@akern40](https://github.com/akern40)
119+
- Added Miri to CI by [@akern40](https://github.com/akern40)
120+
- Smoothed out tests that can be run with `no_std` by [@akern40](https://github.com/akern40)
121+
- Updated to Edition 2021 by [@akern40](https://github.com/akern40)
122+
1123
Version 0.16.1 (2024-08-14)
2124
===========================
3125

0 commit comments

Comments
 (0)