Skip to content

Commit dcbbb23

Browse files
committed
Edition 2024.
1 parent 3997dda commit dcbbb23

File tree

14 files changed

+152
-113
lines changed

14 files changed

+152
-113
lines changed

Cargo.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[package]
22
name = "ndarray-histogram"
3-
version = "0.4.0"
4-
rust-version = "1.74.0"
5-
edition = "2021"
3+
version = "0.5.0"
4+
rust-version = "1.85.0"
5+
edition = "2024"
66
authors = ["Rouven Spreckels <[email protected]>"]
77
license = "MIT OR Apache-2.0"
88
repository = "https://github.com/qu1x/ndarray-histogram"
@@ -14,12 +14,12 @@ categories = ["data-structures", "science"]
1414

1515
[dependencies]
1616
ndarray = "0.16.1"
17-
ndarray-slice = { version = "0.4.0", default-features = false, features = ["std"] }
18-
ordered-float = "4.2.2"
17+
ndarray-slice = { version = "0.5.1", default-features = false, features = ["std"] }
18+
ordered-float = "5.0.0"
1919
num-integer = "0.1.46"
2020
num-traits = "0.2.19"
21-
rand = "0.8.5"
22-
itertools = { version = "0.13.0", default-features = false }
21+
rand = "0.9.0"
22+
itertools = { version = "0.14.0", default-features = false }
2323
rayon = { version = "1.10.0", optional = true }
2424

2525
[dev-dependencies]

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
[Documentation]: https://docs.rs/ndarray-histogram/badge.svg
1212
[Downloads]: https://img.shields.io/crates/d/ndarray-histogram.svg
1313
[Version]: https://img.shields.io/crates/v/ndarray-histogram.svg
14-
[Rust]: https://img.shields.io/badge/rust-v1.74.0-brightgreen.svg
14+
[Rust]: https://img.shields.io/badge/rust-v1.85.0-brightgreen.svg
1515
[License]: https://img.shields.io/badge/License-MIT%20OR%20Apache--2.0-blue.svg
1616

1717
Histogram support for n-dimensional arrays ([`ndarray`]).
@@ -24,7 +24,7 @@ See the [release history](RELEASES.md) to keep track of the development.
2424

2525
# License
2626

27-
Copyright © 2023-2024 Rouven Spreckels <[email protected]>
27+
Copyright © 2023-2025 Rouven Spreckels <[email protected]>
2828

2929
Copyright © 2018–2022 [`ndarray-stats`] Developers
3030

RELEASES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# Version 0.5.0 (2025-02-22)
2+
3+
* Rust Edition 2024.
4+
* Bump MSRV.
5+
* Fix docs.
6+
17
# Version 0.4.0 (2024-09-14)
28

39
* Bump dependencies.

benches/sort.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use criterion::{
2-
black_box, criterion_group, criterion_main, AxisScale, BatchSize, Criterion, PlotConfiguration,
2+
AxisScale, BatchSize, Criterion, PlotConfiguration, black_box, criterion_group, criterion_main,
33
};
44
use ndarray::prelude::*;
55
use ndarray_slice::Slice1Ext;

rustfmt.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
hard_tabs = true
22
max_width = 100
3-
#format_code_in_doc_comments = true
3+
# format_code_in_doc_comments = true

src/histogram/bins.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![warn(missing_docs, clippy::all, clippy::pedantic)]
2-
31
use ndarray::prelude::*;
42
use std::ops::{Index, Range};
53

