optirs-core 0.3.1

OptiRS core optimization algorithms and utilities
Documentation
//! Auto-generated module
//!
//! 🤖 Generated with [SplitRS](https://github.com/cool-japan/splitrs)

use scirs2_core::ndarray::{Array1, ArrayBase, ScalarOperand};
use std::collections::{HashMap, VecDeque};
use std::time::{Duration, Instant};

use super::types::{StreamingConfig, StreamingDataPoint, StreamingMetrics, StreamingOptimizer};

#[cfg(test)]
mod tests {
    use super::*;
    use crate::optimizers::SGD;
    #[test]
    fn test_streaming_config_default() {
        let config = StreamingConfig::default();
        assert_eq!(config.buffer_size, 32);
        assert_eq!(config.latency_budget_ms, 10);
        assert!(config.adaptive_learning_rate);
    }
    #[test]
    fn test_streaming_optimizer_creation() {
        let sgd = SGD::new(0.01);
        let config = StreamingConfig::default();
        let optimizer: StreamingOptimizer<SGD<f64>, f64, scirs2_core::ndarray::Ix2> =
            StreamingOptimizer::new(sgd, config).expect("unwrap failed");
        assert_eq!(optimizer.step_count, 0);
        assert!(optimizer.data_buffer.is_empty());
    }
    #[test]
    fn test_data_point_creation() {
        let features = Array1::from_vec(vec![1.0, 2.0, 3.0]);
        let data_point = StreamingDataPoint {
            features,
            target: Some(0.5),
            timestamp: Instant::now(),
            weight: 1.0,
            metadata: HashMap::new(),
        };
        assert_eq!(data_point.features.len(), 3);
        assert_eq!(data_point.target, Some(0.5));
        assert_eq!(data_point.weight, 1.0);
    }
    #[test]
    fn test_streaming_metrics_default() {
        let metrics = StreamingMetrics::default();
        assert_eq!(metrics.samples_processed, 0);
        assert_eq!(metrics.processing_rate, 0.0);
        assert_eq!(metrics.drift_count, 0);
    }
}