use super::PlotAdapter;
use crate::error::binding;
use crate::{
binding::{BooleanInput, CategoryInput},
data::EstimateStatus,
kind, AdapterError,
};
impl<K: kind::EstimateStatus> PlotAdapter<'_, K> {
pub fn estimate_status_boolean(
mut self,
input: impl BooleanInput,
) -> std::result::Result<Self, AdapterError> {
if input.cell_shape().is_some() || input.selected_columns().is_some() {
return Err(binding(
"estimate status",
"expected one Boolean variable, not a cell grid",
));
}
let capture = self.capture();
let values = capture.bind(input, 1, |input, source| {
input.bind_boolean(source, "estimate status")
})?;
self.aligned("estimate status", values.name(), values.len())?;
self.plot = self.plot.estimate_status_boolean(values)?;
Ok(self)
}
pub fn estimate_status_categorical<I, S>(
mut self,
input: impl CategoryInput,
mapping: I,
) -> std::result::Result<Self, AdapterError>
where
I: IntoIterator<Item = (S, EstimateStatus)>,
S: AsRef<str>,
{
let capture = self.capture();
let values = capture.bind(input, 1, |input, source| {
input.bind_category(source, "estimate status")
})?;
self.aligned("estimate status", values.name(), values.len())?;
self.plot = self.plot.estimate_status_categorical(values, mapping)?;
Ok(self)
}
}
impl<K: kind::Marker> PlotAdapter<'_, K> {
pub fn get_estimate_status(&self) -> Option<&crate::data::EstimateStatusBinding> {
self.plot.get_estimate_status()
}
}