Skip to content

Commit

Permalink
Make Quantile work for no_std via libm
Browse files Browse the repository at this point in the history
This requires the new `libm` feature, which is enabled by default.

This is a breaking change.
  • Loading branch information
vks committed Mar 31, 2021
1 parent 6197452 commit fe8280d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ include = ["src/**/*", "benches/*", "LICENSE-*", "README.md"]
[features]
serde1 = ["serde", "serde_derive", "serde-big-array"]
nightly = []
std = ["easy-cast"]
std = ["easy-cast/std"]
libm = ["easy-cast/libm"]
default = ["libm"]

[[bench]]
harness = false
Expand All @@ -32,7 +34,7 @@ name = "kurtosis"
[dependencies]
num-traits = { version = "0.2", default-features = false }
float-ord = "0.2"
easy-cast = { version = "0.2", optional = true }
easy-cast = { version = "0.3", default-features = false, optional = true }
serde = { version = "1", features = ["derive"], optional = true }
serde_derive = { version = "1", optional = true }
serde-big-array = { version = "0.3.0", optional = true }
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@ This crate works without `std`.

## Crate features

The following optional features are available:
The following features are available:

* `std` enables `Quantile` (`std` is required for floating point functions).
* `libm` enables `Quantile` (using floating point functions provided by `libm`).
This is enabled by default. If the `std` feature is also enabled, `std` is
preferred over `libm`.
* `std` enables `Quantile` (using floating point functions provided by `std`).
* `serde1` enables serialization, via Serde version 1.
* `rayon` enables support for `rayon::iter::FromParallelIterator`.
* `nightly` enables the use of const generics for a histogram implementation
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
#[macro_use] mod moments;
mod weighted_mean;
mod minmax;
#[cfg(feature = "std")]
#[cfg(any(feature = "std", feature = "libm"))]
mod quantile;
mod traits;
#[macro_use] mod histogram;
Expand All @@ -112,7 +112,7 @@ pub mod histogram_const;
pub use crate::moments::{Mean, Variance, Skewness, Kurtosis, MeanWithError};
pub use crate::weighted_mean::{WeightedMean, WeightedMeanWithError};
pub use crate::minmax::{Min, Max};
#[cfg(feature = "std")]
#[cfg(any(feature = "std", feature = "libm"))]
pub use crate::quantile::Quantile;
pub use crate::traits::{Estimate, Merge, Histogram};
pub use crate::histogram::{InvalidRangeError, SampleOutOfRangeError};
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ fn concatenate_moments_max() {
assert_eq!(e.max(), 5.0);
}

#[cfg(feature = "std")]
#[cfg(any(feature = "std", feature = "libm"))]
#[test]
fn concatenate_moments_quantile() {
use average::{Variance, Quantile};
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ mod mean;
mod min;
mod moments;
mod proptest;
#[cfg(feature = "std")]
#[cfg(any(feature = "std", feature = "libm"))]
mod quantile;
mod random;
mod skewness;
Expand Down

0 comments on commit fe8280d

Please sign in to comment.