fix(ml): replace unwrap() with ok_or/? in DQN IQN paths
Replace 6 unwrap() calls with safe error handling in DQN IQN code: - Production: 3 unwrap() on iqn_network/iqn_target_network replaced with ok_or_else returning MLError::ModelError for clear diagnostics - Tests: 2 result.unwrap() replaced with ?, 2 DQN::new().unwrap() replaced with ? after changing test signatures to return anyhow::Result<()> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1361,22 +1361,16 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_production_features_have_51_dimensions() {
|
||||
fn test_production_features_have_51_dimensions() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let mut extractor = ProductionFeatureExtractorAdapter::new();
|
||||
// Feed 55 price updates (past the warmup period of 50)
|
||||
for i in 0..55 {
|
||||
let price = 100.0 + i as f64 * 0.1;
|
||||
let volume = 1000.0;
|
||||
let timestamp = Utc::now();
|
||||
extractor
|
||||
.update(price, volume, timestamp)
|
||||
.unwrap_or_else(|e| {
|
||||
panic!("Production extractor update failed at step {}: {}", i, e)
|
||||
});
|
||||
extractor.update(price, volume, timestamp)?;
|
||||
}
|
||||
let features = extractor
|
||||
.extract_features()
|
||||
.unwrap_or_else(|e| panic!("Production extractor extract_features failed: {}", e));
|
||||
let features = extractor.extract_features()?;
|
||||
assert_eq!(
|
||||
features.len(),
|
||||
51,
|
||||
@@ -1391,6 +1385,7 @@ mod tests {
|
||||
i, val
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user