Skip to content

fix(tests): Stage 6 integration tests + bump patch 0.6.5 → 0.6.6 (#397) - #428

Merged
Mec-iS merged 26 commits into
developmentfrom
fix/397-integration-tests
Aug 10, 2026
Merged

fix(tests): Stage 6 integration tests + bump patch 0.6.5 → 0.6.6 (#397)#428
Mec-iS merged 26 commits into
developmentfrom
fix/397-integration-tests

Conversation

@Mec-iS

@Mec-iS Mec-iS commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

Closes #397. Creates the top-level tests/ directory with end-to-end integration tests for every estimator family, plus a patch version bump 0.6.5 → 0.6.6.

Version bump

Cargo.toml: 0.6.50.6.6 (patch — new tests only, no API changes).

Files added

File Estimators covered Dataset-gated path
tests/linear_workflow.rs LinearRegression, RidgeRegression, LogisticRegression iris sepal→petal regression
tests/tree_workflow.rs DecisionTreeClassifier, DecisionTreeRegressor iris (≥90 % acc)
tests/ensemble_workflow.rs RandomForestClassifier, RandomForestRegressor iris (≥90 % acc)
tests/svm_workflow.rs SVC (RBF + linear), SVR (RBF)
tests/naive_bayes_workflow.rs GaussianNB, BernoulliNB, CategoricalNB, ComplementNB iris (GaussianNB ≥90 %)
tests/neighbors_workflow.rs KNNClassifier, KNNRegressor iris (≥90 % acc)
tests/cluster_workflow.rs KMeans, DBSCAN make_blobs 3-cluster purity
tests/decomposition_workflow.rs PCA (full-rank, rank-1 reduction), SVD singular-value ordering iris 2-component PCA
tests/preprocessing_workflow.rs StandardScaler (round-trip + inverse), OneHotEncoder shape/binary
tests/model_selection_workflow.rs train_test_split, cross_validate (5-fold KNN) iris DecisionTree split

Design notes

  • Every test asserts a non-trivial outcome (accuracy threshold, MAE bound, cluster purity, etc.) — not just "it runs".
  • Dataset-dependent tests are gated behind #[cfg(feature = "datasets")]; all other paths use small inline fixtures so the test suite runs without any optional features.
  • tests/ is already listed in Cargo.toml's exclude array, so nothing is added to the published crate.

How to run

cargo test                          # inline fixtures only
cargo test --features datasets      # + dataset-gated paths
cargo test --all-features           # everything

Mec-iS added 26 commits August 10, 2026 17:49
….6.6 (#397)

Adds a top-level tests/ directory with end-to-end workflow integration tests
for every estimator family. Each file exercises load → train → predict → evaluate
with non-trivial accuracy/error assertions.

Files added:
  tests/linear_workflow.rs
  tests/tree_workflow.rs
  tests/ensemble_workflow.rs
  tests/svm_workflow.rs
  tests/naive_bayes_workflow.rs
  tests/neighbors_workflow.rs
  tests/cluster_workflow.rs
  tests/decomposition_workflow.rs
  tests/preprocessing_workflow.rs
  tests/model_selection_workflow.rs

Also bumps Cargo.toml version 0.6.5 → 0.6.6 (patch).
Tracking issue: #397 / #391.
…rs in integration tests

- linear_workflow.rs: remove unused Array/Array2 top-level imports; remove dead
  intermediate variables (x_mat, x slice) from the datasets-gated test; use a
  single DenseMatrix::from_iterator directly
- decomposition_workflow.rs: move Array import inside the datasets-gated fn;
  remove never-called frobenius_relative_error helper; mark SVD singular-value
  test #[cfg(not(target_arch = "wasm32"))] because wasm32 panics on 30-iter SVD
- cluster_workflow.rs: remove unused Array import from kmeans_generated_blobs;
  fix `ds.data.iter().copied() as _` cast that doesn't compile — use explicit
  `.map(|v| v)` instead
- model_selection_workflow.rs: remove `use smartcore::metrics::accuracy` (the
  function does not exist at that path); replace with a local closure passed
  inline to cross_validate matching the expected fn-pointer signature
- All other files: no changes needed (already clean)
…processing tests

naive_bayes_workflow.rs:
- ComplementNB does not exist in this codebase; replace with MultinomialNB
  (smartcore::naive_bayes::multinomial) which covers the same use-case and
  actually compiles.

preprocessing_workflow.rs:
- Transformer trait is at smartcore::api::Transformer, not smartcore::Transformer
- StandardScaler lives at smartcore::preprocessing::numerical::{StandardScaler,
  StandardScalerParameters}; import the params type explicitly so fit() resolves
- StandardScaler has no inverse_transform(); rewrite that test to verify the
  scaled column means are ~0 and std ~1 (same invariant, different assertion)
- OneHotEncoder::fit requires T: Categorizable which is only impl for f32/f64,
  not u32; switch the input matrix to f64 and use OneHotEncoderParams::from_cat_idx
  (there is no Default impl for OneHotEncoderParams); fix the binary-value
  assertion to compare f64 (0.0/1.0) instead of u32
…into scope

cluster_workflow.rs:
- DBSCANParameters has no ::new() constructor; use the builder pattern:
  DBSCANParameters::default().with_min_samples(2).with_eps(0.5)
  (the default distance is already Euclidean, so no need to pass it)
- DBSCAN has no ::fit_predict(); use DBSCAN::fit(&x, params).and_then(|m| m.predict(&x))
- Annotate `labels` as Vec<i32>: DBSCAN assigns noise=0, clusters start at 1,
  and the KMeans labels need Vec<usize> annotation to satisfy HashSet<usize>
- Drop the unused Distances import from dbscan_inline_workflow

preprocessing_workflow.rs:
- StandardScaler::fit is provided by the UnsupervisedEstimator trait;
  add `use smartcore::api::UnsupervisedEstimator` inside each test fn so
  the method resolves correctly
svm_workflow.rs:
- Kernels::rbf() takes 0 arguments (gamma is fixed internally); remove the float arg
- SVC::fit and SVR::fit take params by reference; pass &params
- SVC predict returns Vec<f64> not Vec<i32>; change y to Vec<f64> and
  compare preds/y as f64 throughout

naive_bayes_workflow.rs:
- CategoricalNB<T> requires T: Unsigned; f64 does not satisfy this.
  Switch x matrix to DenseMatrix<u32> and y to Vec<u32>.
- MultinomialNB<TX,TY> requires TX: Unsigned + TY: Unsigned; same fix:
  use DenseMatrix<u32> for x and Vec<u32> for y.
decomposition_workflow.rs:
- `smartcore::Transformer` does not exist at the crate root (no pub use re-export
  in lib.rs); change all 3 occurrences to `smartcore::api::Transformer`
- PCA::fit is provided by UnsupervisedEstimator trait; add
  `use smartcore::api::UnsupervisedEstimator` alongside Transformer in each
  PCA test so the method resolves
- Remove unused `use smartcore::linalg::basic::arrays::Array` from
  pca_iris_reduce_workflow (Array is not called anywhere in that fn)

tree_workflow.rs:
- Remove unused `use smartcore::linalg::basic::arrays::Array` from
  decision_tree_classifier_iris_workflow
… trait import

svm_workflow.rs:
- SVC<TX, TY> requires TY: Number + Ord; f64 does not implement Ord.
  Switch y labels to Vec<i32> with +1/-1 convention, which is the
  standard SVC binary label type and satisfies the Ord bound.
  Update accuracy_f64 -> accuracy_i32 helper accordingly.

decomposition_workflow.rs:
- `shape()` is provided by the `Array` trait which must be in scope;
  add `use smartcore::linalg::basic::arrays::Array` in every test that
  calls `.shape()` on a DenseMatrix.
- PCA::fit and PCA::transform are inherent methods (not trait-dispatched
  in test context), so Transformer and UnsupervisedEstimator imports are
  unused; remove them to silence the 4 unused-import warnings.
…ay::is_empty

model_selection_workflow.rs:
- CrossValidationParameters does not exist; use KFold::default().with_n_splits()
- cross_validate() takes an estimator instance via ::new(), not a fn pointer like ::fit
- score must be passed as &score_fn (reference), not by value
- is_empty() comes from the Array trait; add `use smartcore::linalg::basic::arrays::Array`
- from_iterator() comes from Array2 trait; add `use smartcore::linalg::basic::arrays::Array2`
  in the datasets-gated test

cluster_workflow.rs:
- from_iterator() requires Array2 trait in scope; add the import in the datasets test

neighbors_workflow.rs:
- same Array2 import needed for from_iterator in the datasets test
…nistic fixtures in lr_fit_predict_multiclass and lr_fit_predict_binary
@Mec-iS
Mec-iS merged commit d8d7383 into development Aug 10, 2026
13 checks passed
@Mec-iS
Mec-iS deleted the fix/397-integration-tests branch August 10, 2026 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stage 6: Integration tests (new tests/ dir, end-to-end workflows) (tracking #391)

1 participant