pub struct NDArrayCollector<F> { /* private fields */ }
Expand description

NDArrayCollector is a Collector which transforms frame-based replay data into a 2-dimensional array of type ndarray::Array2, where each element is of a specified floating point type.

It’s initialized with collections of FeatureAdder instances which extract global, player independent features for each frame, and PlayerFeatureAdder, which add player specific features for each frame.

It’s main entrypoint is Self::get_meta_and_ndarray, which provides ndarray::Array2 along with column headers and replay metadata.

Implementations§

source§

impl<F> NDArrayCollector<F>

source

pub fn new( feature_adders: FeatureAdders<F>, player_feature_adders: PlayerFeatureAdders<F> ) -> Self

Creates a new instance of NDArrayCollector.

Arguments
Returns

A new NDArrayCollector instance. This instance is initialized with empty data, no replay metadata and zero frames added.

source

pub fn get_column_headers(&self) -> NDArrayColumnHeaders

Returns the column headers of the 2-dimensional array produced by the NDArrayCollector.

Returns

An instance of NDArrayColumnHeaders representing the column headers in the collected data.

source

pub fn get_ndarray(self) -> SubtrActorResult<Array2<F>>

This function consumes the NDArrayCollector instance and returns the data collected as an ndarray::Array2.

Returns

A SubtrActorResult containing the collected data as an ndarray::Array2.

This method is a shorthand for calling Self::get_meta_and_ndarray and discarding the replay metadata and headers.

source

pub fn get_meta_and_ndarray( self ) -> SubtrActorResult<(ReplayMetaWithHeaders, Array2<F>)>

Consumes the NDArrayCollector and returns the collected features as a 2D ndarray, along with replay metadata and headers.

Returns

A SubtrActorResult containing a tuple:

source

pub fn process_and_get_meta_and_headers( &mut self, replay: &Replay ) -> SubtrActorResult<ReplayMetaWithHeaders>

Processes a boxcars::Replay and returns its metadata along with column headers.

This method first processes the replay using a ReplayProcessor. It then updates the replay_meta field if it’s not already set, and returns a clone of the replay_meta field along with column headers of the data.

Arguments
Returns

A SubtrActorResult containing a ReplayMetaWithHeaders that includes the metadata of the replay and column headers.

source§

impl NDArrayCollector<f32>

source

pub fn from_strings( fa_names: &[&str], pfa_names: &[&str] ) -> SubtrActorResult<Self>

Trait Implementations§

source§

impl<F> Collector for NDArrayCollector<F>

source§

fn process_frame( &mut self, processor: &ReplayProcessor<'_>, frame: &Frame, frame_number: usize, current_time: f32 ) -> SubtrActorResult<TimeAdvance>

Process a single frame from a replay. Read more
source§

fn process_replay(self, replay: &Replay) -> SubtrActorResult<Self>

Process an entire replay. Read more
source§

impl<F: TryFrom<f32> + Send + Sync + 'static> Default for NDArrayCollector<F>where <F as TryFrom<f32>>::Error: Debug,

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<F> !RefUnwindSafe for NDArrayCollector<F>

§

impl<F> Send for NDArrayCollector<F>where F: Send,

§

impl<F> Sync for NDArrayCollector<F>where F: Sync,

§

impl<F> Unpin for NDArrayCollector<F>where F: Unpin,

§

impl<F> !UnwindSafe for NDArrayCollector<F>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.