Skip to content

Commit

Permalink
Release 0.6.3
Browse files Browse the repository at this point in the history
  • Loading branch information
davehadley committed Apr 7, 2022
1 parent f8de575 commit 43a8110
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 20 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: Swatinem/rust-cache@v1
- uses: actions-rs/toolchain@v1
with:
profile: minimal
Expand All @@ -26,6 +27,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: Swatinem/rust-cache@v1
- uses: actions-rs/toolchain@v1
with:
profile: minimal
Expand All @@ -43,6 +45,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: Swatinem/rust-cache@v1
- uses: actions-rs/toolchain@v1
with:
profile: minimal
Expand All @@ -65,5 +68,5 @@ jobs:
- name: Run pre-commit hooks
run: |
pip install pre-commit \
&& pre-commit run --all
&& pre-commit run --all-files
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ repos:
types: [rust]

- repo: https://github.com/timothycrosley/isort
rev: 5.9.3
rev: 5.10.1
hooks:
- id: isort
stages: [commit]

- repo: https://github.com/ambv/black
rev: 21.9b0
rev: 22.3.0
hooks:
- id: black
language_version: python3
Expand All @@ -31,20 +31,20 @@ repos:
stages: [commit]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.910-1
rev: v0.942
hooks:
- id: mypy

- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.2.0
rev: v2.3.0
hooks:
- id: pretty-format-yaml
args: [--autofix]
args: [--autofix, --preserve-quotes]
- id: pretty-format-toml
args: [--autofix]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
rev: v4.2.0
hooks:
- id: check-added-large-files
- id: check-ast
Expand Down
5 changes: 5 additions & 0 deletions ndhistogram/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 0.6.3 (2022-04-07)
- `Uniform::with_step_size` now panics when given a step size equal to zero (from [@jacg](https://github.com/jacg)).
- Documentation and CI improvements from [@jacg](https://github.com/jacg).
- Fix compiler/clippy warnings when building with the latest stable version (clippy 0.1.59, rustc 1.59.0).

# 0.6.2 (2021-10-16)

- Fix for compiler/clippy warnings when building with the latest stable version (clippy 0.1.55, rustc 1.55.0).
Expand Down
2 changes: 1 addition & 1 deletion ndhistogram/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ bench = false

[package]
name = "ndhistogram"
version = "0.6.2"
version = "0.6.3"
authors = [ "David Hadley <[email protected]>",]
edition = "2018"
license = "MIT OR Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion ndhistogram/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Add this to your `Cargo.toml`:

```toml
[dependencies]
ndhistogram = "0.6.2"
ndhistogram = "0.6.3"
```

See the [change log](https://github.com/davehadley/ndhistogram/blob/main/ndhistogram/CHANGELOG.md)
Expand Down
8 changes: 4 additions & 4 deletions ndhistogram/src/axis/uniform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize};

/// An axis with equal sized bins.
///
/// An axis with N equally spaced, equal sized, bins between (low, high].
/// An axis with N equally spaced, equal sized, bins between [low, high).
/// Below (above) this range is an underflow (overflow) bin.
/// Hence this axis has N+2 bins.
///
Expand Down Expand Up @@ -65,14 +65,14 @@ where
/// Factory method to create an axis with num uniformly spaced bins in the range [low, low+num*step). Under/overflow bins cover values outside this range.
///
/// # Panics
/// Panics if num bins == 0 or step < 0.
/// Panics if num bins == 0 or step <= 0.
pub fn with_step_size(num: usize, low: T, step: T) -> Self {
let high = T::from(num).expect("num bins can be converted to coordinate type") * step + low;
if num == 0 {
panic!("Invalid axis num bins ({})", num);
}
if step < T::zero() {
panic!("Invalid negative step size");
if step <= T::zero() {
panic!("Invalid step size. Step size must be greater than zero.");
}
let (low, high) = if low > high { (high, low) } else { (low, high) };
Self {
Expand Down
2 changes: 1 addition & 1 deletion ndhistogram/src/axis/uniformnoflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize};

/// An axis with equal sized bins and no under/overflow bins.
///
/// An axis with N equally spaced, equal sized, bins between (low, high].
/// An axis with N equally spaced, equal sized, bins between [low, high).
/// Similar to [Uniform] but this axis has no over/underflow bins.
/// Hence it has N bins.
///
Expand Down
4 changes: 2 additions & 2 deletions ndhistogram/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
//!
//! ```toml
//! [dependencies]
//! ndhistogram = "0.6.2"
//! ndhistogram = "0.6.3"
//! ```
//!
//! See the [change log](https://github.com/davehadley/ndhistogram/blob/main/ndhistogram/CHANGELOG.md)
Expand Down Expand Up @@ -128,7 +128,7 @@
//! User defined bin value types are possible by implementing the [Fill](Fill), [FillWith](FillWith) or [FillWithWeighted](FillWithWeighted) traits.
#![doc(issue_tracker_base_url = "https://github.com/davehadley/rust-hist/issues")]
#![doc(html_root_url = "https://docs.rs/ndhistogram/0.6.2")]
#![doc(html_root_url = "https://docs.rs/ndhistogram/0.6.3")]
#![cfg_attr(
debug_assertions,
warn(
Expand Down
3 changes: 1 addition & 2 deletions ndhistogram/tests/test_uniform_axis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ fn test_uniform_get_bin() {
fn test_uniform_get_edges() {
let ax = Uniform::new(5, 0.0, 1.0);
let actual: Vec<Range<f64>> = Range::<i32> { start: -2, end: 7 }
.map(|x| ax.bin(x as usize))
.flatten()
.filter_map(|x| ax.bin(x as usize))
.filter_map(|x| Range::try_from(x).ok())
.collect();
let edges: Vec<f64> = vec![0.0, 0.2, 0.4, 0.6, 0.8, 1.0];
Expand Down
12 changes: 12 additions & 0 deletions ndhistogram/tests/test_uniform_axis_integer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,15 @@ fn test_uniform_integer_get_bin() {
];
assert_eq!(expected, actual);
}

#[test]
#[should_panic]
fn test_uniform_with_step_size_should_panic_on_negative_step() {
Uniform::with_step_size(10, 20.0, -1.0);
}

#[test]
#[should_panic]
fn test_uniform_with_step_size_should_panic_on_zero_step() {
Uniform::with_step_size(10, 20.0, 0.0);
}
4 changes: 2 additions & 2 deletions ndhistogram/tests/test_variablenoflow_axis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fn test_variablenoflow_high() {
#[test]
fn test_variablenoflow_get_index() {
let ax = VariableNoFlow::new(vec![0, 1, 4, 8]);
let actual: Vec<_> = (-1..10).map(|coord| ax.index(&coord)).flatten().collect();
let actual: Vec<_> = (-1..10).filter_map(|coord| ax.index(&coord)).collect();
let expected = vec![0, 1, 1, 1, 2, 2, 2, 2];
assert_eq!(actual, expected);
}
Expand Down Expand Up @@ -108,7 +108,7 @@ fn test_variablenoflow_iterate_items() {
#[test]
fn test_negative_axis_index() {
let axis = VariableNoFlow::new(vec![-3, -1, 0, 1]);
let actual: Vec<_> = (-4..3).map(|loc| axis.index(&loc)).flatten().collect();
let actual: Vec<_> = (-4..3).filter_map(|loc| axis.index(&loc)).collect();
let expected = vec![0, 0, 1, 2];
assert_eq!(actual, expected)
}
Expand Down

0 comments on commit 43a8110

Please sign in to comment.