pub struct SubsetDataset<D>where
D: Dataset,{
pub wrapped: Arc<D>,
pub indices: Vec<usize>,
}Fields§
§wrapped: Arc<D>§indices: Vec<usize>Implementations§
Source§impl<D: Dataset> SubsetDataset<D>
impl<D: Dataset> SubsetDataset<D>
Sourcepub fn new(dataset: impl Into<Arc<D>>, indices: Vec<usize>) -> Self
pub fn new(dataset: impl Into<Arc<D>>, indices: Vec<usize>) -> Self
Creates a new selection dataset with the given dataset and indices without checking bounds.
§Arguments
dataset- The original dataset to select from.indices- A vector of indices to select from the dataset.
Sourcepub fn from_indices(
dataset: impl Into<Arc<D>>,
indices: Vec<usize>,
) -> SubsetDatasetResult<Self>
pub fn from_indices( dataset: impl Into<Arc<D>>, indices: Vec<usize>, ) -> SubsetDatasetResult<Self>
Creates a new selection dataset with the given dataset and indices.
Checks that all indices are within the bounds of the dataset.
§Arguments
dataset- The original dataset to select from.indices- A slice of indices to select from the dataset. These indices must be within the bounds of the dataset.
Sourcepub fn select_all(dataset: impl Into<Arc<D>>) -> Self
pub fn select_all(dataset: impl Into<Arc<D>>) -> Self
Creates a new selection dataset that selects all indices from the dataset.
This allocates a 1-to-1 mapping of indices to the dataset size, essentially functioning as a no-op selection. This is only useful when the dataset will later be shuffled or transformed in place.
§Arguments
dataset- The original dataset to select from.
§Returns
A new SubsetDataset that selects all indices from the dataset.
Sourcepub fn slice(&self, start: usize, end: usize) -> SubsetDatasetResult<Self>
pub fn slice(&self, start: usize, end: usize) -> SubsetDatasetResult<Self>
Creates a new dataset that is a slice of the current selection dataset.
Slices the selection indices from [start..end].
Independent of future shuffles on the parent, but shares the same wrapped dataset.
§Arguments
start- The start of the range.end- The end of the range (exclusive).
Sourcepub fn split(&self, num: usize) -> SubsetDatasetResult<Vec<Self>>
pub fn split(&self, num: usize) -> SubsetDatasetResult<Vec<Self>>
Split into num datasets by slicing the selection indices evenly.
Split is done via slice, so the datasets share the same wrapped dataset.
Independent of future shuffles on the parent, but shares the same wrapped dataset.
§Arguments
num- The number of datasets to split into.
§Returns
A vector of SubsetDataset instances, each containing a subset of the indices.
Trait Implementations§
Auto Trait Implementations§
impl<D> Freeze for SubsetDataset<D>
impl<D> RefUnwindSafe for SubsetDataset<D>where
Arc<D>: RefUnwindSafe,
impl<D> Send for SubsetDataset<D>
impl<D> Sync for SubsetDataset<D>
impl<D> Unpin for SubsetDataset<D>
impl<D> UnsafeUnpin for SubsetDataset<D>where
Arc<D>: UnsafeUnpin,
impl<D> UnwindSafe for SubsetDataset<D>where
Arc<D>: UnwindSafe,
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more