dataeval.data.View

class dataeval.data.View(dataset, operations=None)

Dataset view built from an ordered pipeline of Operation.

Wraps a source dataset and applies operations that filter, reorder, transform, or relabel it, producing a subset/rewritten view without modifying the original.

Parameters:
dataset : Dataset[_TDatum]

Source dataset to apply operations to. Any object implementing the Dataset interface – indexed access via __getitem__ and __len__ – is accepted, including a bare, image-only dataset. A target-bearing (annotated) dataset is only required when an applied operation reads per-datum targets, i.e. when an operation declares Operation.requires (e.g. ClassFilter, ClassBalance, Relabel). Target-free operations such as Limit, Shuffle, Reverse, and Indices operate on a plain dataset. Operations that need targets trigger an upfront validation of the source dataset, raising MaiteShapeError if the targets are missing.

operations : Operation or Sequence[Operation] or None, default None

Operations to apply, in order. When None the view is an unfiltered, untransformed pass-through.

Notes

Operations are applied strictly in the order provided, each one seeing the result of the previous. Order is therefore meaningful — [Relabel(...), ClassFilter([0])] filters on the relabeled classes, while the reverse filters on the source ones, and [Limit(1000), Shuffle(), Limit(100)] keeps a random 100 of the first 1000.

Examples

>>> from dataeval.data import View, ClassFilter, Limit
>>> view = View(dataset, [ClassFilter(classes=[0, 2]), Limit(size=5)])
>>> print(view)
View Dataset
------------
    Operations: [ClassFilter(classes=[0, 2], filter_detections=True), Limit(size=5)]
    Selected Size: 5
map(fn, *, where=None)

Register a per-datum content transform. where=None targets all indices.

read(src_index)

Read one source datum with all currently-registered transforms applied.

resolve_indices(indices=None)

Return the list of source dataset indices after all operations have been applied.

Parameters:
indices : int or SourceIndex or Sequence[int | SourceIndex] or None, default None

Specific indices from the view to resolve to source indices. When None, returns all selected indices.

Returns:

The list of selected indices from the original dataset.

Return type:

list[int]

property metadata : dataeval.protocols.DatasetMetadata

Dataset metadata information, including any operation rewrites.

property operation_groups : list[list[Operation]]

Operation lists from each construction call, innermost (oldest) first.

View(View(base, [A, B]), [C]) returns [[A, B], [C]]. Empty wrappers contribute nothing. The grouping matches the user’s nesting intent and is the natural shape for sidecar metadata (see dataeval.io).

property root_dataset : dataeval.protocols.Dataset[_TDatum]

The original dataset at the bottom of any View wrapping chain.