-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
use std::collections::HashMap; | ||
|
||
use plotly::{Plot, Scatter}; | ||
|
||
/// Trait allowing custom behavior to be defined for logging and inspecting values. | ||
pub trait Inspector<V> { | ||
/// Log a value to state. | ||
fn log(&mut self, value: V); | ||
|
||
/// Inspect a value at a given time step. | ||
fn inspect(&self, step: usize) -> Option<V>; | ||
|
||
/// Save the inspector state. | ||
fn save(&self); | ||
} | ||
|
||
// pub struct Plotter { | ||
// values: Vecf64>, | ||
// } | ||
|
||
// impl Plotter { | ||
// pub fn new() -> Self { | ||
// Plotter { | ||
// values: Vec::new(), | ||
// } | ||
// } | ||
// } | ||
|
||
// impl Inspector<f64> for Plotter { | ||
// fn log(&mut self, value: f64) { | ||
// self.values.push(value); | ||
// } | ||
|
||
// fn inspect(&self, step: usize) -> Option<f64> { | ||
// Some(self.values[step]) | ||
// } | ||
|
||
// fn save(&self) { | ||
// let mut plot = Plot::new(); | ||
|
||
// let timesteps: Vec<usize> = (0..self.values.len()).collect(); | ||
// let values: Vec<f64> = timesteps.iter().map(|v| v).collect(); | ||
|
||
// let trace = Scatter::new(timesteps, values).mode(plotly::common::Mode::Markers); | ||
|
||
// plot.add_trace(trace); | ||
// plot.show(); | ||
// } | ||
// } |