exa.core.container module¶
Container¶
The Container
class is the primary object for
data processing, analysis, and visualization. In brief, containers are composed
of data objects whose contents are used for 2D and 3D visualization. Containers
also provide some content management and data relationship features.
See also
For a description of data objects see numerical
.
-
class
exa.core.container.
Container
(name=None, description=None, meta=None, uuid=None, **kwargs)[source]¶ Bases:
object
Container class responsible for all features related to data management.
-
property
log
¶
-
copy
(name=None, description=None, meta=None)[source]¶ Create a copy of the current object (may alter the container’s name, description, and update the metadata if needed).
-
concat
(*args, **kwargs)[source]¶ Concatenate any number of container objects with the current object into a single container object.
See also
For argument description, see
concat()
.
-
slice_naive
(key)[source]¶ Naively slice each data object in the container by the object’s index.
- Parameters
key – Int, slice, or list by which to extra “sub”-container
- Returns
sub – Sub container of the same format with a view of the data
Warning
To ensure that a new container is created, use the copy method.
mycontainer[slice].copy()
-
slice_cardinal
(key)[source]¶ Slice the container according to its (primary) cardinal axis.
The “cardinal” axis can have any name so long as the name matches a data object attached to the container. The index name for this object should also match the value of the cardinal axis.
The algorithm builds a network graph representing the data relationships (including information about the type of relationship) and then traverses the edge tree (starting from the cardinal table). Each subsequent child object in the tree is sliced based on its relationship with its parent.
Note
Breadth first traversal is performed.
Warning
This function does not make a copy (if possible): to ensure a new object is created (a copy) use
copy()
after slicing.myslice = mycontainer[::2].copy()
-
cardinal_groupby
()[source]¶ Create an instance of this class for every step in the cardinal dimension.
-
info
()[source]¶ Display information about the container’s data objects (note that info on metadata and visualization objects is also provided).
Note
Sizes are reported in bytes.
-
memory_usage
(string=False)[source]¶ Get the memory usage estimate of the container.
- Parameters
string (bool) – Human readable string (default false)
See also
-
network
(figsize=(14, 9), fig=True)[source]¶ Display information about the container’s object relationships.
Nodes correspond to data objects. The size of the node corresponds to the size of the table in memory. The color of the node corresponds to its fundamental data type. Nodes are labeled by their container name; class information is listed below. The color of the connections correspond to the type of relationship; either an index of one table corresponds to a column in another table or the two tables share an index.
-
save
(path=None, complevel=1, complib='zlib')[source]¶ Save the container as an HDF5 archive.
- Parameters
path (str) – Path where to save the container
- Returns
savepath (str) – Path where the container was saved
-
to_hdf
(*args, **kwargs)[source]¶ Alias of
Container()
.
-
classmethod
load
(pkid_or_path=None)[source]¶ Load a container object from a persistent location or file path.
- Parameters
pkid_or_path – Integer pkid corresponding to the container table or file path
- Returns
container – The saved container object
-
classmethod
from_hdf
(*args, **kwargs)[source]¶ Alias for
Container()
.
-
property
-
class
exa.core.container.
TypedMeta
(name, bases, clsdict)[source]¶ Bases:
type
This metaclass creates statically typed class attributes using the property framework.
class TestMeta(TypedMeta): attr1 = (int, float) attr2 = DataFrame class TestClass(metaclass=TestMeta): def __init__(self, attr1, attr2): self.attr1 = attr1 self.attr2 = attr2
The above code dynamically creates code that looks like the following:
class TestClass: @property def attr1(self): return self._attr1 @attr1.setter def attr1(self, obj): if not isinstance(obj, (int, float)): raise TypeError('attr1 must be int') self._attr1 = obj @attr1.deleter def attr1(self): del self._attr1 @property def attr2(self): return self._attr2 @attr2.setter def attr2(self, obj): if not isinstance(obj, DataFrame): raise TypeError('attr2 must be DataFrame') self._attr2 = obj @attr2.deleter def attr2(self): del self._attr2 def __init__(self, attr1, attr2): self.attr1 = attr1 self.attr2 = attr2
-
static
create_property
(name, ptype)[source]¶ Creates a custom property with a getter that performs computing functionality (if available) and raise a type error if setting with the wrong type.
Note
By default, the setter attempts to convert the object to the correct type; a type error is raised if this fails.
-
static