Reorganize the shared example code

The new layout deviates from what the Rust book suggests

  https://doc.rust-lang.org/book/ch11-03-test-organization.html#submodules-in-integration-tests

and uses the frowned-upon `#[path]` attribute,

  https://doc.rust-lang.org/style-guide/advice.html#modules

but we've decided that having a descriptive module filename instead of
`mod.rs` is worth the cost.
This commit is contained in:
Aaron Fenyes 2025-07-18 10:59:41 -07:00
parent 2137284358
commit 477d6a5064
5 changed files with 30 additions and 51 deletions

View file

@ -4,11 +4,11 @@ use nalgebra::DMatrix;
use dyna3::engine::{Q, DescentHistory, RealizationResult};
pub fn print_title(title: &str) {
pub fn title(title: &str) {
println!("─── {title} ───");
}
pub fn print_realization_diagnostics(realization_result: &RealizationResult) {
pub fn realization_diagnostics(realization_result: &RealizationResult) {
let RealizationResult { result, history } = realization_result;
println!();
if let Err(ref message) = result {
@ -20,15 +20,15 @@ pub fn print_realization_diagnostics(realization_result: &RealizationResult) {
println!("Loss: {}", history.scaled_loss.last().unwrap());
}
pub fn print_gram_matrix(config: &DMatrix<f64>) {
pub fn gram_matrix(config: &DMatrix<f64>) {
println!("\nCompleted Gram matrix:{}", (config.tr_mul(&*Q) * config).to_string().trim_end());
}
pub fn print_config(config: &DMatrix<f64>) {
pub fn config(config: &DMatrix<f64>) {
println!("\nConfiguration:{}", config.to_string().trim_end());
}
pub fn print_loss_history(history: &DescentHistory) {
pub fn loss_history(history: &DescentHistory) {
println!("\nStep │ Loss\n─────┼────────────────────────────────");
for (step, scaled_loss) in history.scaled_loss.iter().enumerate() {
println!("{:<4}{}", step, scaled_loss);