Skip to main content

AlphaValues

Struct AlphaValues 

Source
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

Source

pub fn new( name: impl Into<String>, values: impl IntoIterator<Item = f64>, ) -> Result<Self>

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.

Source

pub fn linear( source: NumericValues, domain: (f64, f64), range: (f64, f64), ) -> Result<Self>

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.

Source

pub fn log10( source: NumericValues, domain: (f64, f64), range: (f64, f64), ) -> Result<Self>

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.

Source

pub fn continuous( source: NumericValues, domain: (f64, f64), f: impl FnMut(f64) -> f64, ) -> Result<Self>

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.

Source

pub fn categorical( source: CategoryValues, f: impl FnMut(&str) -> f64, ) -> Result<Self>

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.

Source

pub fn threshold( source: NumericValues, boundaries: impl IntoIterator<Item = f64>, alphas: impl IntoIterator<Item = f64>, ) -> Result<Self>

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.

Source

pub fn select(&self, indices: impl IntoIterator<Item = usize>) -> Result<Self>

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.

Source

pub fn name(&self) -> &str

Raw source identity used for automatic titles and diagnostics.

Source

pub fn len(&self) -> usize

Number of retained occurrences.

Source

pub fn is_empty(&self) -> bool

Whether no occurrences are retained.

Source

pub fn get(&self, index: usize) -> Option<f64>

One occurrence’s final coefficient, or None outside the retained input.

Source

pub fn values(&self) -> &[f64]

Borrow all materialized opacity coefficients in their retained order.

Source

pub fn semantics(&self) -> AlphaSemantics

Explicit explanatory classification, independent of selected coefficients.

Source

pub fn get_numeric_source(&self) -> Option<&NumericValues>

The original numeric source, including explicitly supplied coefficients.

Source

pub fn get_category_source(&self) -> Option<&KeyValues>

The original categorical source, when a category mapping was declared.

Source

pub fn get_threshold_indices(&self) -> Option<&[usize]>

The actual threshold interval of each retained occurrence.

Source

pub fn get_mapping(&self) -> &AlphaMapping

Borrow the full original mapping independently of selected occurrences.

Source

pub fn examples(&self) -> &[(f64, f64)]

Actual original-domain examples and their evaluated opacity.

Trait Implementations§

Source§

impl Clone for AlphaValues

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AlphaValues

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for AlphaValues

Source§

impl PartialEq for AlphaValues

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for AlphaValues

Source§

impl TryFrom<NumericValues> for AlphaValues

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(source: NumericValues) -> Result<Self>

Performs the conversion.

Auto Trait Implementations§

§

impl Forget for AlphaValues

§

impl Freeze for AlphaValues
where *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
where Arc<String>: Send, Arc<AlphaData>: Send, Arc<AlphaDeclaration>: Send,

§

impl Sync for AlphaValues
where Arc<String>: Sync, Arc<AlphaData>: Sync, Arc<AlphaDeclaration>: Sync,

§

impl Unpin for AlphaValues
where Arc<String>: Unpin, Arc<AlphaData>: Unpin, Arc<AlphaDeclaration>: Unpin,

§

impl UnsafeUnpin for AlphaValues
where *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
where Arc<String>: UnwindSafe, Arc<AlphaData>: UnwindSafe, Arc<AlphaDeclaration>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,

Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V