Arrays
- class deker.arrays.Array(collection, adapter, id_=None, primary_attributes=None, custom_attributes=None)
Bases:
BaseArrayArrayis an abstract wrapper over final low-level arrays containing data.Arrayis created by collection. It is alazyobject that does not interact with its data itself, but it possesses all information about the array. Interaction with data is performed by aSubsetobject, which is produced byArray.__getitem__()method.Properties
as_dict: serializes main information about array into dictionary, prepared for JSONcollection: returns the name ofCollectionto which theArrayis bounddimensions: returns a tuple ofArray'sdimensions as objectsdtype: returns type of theArraydataid: returnsArray'sidschema: returnsArray'slow-level schemashape: returnsArray'sshape as a tuple of dimension sizesnamed_shape: returnsArray'sshape 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 forArraysfiltering. It is an OrderedDict. If collection schema contains attributes schema with some of them defined as primary, you obtain a possibility to quickly find allArrayswhich 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 asintand set there anyfloator string or whatever.
API Methods
read_meta: reads the array’s metadata from storageupdate_custom_attributes: updatesArray'scustom attributes valuesdelete: deletesArrayfrom the storage with all its data and metadata__getitem__: returns aSubsetinstance bound to theArray__repr__: ordinary behaviour__str__: ordinary behaviour
- param collection
instance of the
Collection, to which theArrayis bound- param adapter
Arrayadapter 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
ArraySchemaof 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:
BaseArrayVirtual array or
VArrayis an abstract virtual array that consists of ordinaryArrays.VArrayis an “array of arrays” or an “image of pixels”. If we considerVArrayas an image - it is split by virtual grid into tiles. In this case, each tile is an ordinaryArray. Meanwhile, for userVArrayacts as an ordinaryArray.VArrayis created byCollection. It is alazyobject 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 aboutVArrayinto dictionary, prepared for JSONarrays_shape: returns common shape of all theArraysbound to theVArraycollection: returns the name of collection to which theVArrayis bounddimensions: returns a tuple ofVArray'sdimensions as objectsdtype: returns type of theVArraydataid: returns virtualVArray'sidschema: returnsVArray'slow-level schemashape: returnsVArray'sshape as a tuple of dimension sizesnamed_shape: returnsVArray'sshape as a tuple of dimension names bound to their sizesvgrid: returns virtual grid (a tuple of integers) by whichVArrayis split intoArrays
Attributes
According to the schema,
VArraysmay have or may not have primary attributes and/or custom attributes. Attributes are stored inVArray'smetadata. Primary attributes are immutable and ordered, custom attributes are mutable and unordered.primary_attributes: Primary attributes are used forVArraysfiltering. 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'scustom attributes valuesdelete: deletesVArrayfrom the storage with all its data and metadata__getitem__: returns aSubsetinstance bound to theVArray__repr__: ordinary behaviour__str__: ordinary behaviour
- param collection
instance of the
Collection, to which theVArrayis bound- param adapter
VArrayadapter instance- param array_adapter
Arrayadapter instance- param id_
VArrayunique uuid string- param primary_attributes
any primary attribute keyword mapping
- param custom_attributes
any custom attributes keyword mapping
- delete()
Delete
VArrayfrom 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
VArraySchemaof the VArray’s Collection.
- property vgrid: Tuple[int, ...]
Get
VArrayvirtual grid.
- Parameters
collection (Collection) –
adapter (BaseVArrayAdapter) –
array_adapter (BaseArrayAdapter) –
id_ (Optional[str]) –
primary_attributes (Optional[dict]) –
custom_attributes (Optional[dict]) –