pub struct AlphaValues { /* private fields */ }Expand description
Owned opacity coefficients and their complete immutable mapping declaration.
Construction eagerly materializes custom functions; no callback survives in a
Plot, Canvas or output. Alpha zero preserves scientific membership. Attach with
AlphaEncoding to select observations, explicit collective keys or bins.
use lichtung_plot::{NumericValues, scales::{AlphaSemantics, AlphaValues}};
let alpha = AlphaValues::linear(
NumericValues::new("confidence", [0.0, 0.25, 0.5, 0.75, 1.0]),
(0.0, 1.0), (0.0, 1.0),
)?;
assert_eq!(alpha.semantics(), AlphaSemantics::Continuous);
assert_eq!((0..alpha.len()).map(|i| alpha.get(i).unwrap()).collect::<Vec<_>>(),
[0.0, 0.25, 0.5, 0.75, 1.0]);The representation is private:
use lichtung_plot::scales::AlphaValues;
fn private(values: AlphaValues) { let _ = values.declaration; }Implementations§
Source§impl AlphaValues
impl AlphaValues
Sourcepub fn new(
name: impl Into<String>,
values: impl IntoIterator<Item = f64>,
) -> Result<AlphaValues, Error>
pub fn new( name: impl Into<String>, values: impl IntoIterator<Item = f64>, ) -> Result<AlphaValues, Error>
Own caller-computed coefficients in [0, 1] without guide semantics.
Names must be nonempty, already trimmed and control-free. Empty values are valid; attachment checks the actual unit alignment before fonts.
Sourcepub fn linear(
source: NumericValues,
domain: (f64, f64),
range: (f64, f64),
) -> Result<AlphaValues, Error>
pub fn linear( source: NumericValues, domain: (f64, f64), range: (f64, f64), ) -> Result<AlphaValues, Error>
Map finite source values linearly over an explicit increasing domain.
Clamp out-of-domain values. Ascending, descending and constant coefficient ranges are valid. Missing/nonfinite sources and nonfinite/nonincreasing domains reject during construction.
Sourcepub fn log10(
source: NumericValues,
domain: (f64, f64),
range: (f64, f64),
) -> Result<AlphaValues, Error>
pub fn log10( source: NumericValues, domain: (f64, f64), range: (f64, f64), ) -> Result<AlphaValues, Error>
Map positive finite source values over an explicit positive log10 domain.
Endpoints must be strictly increasing and remain distinguishable after
binary64 log10. Nonpositive sources reject rather than clamping. Other
clamping rules match Self::linear.
Sourcepub fn continuous(
source: NumericValues,
domain: (f64, f64),
f: impl FnMut(f64) -> f64,
) -> Result<AlphaValues, Error>
pub fn continuous( source: NumericValues, domain: (f64, f64), f: impl FnMut(f64) -> f64, ) -> Result<AlphaValues, Error>
Declare a continuous mapping and eagerly materialize its finite values.
Invoke f once for every distinct clamped source coordinate and required
numeric representative, in numeric order. Retain the complete evaluated
table and original members; no function, inverse or smooth ramp is stored.
The domain must be finite and strictly increasing, and sources nonmissing
and finite. Up to five original-domain examples explain this declaration.
Sourcepub fn categorical(
source: CategoryValues,
f: impl FnMut(&str) -> f64,
) -> Result<AlphaValues, Error>
pub fn categorical( source: CategoryValues, f: impl FnMut(&str) -> f64, ) -> Result<AlphaValues, Error>
Declare a categorical map, invoking f once per first-observed raw level.
Null sources reject. Complete table order survives Self::select; only
actual consumed categories appear in automatic explanations, including zero.
Sourcepub fn threshold(
source: NumericValues,
boundaries: impl IntoIterator<Item = f64>,
alphas: impl IntoIterator<Item = f64>,
) -> Result<AlphaValues, Error>
pub fn threshold( source: NumericValues, boundaries: impl IntoIterator<Item = f64>, alphas: impl IntoIterator<Item = f64>, ) -> Result<AlphaValues, Error>
Declare increasing finite boundaries and exactly one more alpha coefficient.
Intervals are < b0, [b0,b1), …, >= blast; equality belongs to the
right. No boundaries plus one coefficient declares all values. Sources must be
finite and nonmissing. Labels come from the actual bounds, not caller text.
Sourcepub fn select(
&self,
indices: impl IntoIterator<Item = usize>,
) -> Result<AlphaValues, Error>
pub fn select( &self, indices: impl IntoIterator<Item = usize>, ) -> Result<AlphaValues, Error>
Select original occurrences while retaining the complete shared declaration.
Repeated indices are allowed; out-of-range indices reject. Construct pooled custom/category maps once and select per Plot to preserve Shared recipes.
Sourcepub fn get(&self, index: usize) -> Option<f64>
pub fn get(&self, index: usize) -> Option<f64>
One occurrence’s final coefficient, or None outside the retained input.
Sourcepub fn values(&self) -> &[f64]
pub fn values(&self) -> &[f64]
Borrow all materialized opacity coefficients in their retained order.
Sourcepub fn semantics(&self) -> AlphaSemantics
pub fn semantics(&self) -> AlphaSemantics
Explicit explanatory classification, independent of selected coefficients.
Sourcepub fn get_numeric_source(&self) -> Option<&NumericValues>
pub fn get_numeric_source(&self) -> Option<&NumericValues>
The original numeric source, including explicitly supplied coefficients.
Sourcepub fn get_category_source(&self) -> Option<&KeyValues>
pub fn get_category_source(&self) -> Option<&KeyValues>
The original categorical source, when a category mapping was declared.
Sourcepub fn get_threshold_indices(&self) -> Option<&[usize]>
pub fn get_threshold_indices(&self) -> Option<&[usize]>
The actual threshold interval of each retained occurrence.
Sourcepub fn get_mapping(&self) -> &AlphaMapping
pub fn get_mapping(&self) -> &AlphaMapping
Borrow the full original mapping independently of selected occurrences.
Trait Implementations§
impl AlphaValuesInput for AlphaValues
Source§impl Clone for AlphaValues
impl Clone for AlphaValues
Source§fn clone(&self) -> AlphaValues
fn clone(&self) -> AlphaValues
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AlphaValues
impl Debug for AlphaValues
impl Eq for AlphaValues
Source§impl PartialEq for AlphaValues
impl PartialEq for AlphaValues
impl StructuralPartialEq for AlphaValues
Source§impl TryFrom<NumericValues> for AlphaValues
impl TryFrom<NumericValues> for AlphaValues
Auto Trait Implementations§
impl Forget for AlphaValues
impl Freeze for AlphaValueswhere
*const ArcInner<String> is !null: Freeze,
PhantomData<ArcInner<String>>: Freeze,
*const ArcInner<AlphaData> is !null: Freeze,
PhantomData<ArcInner<AlphaData>>: Freeze,
*const ArcInner<AlphaDeclaration> is !null: Freeze,
PhantomData<ArcInner<AlphaDeclaration>>: Freeze,
impl Move for AlphaValues
impl RefUnwindSafe for AlphaValues
impl Send for AlphaValues
impl Sync for AlphaValues
impl Unpin for AlphaValues
impl UnsafeUnpin for AlphaValueswhere
*const ArcInner<String> is !null: UnsafeUnpin,
PhantomData<ArcInner<String>>: UnsafeUnpin,
*const ArcInner<AlphaData> is !null: UnsafeUnpin,
PhantomData<ArcInner<AlphaData>>: UnsafeUnpin,
*const ArcInner<AlphaDeclaration> is !null: UnsafeUnpin,
PhantomData<ArcInner<AlphaDeclaration>>: UnsafeUnpin,
impl UnwindSafe for AlphaValues
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> AlphaInput for Twhere
T: AlphaValuesInput,
impl<T> AlphaInput for Twhere
T: AlphaValuesInput,
fn bind_alpha( self, source: Option<&dyn ArraySource>, expected: Option<usize>, copies: usize, rows: bool, reference: Option<&DataSourceRef>, ) -> Result<AlphaEncoding, AdapterError>
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> Scalar for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.