pub struct ColumnProjection<'columns> { /* private fields */ }Expand description
Borrowed one-column sources addressed by their original logical indices.
The shape is the actual source’s (rows, logical_column_count), not the
number of supplied columns. Each entry supplies a two-dimensional view or
values/present pair with shape (rows, 1). Different entries may have
different element types, strides and validity. Construction validates only
descriptor structure; selecting a role snapshots only its supplied values.
Existing scalar and ordered index selectors retain their meaning. An
in-bounds column without a value entry fails explicitly; .. still means
every original column, not every supplied entry. Grid positions and source
row IDs remain independent of field identities.
Self::from_identities supplies the same original namespace without any
value entries when only field-identity resolution is needed.
use lichtung_plot_ndarray::{ArraySource, ColumnProjection, Line};
use ndarray::array;
let x = array![[0.], [5.], [20.]];
let y7 = array![[4.], [5.], [6.]];
let y2 = array![[1.], [2.], [3.]];
let columns: [(usize, &dyn ArraySource); 3] =
[(4, &x.view()), (7, &y7.view()), (2, &y2.view())];
let identities = [(4, "time"), (7, "treated"), (2, "control")];
let source = ColumnProjection::new((3, 10), &columns)?
.with_identities(&identities)?;
let adapted = Line::from_data(source, 4usize, [7usize, 2usize])?;
let (plot, metadata) = adapted.into_parts(); // releases all source borrows
let _restored = Line::from_parts(plot, metadata);Implementations§
Source§impl<'columns> ColumnProjection<'columns>
impl<'columns> ColumnProjection<'columns>
Sourcepub fn new(
source_shape: (usize, usize),
columns: &'columns [(usize, &'columns dyn ArraySource)],
) -> Result<Self, AdapterError>
pub fn new( source_shape: (usize, usize), columns: &'columns [(usize, &'columns dyn ArraySource)], ) -> Result<Self, AdapterError>
Validate and borrow nonempty, unique, in-bounds one-column descriptors.
Retains original coordinates and positional Column N identities without
reading observations. Each source must have shape (source_shape.0, 1)
and pass its existing validity-shape validation.
Sourcepub fn from_identities(
source_shape: (usize, usize),
identities: &'columns [(usize, &'columns str)],
) -> Result<Self, AdapterError>
pub fn from_identities( source_shape: (usize, usize), identities: &'columns [(usize, &'columns str)], ) -> Result<Self, AdapterError>
Borrow an explicit original namespace without projecting observations.
The shape is the actual source shape, not the number of identities or
selector rows. Indices and raw identities follow Self::with_identities
validation. An empty identity table remains explicit: it does not enable
positional-name fallback. Every value lookup still fails as unprojected.
This uses the same descriptor representation; Self::new continues to
require at least one value entry.
Sourcepub fn with_identities(
self,
identities: &'columns [(usize, &'columns str)],
) -> Result<Self, AdapterError>
pub fn with_identities( self, identities: &'columns [(usize, &'columns str)], ) -> Result<Self, AdapterError>
Supply exact raw field identities separately from coordinates and labels.
Indices and raw strings must each be unique, all indices must be in the original bounds, and every value entry needs an identity. Additional in-bounds identities may describe unprojected columns, for example targets named by a generated-column alpha key variable. They do not grant value lookup. An explicit table never falls back to positional identities.
Replaces any previous table completely. Strings are borrowed unchanged: empty/whitespace names and display collisions retain native validation. No observation is read, and neither this table nor its borrow enters the owned native Plot or binding metadata.
Trait Implementations§
impl ArraySource for ColumnProjection<'_>
Auto Trait Implementations§
impl<'columns> !RefUnwindSafe for ColumnProjection<'columns>
impl<'columns> !Send for ColumnProjection<'columns>
impl<'columns> !Sync for ColumnProjection<'columns>
impl<'columns> !UnwindSafe for ColumnProjection<'columns>
impl<'columns> Forget for ColumnProjection<'columns>
impl<'columns> Freeze for ColumnProjection<'columns>
impl<'columns> Move for ColumnProjection<'columns>
impl<'columns> Unpin for ColumnProjection<'columns>
impl<'columns> UnsafeUnpin for ColumnProjection<'columns>
Blanket Implementations§
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
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
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.