Skip to main content

ColumnProjection

Struct ColumnProjection 

Source
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::{Line, binding::{ArraySource, ColumnProjection}};
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>

Source

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.

Source

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.

Source

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§

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>
where &'columns [(usize, &'columns dyn ArraySource)]: Freeze, &'columns [(usize, &'columns str)]: Freeze, &'columns DataSourceInfo: Freeze,

§

impl<'columns> Move for ColumnProjection<'columns>

§

impl<'columns> Unpin for ColumnProjection<'columns>
where &'columns [(usize, &'columns dyn ArraySource)]: Unpin, &'columns [(usize, &'columns str)]: Unpin, &'columns DataSourceInfo: Unpin,

§

impl<'columns> UnsafeUnpin for ColumnProjection<'columns>
where &'columns [(usize, &'columns dyn ArraySource)]: UnsafeUnpin, &'columns [(usize, &'columns str)]: UnsafeUnpin, &'columns DataSourceInfo: UnsafeUnpin,

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> 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<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, 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