@@ -145,7 +143,7 @@ impl<A: Ord + Send> Edges<A> {
145143
/// # Examples
146144
///
147145
/// ```
148-
/// use ndarray_histogram::{histogram::Edges, o64, O64};
146+
/// use ndarray_histogram::{O64, histogram::Edges, o64};
149147
///
150148
/// let edges = Edges::<O64>::from(vec![]);
151149
/// assert_eq!(edges.is_empty(), true);
@@ -178,9 +176,15 @@ impl<A: Ord + Send> Edges<A> {
178176
/// contains the given `value`, or returns `None` otherwise.
179177
///
180178
/// That is to say, it returns
181-
/// - `Some((left, right))`, where `left` and `right` are the indices of two consecutive edges
182-
/// in `self` and `right == left + 1`, if `self[left] <= value < self[right]`;
183-
/// - `None`, otherwise.
179+
///
180+
/// - `Some((left, right))`,
181+
///
182+
/// where `left` and `right` are the indices of two consecutive edges in `self` and
183+
/// `right == left + 1`, if `self[left] <= value < self[right]` it returns
184+
///
185+
/// - `None`,
186+
///
187+
/// else otherwise.
184188
///
185189
/// # Examples
186190
///
@@ -278,8 +282,9 @@ impl<A: Ord + Send> Bins<A> {
278282
///
279283
/// ```
280284
/// use ndarray_histogram::{
285+
/// O64,
281286
/// histogram::{Bins, Edges},
282-
/// o64, O64,
287+
/// o64,
283288
/// };
284289
///
285290
/// // At least 2 edges is needed to represent 1 interval

src/histogram/grid.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![warn(missing_docs, clippy::all, clippy::pedantic)]
2-
31
use super::{bins::Bins, errors::BinsBuildError, strategies::BinsBuildingStrategy};
42
use itertools::izip;
53
use ndarray::{ArrayBase, Axis, Data, Ix1, Ix2};
@@ -61,10 +59,10 @@ use std::ops::Range;
6159
/// a given [`strategy`], and generating a [`histogram`]:
6260
///
6361
/// ```
64-
/// use ndarray::{array, Array};
62+
/// use ndarray::{Array, array};
6563
/// use ndarray_histogram::{
66-
/// histogram::{strategies::Auto, Bins, Edges, Grid, GridBuilder},
6764
/// HistogramExt,
65+
/// histogram::{Bins, Edges, Grid, GridBuilder, strategies::Auto},
6866
/// };
6967
///
7068
/// // 1-dimensional observations, as a (n_observations, n_dimension) 2-d matrix
@@ -284,7 +282,7 @@ impl<A: Ord + Send + Clone> Grid<A> {
284282
///
285283
/// ```
286284
/// use ndarray::Array;
287-
/// use ndarray_histogram::histogram::{strategies::Auto, Bins, Edges, Grid, GridBuilder};
285+
/// use ndarray_histogram::histogram::{Bins, Edges, Grid, GridBuilder, strategies::Auto};
288286
///
289287
/// // 1-dimensional observations, as a (n_observations, n_dimension) 2-d matrix
290288
/// let observations =

src/histogram/histograms.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use super::errors::BinNotFound;
22
use super::grid::Grid;
3-
use ndarray::prelude::*;
43
use ndarray::Data;
4+
use ndarray::prelude::*;
55

66
/// Histogram data structure.
77
pub struct Histogram<A: Ord + Send> {
@@ -83,8 +83,10 @@ where
8383
/// for a 2-dimensional array of points `M`.
8484
///
8585
/// Let `(n, d)` be the shape of `M`:
86-
/// - `n` is the number of points;
87-
/// - `d` is the number of dimensions of the space those points belong to.
86+
///
87+
/// - `n` is the number of points;
88+
/// - `d` is the number of dimensions of the space those points belong to.
89+
///
8890
/// It follows that every column in `M` is a `d`-dimensional point.
8991
///
9092
/// For example: a (3, 4) matrix `M` is a collection of 3 points in a
@@ -99,8 +101,9 @@ where
99101
/// ```
100102
/// use ndarray::array;
101103
/// use ndarray_histogram::{
102-
/// histogram::{strategies::Sqrt, Bins, Edges, Grid, GridBuilder, Histogram},
103-
/// o64, HistogramExt, O64,
104+
/// HistogramExt, O64,
105+
/// histogram::{Bins, Edges, Grid, GridBuilder, Histogram, strategies::Sqrt},
106+
/// o64,
104107
/// };
105108
///
106109
/// let observations = array![

src/histogram/strategies.rs

Lines changed: 53 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,12 @@
4444
//! [`Rice`]: struct.Rice.html
4545
//! [`Sqrt`]: struct.Sqrt.html
4646
//! [iqr]: https://www.wikiwand.com/en/Interquartile_range
47-
#![warn(missing_docs, clippy::all, clippy::pedantic)]
4847
4948
use crate::{
50-
histogram::{errors::BinsBuildError, Bins, Edges},
51-
quantile::{interpolate::Nearest, Quantile1dExt, QuantileExt},
49+
histogram::{Bins, Edges, errors::BinsBuildError},
50+
quantile::{Quantile1dExt, QuantileExt, interpolate::Nearest},
5251
};
53-
use ndarray::{prelude::*, Data};
52+
use ndarray::{Data, prelude::*};
5453
use num_traits::{FromPrimitive, NumOps, ToPrimitive, Zero};
5554

5655
/// A trait implemented by all strategies to build [`Bins`] with parameters inferred from
@@ -640,16 +639,20 @@ mod sqrt_tests {
640639

641640
#[test]
642641
fn constant_array_are_bad() {
643-
assert!(Sqrt::from_array(&array![1, 1, 1, 1, 1, 1, 1])
644-
.unwrap_err()
645-
.is_strategy());
642+
assert!(
643+
Sqrt::from_array(&array![1, 1, 1, 1, 1, 1, 1])
644+
.unwrap_err()
645+
.is_strategy()
646+
);
646647
}
647648

648649
#[test]
649650
fn empty_arrays_are_bad() {
650-
assert!(Sqrt::<usize>::from_array(&array![])
651-
.unwrap_err()
652-
.is_empty_input());
651+
assert!(
652+
Sqrt::<usize>::from_array(&array![])
653+
.unwrap_err()
654+
.is_empty_input()
655+
);
653656
}
654657
}
655658

@@ -660,16 +663,20 @@ mod rice_tests {
660663

661664
#[test]
662665
fn constant_array_are_bad() {
663-
assert!(Rice::from_array(&array![1, 1, 1, 1, 1, 1, 1])
664-
.unwrap_err()
665-
.is_strategy());
666+
assert!(
667+
Rice::from_array(&array![1, 1, 1, 1, 1, 1, 1])
668+
.unwrap_err()
669+
.is_strategy()
670+
);
666671
}
667672

668673
#[test]
669674
fn empty_arrays_are_bad() {
670-
assert!(Rice::<usize>::from_array(&array![])
671-
.unwrap_err()
672-
.is_empty_input());
675+
assert!(
676+
Rice::<usize>::from_array(&array![])
677+
.unwrap_err()
678+
.is_empty_input()
679+
);
673680
}
674681
}
675682

@@ -680,16 +687,20 @@ mod sturges_tests {
680687

681688
#[test]
682689
fn constant_array_are_bad() {
683-
assert!(Sturges::from_array(&array![1, 1, 1, 1, 1, 1, 1])
684-
.unwrap_err()
685-
.is_strategy());
690+
assert!(
691+
Sturges::from_array(&array![1, 1, 1, 1, 1, 1, 1])
692+
.unwrap_err()
693+
.is_strategy()
694+
);
686695
}
687696

688697
#[test]
689698
fn empty_arrays_are_bad() {
690-
assert!(Sturges::<usize>::from_array(&array![])
691-
.unwrap_err()
692-
.is_empty_input());
699+
assert!(
700+
Sturges::<usize>::from_array(&array![])
701+
.unwrap_err()
702+
.is_empty_input()
703+
);
693704
}
694705
}
695706

@@ -700,9 +711,11 @@ mod fd_tests {
700711

701712
#[test]
702713
fn constant_array_are_bad() {
703-
assert!(FreedmanDiaconis::from_array(&array![1, 1, 1, 1, 1, 1, 1])
704-
.unwrap_err()
705-
.is_strategy());
714+
assert!(
715+
FreedmanDiaconis::from_array(&array![1, 1, 1, 1, 1, 1, 1])
716+
.unwrap_err()
717+
.is_strategy()
718+
);
706719
}
707720

708721
#[test]
@@ -716,9 +729,11 @@ mod fd_tests {
716729

717730
#[test]
718731
fn empty_arrays_are_bad() {
719-
assert!(FreedmanDiaconis::<usize>::from_array(&array![])
720-
.unwrap_err()
721-
.is_empty_input());
732+
assert!(
733+
FreedmanDiaconis::<usize>::from_array(&array![])
734+
.unwrap_err()
735+
.is_empty_input()
736+
);
722737
}
723738
}
724739

@@ -729,9 +744,11 @@ mod auto_tests {
729744

730745
#[test]
731746
fn constant_array_are_bad() {
732-
assert!(Auto::from_array(&array![1, 1, 1, 1, 1, 1, 1])
733-
.unwrap_err()
734-
.is_strategy());
747+
assert!(
748+
Auto::from_array(&array![1, 1, 1, 1, 1, 1, 1])
749+
.unwrap_err()
750+
.is_strategy()
751+
);
735752
}
736753

737754
#[test]
@@ -741,8 +758,10 @@ mod auto_tests {
741758

742759
#[test]
743760
fn empty_arrays_are_bad() {
744-
assert!(Auto::<usize>::from_array(&array![])
745-
.unwrap_err()
746-
.is_empty_input());
761+
assert!(
762+
Auto::<usize>::from_array(&array![])
763+
.unwrap_err()
764+
.is_empty_input()
765+
);
747766
}
748767
}

src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
rustdoc::broken_intra_doc_links,
1010
rustdoc::missing_crate_level_docs
1111
)]
12+
#![allow(clippy::tabs_in_doc_comments)]
1213
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
1314

1415
pub use crate::histogram::HistogramExt;
15-
pub use crate::maybe_nan::{n32, n64, o32, o64, MaybeNan, MaybeNanExt, N32, N64, O32, O64};
16-
pub use crate::quantile::{interpolate, Quantile1dExt, QuantileExt};
16+
pub use crate::maybe_nan::{MaybeNan, MaybeNanExt, N32, N64, O32, O64, n32, n64, o32, o64};
17+
pub use crate::quantile::{Quantile1dExt, QuantileExt, interpolate};
1718

1819
pub use ndarray;
1920

0 commit comments

Comments
 (0)