Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
# the repo. Unless a later match takes precedence,
# Developers in this list will be requested for
# review when someone opens a pull request.
* @VolodymyrOrlov
* @morenol
* @Mec-iS
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ $ rust-code-analysis-cli -p src/algorithm/neighbour/fastpair.rs --ls 22 --le 213

1. After a PR is opened maintainers are notified
2. Probably changes will be required to comply with the workflow, these commands are run automatically and all tests shall pass:
* **Coverage** (optional): `tarpaulin` is used with command `cargo tarpaulin --out Lcov --all-features -- --test-threads 1`
* **Formatting**: run `rustfmt src/*.rs` to apply automatic formatting
* **Linting**: `clippy` is used with command `cargo clippy --all-features -- -Drust-2018-idioms -Dwarnings`
* **Coverage** (optional): `tarpaulin` is used with command `cargo tarpaulin --out Lcov --all-features -- --test-threads 1`
* **Testing**: multiple test pipelines are run for different targets
3. When everything is OK, code is merged.

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "smartcore"
description = "Machine Learning in Rust."
homepage = "https://smartcorelib.org"
version = "0.4.1"
version = "0.4.2"
authors = ["smartcore Developers"]
edition = "2021"
license = "Apache-2.0"
Expand Down
27 changes: 26 additions & 1 deletion src/linalg/basic/arrays.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ pub trait MutArrayView1<T: Debug + Display + Copy + Sized>:
T: Number + PartialOrd,
{
let stack_size = 64;
let mut jstack = -1;
let mut jstack: i32 = -1;
let mut l = 0;
let mut istack = vec![0; stack_size];
let mut ir = self.shape() - 1;
Expand Down Expand Up @@ -2190,4 +2190,29 @@ mod tests {

assert_eq!(result, [65, 581, 30])
}

#[test]
fn test_argsort_mut_exact_boundary() {
// Test index == length - 1 case
let boundary =
DenseMatrix::from_2d_array(&[&[1.0, 2.0, 3.0, f64::MAX], &[3.0, f64::MAX, 0.0, 2.0]])
.unwrap();
let mut view0: Vec<f64> = boundary.get_col(0).iterator(0).copied().collect();
let indices = view0.argsort_mut();
assert_eq!(indices.last(), Some(&1));
assert_eq!(indices.first(), Some(&0));

let mut view1: Vec<f64> = boundary.get_col(3).iterator(0).copied().collect();
let indices = view1.argsort_mut();
assert_eq!(indices.last(), Some(&0));
assert_eq!(indices.first(), Some(&1));
}

#[test]
fn test_argsort_mut_filled_array() {
let matrix = DenseMatrix::<f64>::rand(1000, 1000);
let mut view: Vec<f64> = matrix.get_col(0).iterator(0).copied().collect();
let sorted = view.argsort_mut();
assert_eq!(sorted.len(), 1000);
}
}
2 changes: 1 addition & 1 deletion src/neighbors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl KNNWeightFunction {
KNNWeightFunction::Distance => {
// if there are any points that has zero distance from one or more training points,
// those training points are weighted as 1.0 and the other points as 0.0
if distances.iter().any(|&e| e == 0f64) {
if distances.contains(&0f64) {
distances
.iter()
.map(|e| if *e == 0f64 { 1f64 } else { 0f64 })
Expand Down
Loading
Loading