Subsets

class deker.subset.Subset(slice_expression, shape, array, adapter)

Bases: BaseSubset

Array subset.

A subset of the Array data with set bounds, shape, dtype and fill_value.

It is final lazy object that can read, update and clear the data within the Array. Once created, it does not contain any data and does not access the storage until user manually invokes one of the subset API methods. If you need to get and manage all the data from the array you should create a subset with Array[:] or Array[...].

Properties

  • shape: returns shape of the subset

  • bounds: returns the bounds that were applied to the Array

  • dtype: returns type of the queried data

  • fill_value: returns the value that fills empty cells instead of None

API methods

  • describe: returns an OrderedDict with description of all the subset’s dimensions

  • read: returns a numpy ndarray with all the data from the Subset bounds

    Note

    If the Subset or Array is empty, a numpy ndarray of fill_values will be returned

    Warning

    Mind your RAM!

  • read_xarray: returns an xarray.DataArray with data returned by read method and its description.

    Attention

    Scalar data cannot be converted to xarray.DataArray

  • update: writes new data to the storage;

    Note

    • Data cannot be None

    • Data shape should be equal to the Subset.shape

    • Data dtype should be equal to the Array.dtype

  • clear: removes or resets with fill_value all data from the storage within the subset bounds;

clear()

Clear data in Array by slice.

Return type

None

read()

Read data from Array slice.

Return type

Union[int, float, complex, int8, int16, int32, int64, longlong, uint64, uint8, uint16, uint32, ulonglong, float16, complex128, float32, clongdouble, float64, longdouble, complex64, ndarray]

update(data)

Update data in Array by slice.

  • Data cannot be None

  • Data shape should be equal to the Subset.shape

  • Data dtype should be equal to the Array.dtype

Parameters

data (Union[list, tuple, ndarray, int, float, complex, int8, int16, int32, int64, longlong, uint64, uint8, uint16, uint32, ulonglong, float16, complex128, float32, clongdouble, float64, longdouble, complex64]) – new data which shall match subset slicing

Return type

None

Parameters
  • slice_expression (Tuple[Union[slice, int], ...]) –

  • shape (Tuple[int, ...]) –

  • array (Array) –

  • adapter (BaseArrayAdapter) –

class deker.subset.VSubset(slice_expression, shape, array, array_adapter, varray_adapter, collection)

Bases: BaseSubset

VArray subset.

A subset of VArray data with set bounds, shape, dtype and fill_value.

It is final lazy object that can read, update and clear the data within the VArray. Once created, it does not contain any data and does not access the storage until user manually invokes one of the virtual subset API methods. If you need to get and manage all the data from array you shall create a virtual subset with VArray[:] or VArray[...].

Properties

  • shape: returns shape of the virtual subset

  • bounds: returns bounds that were applied to VArray

  • dtype: returns type of queried data

  • fill_value: returns value that fills empty cells instead of None

API methods

  • describe: returns an OrderedDict with description of all VSubset’s dimensions

  • read: returns a numpy ndarray with all the data from the VSubset bounds

    Note

    If the VSubset or VArray is empty, a numpy ndarray of fill_values will be returned

    Warning

    Mind your RAM!

  • read_xarray: returns an xarray.DataArray with data returned by read method and its description.

    Attention

    Scalar data cannot be converted to xarray.DataArray

  • update: writes new data to the storage;

    Note

    • Data cannot be None

    • Data shape shall be equal to the VSubset.shape

    • Data dtype shall be equal to the VArray.dtype

  • clear: removes or resets with fill_value all data from the storage within the virtual subset bounds;

param slice_expression

a slice, tuple of slices or numpy IndexExpression, created by VArray.__getitem__()

param shape

subset shape, calculated by VArray.__getitem__()

param array

an instance of VArray to which the virtual subset is bound

param array_adapter

ArrayAdapter instance

param collection

Collection instance, to which the virtual array is bound

clear()

Clear data in VArray by slice.

Return type

None

read()

Read data from VArray slice.

Return type

Union[int, float, complex, int8, int16, int32, int64, longlong, uint64, uint8, uint16, uint32, ulonglong, float16, complex128, float32, clongdouble, float64, longdouble, complex64, ndarray]

update(data)

Update data in VArray by slice.

  • Data cannot be None

  • Data shape should be equal to the VSubset.shape

  • Data dtype should be equal to the VArray.dtype

Parameters

data (Union[list, tuple, ndarray, int, float, complex, int8, int16, int32, int64, longlong, uint64, uint8, uint16, uint32, ulonglong, float16, complex128, float32, clongdouble, float64, longdouble, complex64]) – new data which shall match subset slicing

Return type

None

Parameters
  • slice_expression (Tuple[Union[slice, int], ...]) –

  • shape (Tuple[int, ...]) –

  • array (VArray) –

  • array_adapter (BaseArrayAdapter) –

  • varray_adapter (BaseVArrayAdapter) –

  • collection (Collection) –