Arrays
- class deker.arrays.Array(collection, adapter, id_=None, primary_attributes=None, custom_attributes=None)
Bases:
BaseArray
Array
is an abstract wrapper over final low-level arrays containing data.Array
is created by collection. It is alazy
object that does not interact with its data itself, but it possesses all information about the array. Interaction with data is performed by aSubset
object, which is produced byArray.__getitem__()
method.Properties
as_dict
: serializes main information about array into dictionary, prepared for JSONcollection
: returns the name ofCollection
to which theArray
is bounddimensions
: returns a tuple ofArray's
dimensions as objectsdtype
: returns type of theArray
dataid
: returnsArray's
idschema
: returnsArray's
low-level schemashape
: returnsArray's
shape as a tuple of dimension sizesnamed_shape
: returnsArray's
shape as a tuple of dimension names bound to their sizes
Attributes
According to the schema, arrays may have or may not have primary and/or custom attributes. Attributes are stored in low-level array’s metadata. Primary attributes are immutable and ordered, custom attributes are mutable and unordered.
primary_attributes
: Primary attributes are used forArrays
filtering. It is an OrderedDict. If collection schema contains attributes schema with some of them defined as primary, you obtain a possibility to quickly find allArrays
which can have a certain attribute or meet same conditions based on primary attributes values.E.g., if we refer to the example above and store the information about arrays’ data heights into primary attribute, we can create a filter
{"height": 10}
and find theArray
, which data was calculated at height equal to 10 meters.custom_attributes
: Custom attributes are used to keep some unique information about the array or about its data. E.g. you store some weather data, which is calculated at different heights. If it is not important for filtering you can keep the information about certain heights in arrays’ custom attribute, named “height”. In this case you won’t be able to search by this attribute, but still you’ll be able to use this information in your calculations, checking it array by array. Anytime you can set this attribute to None for any array as it is not a global setting. But you are not able to change dtype of custom attributes. In other words you cannot provide attribute’s dtype asint
and set there anyfloat
or string or whatever.
API Methods
read_meta
: reads the array’s metadata from storageupdate_custom_attributes
: updatesArray's
custom attributes valuesdelete
: deletesArray
from the storage with all its data and metadata__getitem__
: returns aSubset
instance bound to theArray
__repr__
: ordinary behaviour__str__
: ordinary behaviour
- param collection
instance of the
Collection
, to which theArray
is bound- param adapter
Array
adapter instance- param id_
array unique uuid string
- param primary_attributes
any primary attributes keyword mapping
- param custom_attributes
any custom attributes keyword mapping
- custom_attributes
- primary_attributes
- property schema: ArraySchema
Return
ArraySchema
of the Array’s Collection.
- Parameters
collection (Collection) –
adapter (BaseArrayAdapter) –
id_ (Optional[str]) –
primary_attributes (Optional[dict]) –
custom_attributes (Optional[dict]) –
- class deker.arrays.VArray(collection, adapter, array_adapter, id_=None, primary_attributes=None, custom_attributes=None)
Bases:
BaseArray
Virtual array or
VArray
is an abstract virtual array that consists of ordinaryArrays
.VArray
is an “array of arrays” or an “image of pixels”. If we considerVArray
as an image - it is split by virtual grid into tiles. In this case, each tile is an ordinaryArray
. Meanwhile, for userVArray
acts as an ordinaryArray
.VArray
is created byCollection
. It is alazy
object that does not interact with its data itself, but it possesses all information about the virtual array (and even a bit more). Interaction with data is performed by a VSubset object, which is produced byVArray.__getitem__()
method.Properties
as_dict
: serializes main information aboutVArray
into dictionary, prepared for JSONarrays_shape
: returns common shape of all theArrays
bound to theVArray
collection
: returns the name of collection to which theVArray
is bounddimensions
: returns a tuple ofVArray's
dimensions as objectsdtype
: returns type of theVArray
dataid
: returns virtualVArray's
idschema
: returnsVArray's
low-level schemashape
: returnsVArray's
shape as a tuple of dimension sizesnamed_shape
: returnsVArray's
shape as a tuple of dimension names bound to their sizesvgrid
: returns virtual grid (a tuple of integers) by whichVArray
is split intoArrays
Attributes
According to the schema,
VArrays
may have or may not have primary attributes and/or custom attributes. Attributes are stored inVArray's
metadata. Primary attributes are immutable and ordered, custom attributes are mutable and unordered.primary_attributes
: Primary attributes are used forVArrays
filtering. It is an OrderedDict. If collection schema contains attributes schema with some of them as primary, you obtain a possibility to quickly find all VArrays which can have a certain attribute or meet the same conditions based on primary attributes values.E.g., if we refer to the example above and store the information about arrays’ data heights into primary attribute, we can create a filter
{"height": 10}
and find theVArray
, which data was calculated at heights equal to 10 meters.custom_attributes
: Custom attributes are used to keep some unique information about the array or about its data. E.g., you store some weather data, which is calculated at different heights. If it is not important for filtering, you can keep the information about certain heights in arrays’ custom attribute, named “height”. In this case, you won’t be able to search by this attribute, but still you’ll be able to use this information in your calculations, checking it array by array. Anytime you can set this attribute to None for any array as it is not a global setting. But you are not able to change dtype of custom attributes. In other words, you cannot provide attribute’s dtype as int and set there any float or string or whatever.
API Methods
read_meta
: reads the array’s metadata from storageupdate_custom_attributes
: updatesVArray's
custom attributes valuesdelete
: deletesVArray
from the storage with all its data and metadata__getitem__
: returns aSubset
instance bound to theVArray
__repr__
: ordinary behaviour__str__
: ordinary behaviour
- param collection
instance of the
Collection
, to which theVArray
is bound- param adapter
VArray
adapter instance- param array_adapter
Array
adapter instance- param id_
VArray
unique uuid string- param primary_attributes
any primary attribute keyword mapping
- param custom_attributes
any custom attributes keyword mapping
- delete()
Delete
VArray
from storage.- Return type
None
- property arrays_shape: Tuple[int, ...]
Get the shape of inner
Arrays
.
- property as_dict: dict
Serialize self into dict.
- custom_attributes
- primary_attributes
- property schema: Optional[VArraySchema]
Return
VArraySchema
of the VArray’s Collection.
- property vgrid: Tuple[int, ...]
Get
VArray
virtual grid.
- Parameters
collection (Collection) –
adapter (BaseVArrayAdapter) –
array_adapter (BaseArrayAdapter) –
id_ (Optional[str]) –
primary_attributes (Optional[dict]) –
custom_attributes (Optional[dict]) –