class Table(Indexable): eclass = MANIFEST _metaheader = [ md.manifest, md.tablelike, ] def __init__(self, obj, dshape=None, metadata=None, layout=None, params=None): # Datashape # --------- if isinstance(dshape, basestring): dshape = _dshape(dshape) if not dshape: # The user just passed in a raw data source, try # and infer how it should be layed out or fail # back on dynamic types. self._datashape = dshape = CTableSource.infer_datashape(obj) else: # The user overlayed their custom dshape on this # data, check if it makes sense CTableSource.check_datashape(obj, given_dshape=dshape) self._datashape = dshape # Source # ------ if isinstance(obj, ByteProvider): self.data = obj else: self.data = CTableSource(obj, dshape=dshape, params=params) # children graph nodes self.children = [] self.space = Space(self.data) # Layout # ------ if layout: self._layout = layout elif not layout: self._layout = self.data.default_layout() # Metadata # -------- self._metadata = NDTable._metaheader + (metadata or []) # Parameters # ---------- self.params = params
class NDTable(Indexable, ArrayNode): """ The base NDTable. Indexable contains the indexing logic for how to access elements, while ArrayNode contains the graph related logic for building expression trees with this table as an element. """ eclass = DELAYED _metaheader = [ md.deferred, md.tablelike, ] #------------------------------------------------------------------------ # Properties #------------------------------------------------------------------------ def __init__(self, obj, dshape=None, metadata=None, layout=None, params=None): # Datashape # --------- if isinstance(dshape, basestring): dshape = _dshape(dshape) if not dshape: # The user just passed in a raw data source, try # and infer how it should be layed out or fail # back on dynamic types. self._datashape = dshape = CTableSource.infer_datashape(obj) else: # The user overlayed their custom dshape on this # data, check if it makes sense CTableSource.check_datashape(obj, given_dshape=dshape) self._datashape = dshape # Source # ------ if isinstance(obj, ByteProvider): self.data = obj else: self.data = CTableSource(obj, dshape=dshape, params=params) # children graph nodes self.children = [] self.space = Space(self.data) # Layout # ------ if layout: self._layout = layout elif not layout: self._layout = self.data.default_layout() # Metadata # -------- self._metadata = NDTable._metaheader + (metadata or []) # Parameters # ---------- self.params = params @property def datashape(self): """ Type deconstructor """ return self._datashape @property def size(self): """ Size of the NDTable. """ # TODO: need to generalize, not every Array will look # like Numpy return sum(i.val for i in self._datashape.parameters[:-1]) @property def backends(self): """ The storage backends that make up the space behind the Array. """ return iter(self.space) def __repr__(self): return generic_repr('NDTable', self, deferred=True)
class Table(Indexable): eclass = MANIFEST _metaheader = [ md.manifest, md.tablelike, ] def __init__(self, obj, dshape=None, metadata=None, layout=None, params=None): # Datashape # --------- if isinstance(dshape, basestring): dshape = _dshape(dshape) if not dshape: # The user just passed in a raw data source, try # and infer how it should be layed out or fail # back on dynamic types. self._datashape = dshape = CTableSource.infer_datashape(obj) else: # The user overlayed their custom dshape on this # data, check if it makes sense CTableSource.check_datashape(obj, given_dshape=dshape) self._datashape = dshape # Source # ------ if isinstance(obj, ByteProvider): self.data = obj else: self.data = CTableSource(obj, dshape=dshape, params=params) # children graph nodes self.children = [] self.space = Space(self.data) # Layout # ------ if layout: self._layout = layout elif not layout: self._layout = self.data.default_layout() # Metadata # -------- self._metadata = NDTable._metaheader + (metadata or []) # Parameters # ---------- self.params = params
class NDTable(Indexable, ArrayNode): """ The base NDTable. Indexable contains the indexing logic for how to access elements, while ArrayNode contains the graph related logic for building expression trees with this table as an element. """ eclass = DELAYED _metaheader = [ md.deferred, md.tablelike, ] #------------------------------------------------------------------------ # Properties #------------------------------------------------------------------------ def __init__(self, obj, dshape=None, metadata=None, layout=None, params=None): # Datashape # --------- if isinstance(dshape, basestring): dshape = _dshape(dshape) if not dshape: # The user just passed in a raw data source, try # and infer how it should be layed out or fail # back on dynamic types. self._datashape = dshape = CTableSource.infer_datashape(obj) else: # The user overlayed their custom dshape on this # data, check if it makes sense CTableSource.check_datashape(obj, given_dshape=dshape) self._datashape = dshape # Source # ------ if isinstance(obj, ByteProvider): self.data = obj else: self.data = CTableSource(obj, dshape=dshape, params=params) # children graph nodes self.children = [] self.space = Space(self.data) # Layout # ------ if layout: self._layout = layout elif not layout: self._layout = self.data.default_layout() # Metadata # -------- self._metadata = NDTable._metaheader + (metadata or []) # Parameters # ---------- self.params = params @property def datashape(self): """ Type deconstructor """ return self._datashape @property def size(self): """ Size of the NDTable. """ # TODO: need to generalize, not every Array will look # like Numpy return sum(i.val for i in self._datashape.parameters[:-1]) @property def backends(self): """ The storage backends that make up the space behind the Array. """ return iter(self.space) def __repr__(self): return generic_repr('NDTable', self, deferred=True)