Skip to content

Commit f2f4068

Browse files
authored
Merge branch 'development' into fix-245
2 parents 22c9640 + d15ea43 commit f2f4068

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+266
-268
lines changed

.github/workflows/coverage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ jobs:
4141
- name: Upload to codecov.io
4242
uses: codecov/codecov-action@v2
4343
with:
44-
fail_ci_if_error: true
44+
fail_ci_if_error: false

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "smartcore"
33
description = "Machine Learning in Rust."
44
homepage = "https://smartcorelib.org"
5-
version = "0.3.0"
5+
version = "0.3.1"
66
authors = ["smartcore Developers"]
77
edition = "2021"
88
license = "Apache-2.0"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818
-----
1919
[![CI](https://github.com/smartcorelib/smartcore/actions/workflows/ci.yml/badge.svg)](https://github.com/smartcorelib/smartcore/actions/workflows/ci.yml)
2020

21-
To start getting familiar with the new smartcore v0.5 API, there is now available a [**Jupyter Notebook environment repository**](https://github.com/smartcorelib/smartcore-jupyter). Please see instructions there, contributions welcome see [CONTRIBUTING](.github/CONTRIBUTING.md).
21+
To start getting familiar with the new smartcore v0.3 API, there is now available a [**Jupyter Notebook environment repository**](https://github.com/smartcorelib/smartcore-jupyter). Please see instructions there, contributions welcome see [CONTRIBUTING](.github/CONTRIBUTING.md).

src/algorithm/neighbour/fastpair.rs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,8 @@ mod tests_fastpair {
260260
let distances = fastpair.distances;
261261
let neighbours = fastpair.neighbours;
262262

263-
assert!(distances.len() != 0);
264-
assert!(neighbours.len() != 0);
263+
assert!(!distances.is_empty());
264+
assert!(!neighbours.is_empty());
265265

266266
assert_eq!(10, neighbours.len());
267267
assert_eq!(10, distances.len());
@@ -276,17 +276,13 @@ mod tests_fastpair {
276276
// We expect an error when we run `FastPair` on this dataset,
277277
// becuase `FastPair` currently only works on a minimum of 3
278278
// points.
279-
let _fastpair = FastPair::new(&dataset);
279+
let fastpair = FastPair::new(&dataset);
280+
assert!(fastpair.is_err());
280281

281-
match _fastpair {
282-
Err(e) => {
283-
let expected_error =
284-
Failed::because(FailedError::FindFailed, "min number of rows should be 3");
285-
assert_eq!(e, expected_error)
286-
}
287-
_ => {
288-
assert!(false);
289-
}
282+
if let Err(e) = fastpair {
283+
let expected_error =
284+
Failed::because(FailedError::FindFailed, "min number of rows should be 3");
285+
assert_eq!(e, expected_error)
290286
}
291287
}
292288

@@ -582,7 +578,7 @@ mod tests_fastpair {
582578
};
583579
for p in dissimilarities.iter() {
584580
if p.distance.unwrap() < min_dissimilarity.distance.unwrap() {
585-
min_dissimilarity = p.clone()
581+
min_dissimilarity = *p
586582
}
587583
}
588584

src/algorithm/neighbour/mod.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,15 @@ pub mod linear_search;
4949
/// Both, KNN classifier and regressor benefits from underlying search algorithms that helps to speed up queries.
5050
/// `KNNAlgorithmName` maintains a list of supported search algorithms, see [KNN algorithms](../algorithm/neighbour/index.html)
5151
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
52-
#[derive(Debug, Clone)]
52+
#[derive(Debug, Clone, Default)]
5353
pub enum KNNAlgorithmName {
5454
/// Heap Search algorithm, see [`LinearSearch`](../algorithm/neighbour/linear_search/index.html)
5555
LinearSearch,
5656
/// Cover Tree Search algorithm, see [`CoverTree`](../algorithm/neighbour/cover_tree/index.html)
57+
#[default]
5758
CoverTree,
5859
}
5960

60-
impl Default for KNNAlgorithmName {
61-
fn default() -> Self {
62-
KNNAlgorithmName::CoverTree
63-
}
64-
}
65-
6661
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
6762
#[derive(Debug)]
6863
pub(crate) enum KNNAlgorithm<T: Number, D: Distance<Vec<T>>> {

src/cluster/dbscan.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
//!
1919
//! Example:
2020
//!
21-
//! ```
21+
//! ```ignore
2222
//! use smartcore::linalg::basic::matrix::DenseMatrix;
2323
//! use smartcore::linalg::basic::arrays::Array2;
2424
//! use smartcore::cluster::dbscan::*;
@@ -511,6 +511,6 @@ mod tests {
511511
.and_then(|dbscan| dbscan.predict(&x))
512512
.unwrap();
513513

514-
println!("{:?}", labels);
514+
println!("{labels:?}");
515515
}
516516
}

src/cluster/kmeans.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,8 +498,8 @@ mod tests {
498498

499499
let y: Vec<usize> = kmeans.predict(&x).unwrap();
500500

501-
for i in 0..y.len() {
502-
assert_eq!(y[i] as usize, kmeans._y[i]);
501+
for (i, _y_i) in y.iter().enumerate() {
502+
assert_eq!({ y[i] }, kmeans._y[i]);
503503
}
504504
}
505505

src/dataset/boston.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use crate::dataset::Dataset;
3131
pub fn load_dataset() -> Dataset<f32, f32> {
3232
let (x, y, num_samples, num_features) = match deserialize_data(std::include_bytes!("boston.xy"))
3333
{
34-
Err(why) => panic!("Can't deserialize boston.xy. {}", why),
34+
Err(why) => panic!("Can't deserialize boston.xy. {why}"),
3535
Ok((x, y, num_samples, num_features)) => (x, y, num_samples, num_features),
3636
};
3737

src/dataset/breast_cancer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use crate::dataset::Dataset;
3333
pub fn load_dataset() -> Dataset<f32, u32> {
3434
let (x, y, num_samples, num_features) =
3535
match deserialize_data(std::include_bytes!("breast_cancer.xy")) {
36-
Err(why) => panic!("Can't deserialize breast_cancer.xy. {}", why),
36+
Err(why) => panic!("Can't deserialize breast_cancer.xy. {why}"),
3737
Ok((x, y, num_samples, num_features)) => (
3838
x,
3939
y.into_iter().map(|x| x as u32).collect(),

src/dataset/diabetes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use crate::dataset::Dataset;
2626
pub fn load_dataset() -> Dataset<f32, u32> {
2727
let (x, y, num_samples, num_features) =
2828
match deserialize_data(std::include_bytes!("diabetes.xy")) {
29-
Err(why) => panic!("Can't deserialize diabetes.xy. {}", why),
29+
Err(why) => panic!("Can't deserialize diabetes.xy. {why}"),
3030
Ok((x, y, num_samples, num_features)) => (
3131
x,
3232
y.into_iter().map(|x| x as u32).collect(),

0 commit comments

Comments
 (0)