diff --git a/src/algorithm/neighbour/cover_tree.rs b/src/algorithm/neighbour/cover_tree.rs index 96a3389..9c5c806 100644 --- a/src/algorithm/neighbour/cover_tree.rs +++ b/src/algorithm/neighbour/cover_tree.rs @@ -457,7 +457,8 @@ mod tests { use super::*; use crate::math::distance::Distances; - #[derive(Debug, Serialize, Deserialize, Clone)] + #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] + #[derive(Debug, Clone)] struct SimpleDistance {} impl Distance for SimpleDistance { @@ -503,6 +504,7 @@ mod tests { } #[test] + #[cfg(feature = "serde")] fn serde() { let data = vec![1, 2, 3, 4, 5, 6, 7, 8, 9]; diff --git a/src/algorithm/neighbour/linear_search.rs b/src/algorithm/neighbour/linear_search.rs index f89e751..b4a3c89 100644 --- a/src/algorithm/neighbour/linear_search.rs +++ b/src/algorithm/neighbour/linear_search.rs @@ -140,7 +140,8 @@ mod tests { use super::*; use crate::math::distance::Distances; - #[derive(Debug, Serialize, Deserialize, Clone)] + #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] + #[derive(Debug, Clone)] struct SimpleDistance {} impl Distance for SimpleDistance { diff --git a/src/cluster/dbscan.rs b/src/cluster/dbscan.rs index 73d686d..d7a706a 100644 --- a/src/cluster/dbscan.rs +++ b/src/cluster/dbscan.rs @@ -265,6 +265,7 @@ impl, T>> DBSCAN { mod tests { use super::*; use crate::linalg::naive::dense_matrix::DenseMatrix; + #[cfg(feature = "serde")] use crate::math::distance::euclidian::Euclidian; #[test] @@ -299,6 +300,7 @@ mod tests { } #[test] + #[cfg(feature = "serde")] fn serde() { let x = DenseMatrix::from_2d_array(&[ &[5.1, 3.5, 1.4, 0.2], diff --git a/src/cluster/kmeans.rs b/src/cluster/kmeans.rs index a454b1f..6be52a5 100644 --- a/src/cluster/kmeans.rs +++ b/src/cluster/kmeans.rs @@ -347,6 +347,7 @@ mod tests { } #[test] + #[cfg(feature = "serde")] fn serde() { let x = DenseMatrix::from_2d_array(&[ &[5.1, 3.5, 1.4, 0.2], diff --git a/src/decomposition/pca.rs b/src/decomposition/pca.rs index e3212e3..de258dc 100644 --- a/src/decomposition/pca.rs +++ b/src/decomposition/pca.rs @@ -567,6 +567,7 @@ mod tests { } #[test] + #[cfg(feature = "serde")] fn serde() { let iris = DenseMatrix::from_2d_array(&[ &[5.1, 3.5, 1.4, 0.2], diff --git a/src/decomposition/svd.rs b/src/decomposition/svd.rs index 5524e29..6f5a1bd 100644 --- a/src/decomposition/svd.rs +++ b/src/decomposition/svd.rs @@ -228,6 +228,7 @@ mod tests { } #[test] + #[cfg(feature = "serde")] fn serde() { let iris = DenseMatrix::from_2d_array(&[ &[5.1, 3.5, 1.4, 0.2], diff --git a/src/ensemble/random_forest_classifier.rs b/src/ensemble/random_forest_classifier.rs index 62e83b5..4127627 100644 --- a/src/ensemble/random_forest_classifier.rs +++ b/src/ensemble/random_forest_classifier.rs @@ -325,6 +325,7 @@ mod tests { } #[test] + #[cfg(feature = "serde")] fn serde() { let x = DenseMatrix::from_2d_array(&[ &[5.1, 3.5, 1.4, 0.2], diff --git a/src/ensemble/random_forest_regressor.rs b/src/ensemble/random_forest_regressor.rs index 18c2f69..02eef99 100644 --- a/src/ensemble/random_forest_regressor.rs +++ b/src/ensemble/random_forest_regressor.rs @@ -274,6 +274,7 @@ mod tests { } #[test] + #[cfg(feature = "serde")] fn serde() { let x = DenseMatrix::from_2d_array(&[ &[234.289, 235.6, 159., 107.608, 1947., 60.323], diff --git a/src/linalg/naive/dense_matrix.rs b/src/linalg/naive/dense_matrix.rs index 1a9b3a6..4faa77d 100644 --- a/src/linalg/naive/dense_matrix.rs +++ b/src/linalg/naive/dense_matrix.rs @@ -1312,6 +1312,7 @@ mod tests { } #[test] + #[cfg(feature = "serde")] fn to_from_json() { let a = DenseMatrix::from_2d_array(&[&[0.9, 0.4, 0.7], &[0.4, 0.5, 0.3], &[0.7, 0.3, 0.8]]); let deserialized_a: DenseMatrix = @@ -1320,6 +1321,7 @@ mod tests { } #[test] + #[cfg(feature = "serde")] fn to_from_bincode() { let a = DenseMatrix::from_2d_array(&[&[0.9, 0.4, 0.7], &[0.4, 0.5, 0.3], &[0.7, 0.3, 0.8]]); let deserialized_a: DenseMatrix = diff --git a/src/linear/elastic_net.rs b/src/linear/elastic_net.rs index f4a4326..479ae2a 100644 --- a/src/linear/elastic_net.rs +++ b/src/linear/elastic_net.rs @@ -401,6 +401,7 @@ mod tests { } #[test] + #[cfg(feature = "serde")] fn serde() { let x = DenseMatrix::from_2d_array(&[ &[234.289, 235.6, 159.0, 107.608, 1947., 60.323], diff --git a/src/linear/lasso.rs b/src/linear/lasso.rs index 17712b1..8c59a4f 100644 --- a/src/linear/lasso.rs +++ b/src/linear/lasso.rs @@ -275,6 +275,7 @@ mod tests { } #[test] + #[cfg(feature = "serde")] fn serde() { let x = DenseMatrix::from_2d_array(&[ &[234.289, 235.6, 159.0, 107.608, 1947., 60.323], diff --git a/src/linear/linear_regression.rs b/src/linear/linear_regression.rs index 290a2db..2734a78 100644 --- a/src/linear/linear_regression.rs +++ b/src/linear/linear_regression.rs @@ -251,6 +251,7 @@ mod tests { } #[test] + #[cfg(feature = "serde")] fn serde() { let x = DenseMatrix::from_2d_array(&[ &[234.289, 235.6, 159.0, 107.608, 1947., 60.323], diff --git a/src/linear/logistic_regression.rs b/src/linear/logistic_regression.rs index 45777be..cbdef77 100644 --- a/src/linear/logistic_regression.rs +++ b/src/linear/logistic_regression.rs @@ -543,6 +543,7 @@ mod tests { } #[test] + #[cfg(feature = "serde")] fn serde() { let x = DenseMatrix::from_2d_array(&[ &[1., -5.], diff --git a/src/linear/ridge_regression.rs b/src/linear/ridge_regression.rs index 4e1ebad..787c338 100644 --- a/src/linear/ridge_regression.rs +++ b/src/linear/ridge_regression.rs @@ -330,6 +330,7 @@ mod tests { } #[test] + #[cfg(feature = "serde")] fn serde() { let x = DenseMatrix::from_2d_array(&[ &[234.289, 235.6, 159.0, 107.608, 1947., 60.323], diff --git a/src/naive_bayes/bernoulli.rs b/src/naive_bayes/bernoulli.rs index cdbfa80..6a7d0b4 100644 --- a/src/naive_bayes/bernoulli.rs +++ b/src/naive_bayes/bernoulli.rs @@ -351,6 +351,7 @@ mod tests { } #[test] + #[cfg(feature = "serde")] fn serde() { let x = DenseMatrix::::from_2d_array(&[ &[1., 1., 0., 0., 0., 0.], diff --git a/src/naive_bayes/categorical.rs b/src/naive_bayes/categorical.rs index dc8587a..2161528 100644 --- a/src/naive_bayes/categorical.rs +++ b/src/naive_bayes/categorical.rs @@ -349,6 +349,7 @@ mod tests { } #[test] + #[cfg(feature = "serde")] fn serde() { let x = DenseMatrix::::from_2d_array(&[ &[3., 4., 0., 1.], diff --git a/src/naive_bayes/gaussian.rs b/src/naive_bayes/gaussian.rs index c27c396..28c4785 100644 --- a/src/naive_bayes/gaussian.rs +++ b/src/naive_bayes/gaussian.rs @@ -281,6 +281,7 @@ mod tests { } #[test] + #[cfg(feature = "serde")] fn serde() { let x = DenseMatrix::::from_2d_array(&[ &[-1., -1.], diff --git a/src/naive_bayes/multinomial.rs b/src/naive_bayes/multinomial.rs index fa91020..06ee071 100644 --- a/src/naive_bayes/multinomial.rs +++ b/src/naive_bayes/multinomial.rs @@ -324,6 +324,7 @@ mod tests { )); } #[test] + #[cfg(feature = "serde")] fn serde() { let x = DenseMatrix::::from_2d_array(&[ &[1., 1., 0., 0., 0., 0.], diff --git a/src/neighbors/knn_classifier.rs b/src/neighbors/knn_classifier.rs index 839eea3..ba6693e 100644 --- a/src/neighbors/knn_classifier.rs +++ b/src/neighbors/knn_classifier.rs @@ -280,6 +280,7 @@ mod tests { } #[test] + #[cfg(feature = "serde")] fn serde() { let x = DenseMatrix::from_2d_array(&[&[1., 2.], &[3., 4.], &[5., 6.], &[7., 8.], &[9., 10.]]); diff --git a/src/neighbors/knn_regressor.rs b/src/neighbors/knn_regressor.rs index 1edf86a..ed52496 100644 --- a/src/neighbors/knn_regressor.rs +++ b/src/neighbors/knn_regressor.rs @@ -269,6 +269,7 @@ mod tests { } #[test] + #[cfg(feature = "serde")] fn serde() { let x = DenseMatrix::from_2d_array(&[&[1., 2.], &[3., 4.], &[5., 6.], &[7., 8.], &[9., 10.]]); diff --git a/src/svm/svc.rs b/src/svm/svc.rs index 9d77812..3101425 100644 --- a/src/svm/svc.rs +++ b/src/svm/svc.rs @@ -726,6 +726,7 @@ mod tests { use super::*; use crate::linalg::naive::dense_matrix::*; use crate::metrics::accuracy; + #[cfg(feature = "serde")] use crate::svm::*; #[test] @@ -814,6 +815,7 @@ mod tests { } #[test] + #[cfg(feature = "serde")] fn svc_serde() { let x = DenseMatrix::from_2d_array(&[ &[5.1, 3.5, 1.4, 0.2], diff --git a/src/svm/svr.rs b/src/svm/svr.rs index cbb1ea5..b160cca 100644 --- a/src/svm/svr.rs +++ b/src/svm/svr.rs @@ -533,6 +533,7 @@ mod tests { use super::*; use crate::linalg::naive::dense_matrix::*; use crate::metrics::mean_squared_error; + #[cfg(feature = "serde")] use crate::svm::*; #[test] @@ -569,6 +570,7 @@ mod tests { } #[test] + #[cfg(feature = "serde")] fn svr_serde() { let x = DenseMatrix::from_2d_array(&[ &[234.289, 235.6, 159.0, 107.608, 1947., 60.323], diff --git a/src/tree/decision_tree_classifier.rs b/src/tree/decision_tree_classifier.rs index 7575a5a..ba79d52 100644 --- a/src/tree/decision_tree_classifier.rs +++ b/src/tree/decision_tree_classifier.rs @@ -745,6 +745,7 @@ mod tests { } #[test] + #[cfg(feature = "serde")] fn serde() { let x = DenseMatrix::from_2d_array(&[ &[1., 1., 1., 0.], diff --git a/src/tree/decision_tree_regressor.rs b/src/tree/decision_tree_regressor.rs index d1292db..307d357 100644 --- a/src/tree/decision_tree_regressor.rs +++ b/src/tree/decision_tree_regressor.rs @@ -581,6 +581,7 @@ mod tests { } #[test] + #[cfg(feature = "serde")] fn serde() { let x = DenseMatrix::from_2d_array(&[ &[234.289, 235.6, 159., 107.608, 1947., 60.323],