pyxc.core.loader

Module Contents

Classes

DataLoaderBase

An abstract base class for data loaders.

ImageLoader

An abstract base class for data loaders.

XYDLoader

An abstract base class for data loaders.

class pyxc.core.loader.DataLoaderBase(container: Type[pyxc.core.container.Container2D], data: numpy.typing.ArrayLike)[source]

Bases: abc.ABC

An abstract base class for data loaders.

Initializes a container with preprocessed data and returns the container when called. Works with a Layer object. Subclasses should implement the prep method to specify the preprocessing of data.

Parameters:
containerContainer2D

The container class to be initialized with the preprocessed data.

dataarray_like

The raw data to be preprocessed.

Attributes:
containerContainer2D

The container that was initialized with the preprocessed data.

abstract prep(data)[source]

Process the provided data.

This method should be implemented in subclasses to specify the preprocessing steps.

Parameters:
dataany

The raw data to be preprocessed.

Returns:
x_raw: np.ndarray

1-dimensional numpy array with shape of (n, ).

y_raw: np.ndarray

1-dimensional numpy array with shape of (n, ).

data: np.ndarray

Structured array with proper column names.

class pyxc.core.loader.ImageLoader(container: Type[pyxc.core.container.Container2D], data: numpy.typing.ArrayLike)[source]

Bases: DataLoaderBase

An abstract base class for data loaders.

Initializes a container with preprocessed data and returns the container when called. Works with a Layer object. Subclasses should implement the prep method to specify the preprocessing of data.

Parameters:
containerContainer2D

The container class to be initialized with the preprocessed data.

dataarray_like

The raw data to be preprocessed.

Attributes:
containerContainer2D

The container that was initialized with the preprocessed data.

prep(data: numpy.typing.ArrayLike) tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray][source]

Process the provided image data.

Provided dimension of the image data should be 2 or 3. If the dimension is 2, then the image is assumed to be grayscale. If the dimension is 3, then the image is assumed to be multi-channel. The number of channels is not limited.

Parameters:
dataany

The raw image data to be preprocessed.

Returns:
x_serial, y_serial, prepped_datatuple

The preprocessed image data. x_serial and y_serial are the flattened arrays for the X and Y coordinates, and prepped_data is the serialized and reshaped image data.

class pyxc.core.loader.XYDLoader(container: Type[pyxc.core.container.Container2D], data: numpy.typing.ArrayLike)[source]

Bases: DataLoaderBase

An abstract base class for data loaders.

Initializes a container with preprocessed data and returns the container when called. Works with a Layer object. Subclasses should implement the prep method to specify the preprocessing of data.

Parameters:
containerContainer2D

The container class to be initialized with the preprocessed data.

dataarray_like

The raw data to be preprocessed.

Attributes:
containerContainer2D

The container that was initialized with the preprocessed data.

prep(data: numpy.typing.ArrayLike) tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray][source]

Process the provided XYD data.

Parameters:
dataarray_like or structured array

The raw XYD data to be preprocessed. The first and second columns should be x- and y-coordinates, and the third and subsequent columns should be data columns.

Returns:
x_raw, y_raw, datatuple

The preprocessed XYD data. x_raw and y_raw are the x- and y-coordinates, and data contains the rest of the columns.