Skip to content

chore(xgboost): apply #445 review follow-ups to the subsample clamp - #447

Merged
Mec-iS merged 4 commits into
mainfrom
xgboost-review-hygiene
Aug 24, 2026
Merged

chore(xgboost): apply #445 review follow-ups to the subsample clamp#447
Mec-iS merged 4 commits into
mainfrom
xgboost-review-hygiene

Conversation

@Mec-iS

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

Copy link
Copy Markdown
Collaborator

Follow-up to #445 — review notes from #445 plus an idiomatic-Rust hygiene pass.

Checklist

  • My branch is up-to-date with main branch.
  • Everything works and tested on latest stable Rust.
  • Coverage and Linting have been applied

Current behaviour

PR #445 merged with minor review notes still open. A follow-up review against the idiomatic-rust resource list surfaced additional hygiene findings: panics escaping Result APIs, wildcard match arms, and zero #[must_use] coverage.

New expected behaviour

Commit 1 — #445 review follow-ups (0395b41)

  • with_subsample doc states the one-row minimum holds only for a non-empty dataset
  • sample_without_replacement gains debug_assert! guards for its internal invariants
  • Single-row test asserts the prediction moves off base_score = 0.5 towards the target
  • Blank line restored between adjacent tests; 0.6.12 changelog bullet trimmed to user-visible behaviour

Commit 2 — svm panic fixes (33db5f4)

  • MultiClassSVC::fit propagates binary-fit failures instead of unwrapping
  • MultiClassSVC::predict returns PredictFailed when called before fit, and when fit saw fewer than two classes, instead of panicking through a Result API
  • PredictorBorrow::predict impls delegate directly to the inherent fallible predict

Commit 3 — Kernels setter arms (5590534)

  • with_gamma / with_degree / with_coef0 enumerate every variant explicitly; a future kernel variant holding these fields can no longer silently ignore the setters

Commit 4 — #[must_use] coverage (f6a3f2e)

  • All 49 *Parameters/*Params config types gain type-level #[must_use], covering every with_* builder returning Self
  • Remaining library callables flagged by clippy::must_use_candidate (dataset loaders, metric/error constructors, linalg factories) gain fn-level #[must_use]
  • Lint is now silent under -Wclippy::must_use_candidate

Deliberately not changed

  • clippy::indexing_slicing (~970 sites): deliberate trade in hot numeric kernels; dimension invariants are checked at fit()/view construction. Suggested as a per-module decision for new code only.
  • 18 ..Default::default() sites in tests: intentional partial configuration in hyperparameter-grid tests, not production construction.

Change logs

Changed

  • No user-facing behaviour changes except MultiClassSVC::predict now returns Err(Failed) in two states where it previously panicked (before fit; single-class training data).

Verification

cargo fmt --all -- --check, cargo clippy --all-features -- -Drust-2018-idioms -Drust-2024-compatibility -Dwarnings, and cargo test --all-features (619 passed) all green. Pre-commit hook re-verifies fmt + clippy on every commit.

Mec-iS added 4 commits August 24, 2026 17:20
- Document that the one-row minimum holds for a non-empty dataset
- Add debug_asserts for the population_size and subsample_ratio bounds
- Assert the single-row fit moves the prediction towards the target
- Separate adjacent tests with a blank line
- Trim the 0.6.12 changelog bullet to user-visible behaviour
Predict and fit propagated internal unwraps to callers through
Result-returning methods:

- PredictorBorrow::predict delegates to the inherent predict, which
  already returns Failed errors.
- MultiClassSVC::fit propagates multiclass_fit failures with ?.
- predict returns PredictFailed when called before fit, e.g. on a
  deserialized model with no classifiers.
- predict returns PredictFailed instead of panicking when fit saw
  fewer than two classes.
with_gamma, with_degree, and with_coef0 matched non-applicable
kernels with a catch-all arm. A future kernel variant holding these
fields would silently ignore the setters. Each setter now lists every
variant explicitly. Also marks Kernels #[must_use].
clippy::must_use_candidate flagged 149 callables whose results are
meaningless to discard: parameter structs and their with_* builders,
dataset loaders, metric constructors, error constructors, and linalg
factory methods.

The 49 *Parameters/*Params config types gain a type-level #[must_use],
which covers every builder method returning Self. The remaining
library functions gain fn-level #[must_use]. Kernels was already
covered in the previous commit.
@Mec-iS

Mec-iS commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator Author

Widened this PR with three more commits applying the idiomatic-Rust hygiene findings (33db5f4, 5590534, f6a3f2e): svm panic-through-Result fixes, explicit Kernels setter arms, and full #[must_use] coverage (130 attributes; clippy::must_use_candidate now silent). indexing_slicing left alone by design; rationale in the PR description.

@Mec-iS
Mec-iS merged commit 0b7f188 into main Aug 24, 2026
13 checks passed
@Mec-iS
Mec-iS deleted the xgboost-review-hygiene branch August 24, 2026 17:05
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.

1 participant