コード例 #1
0
ファイル: table.py プロジェクト: renjiec/blaze-core
    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 = CArraySource.infer_datashape(obj)
        else:
            # The user overlayed their custom dshape on this
            # data, check if it makes sense
            CArraySource.check_datashape(obj, given_dshape=dshape)
            self._datashape = dshape

        # Values
        # ------
        # Mimic NumPy behavior in that we have a variety of
        # possible arguments to the first argument which result
        # in different behavior for the values.

        if isinstance(obj, CArraySource):
            self.data = obj
        else:
            self.data = CArraySource(obj, params)

        # children graph nodes
        self.children = []

        self.space = Space(self.data)

        # Layout
        # ------

        if layout:
            self._layout = layout
        elif not layout:
            self._layout = ChunkedL(self.data, cdimension=0)

        # Metadata
        # --------

        self._metadata = NDArray._metaheader + (metadata or [])

        # Parameters
        # ----------
        self.params = params
コード例 #2
0
def test_open_carray():
    with temp_dir() as temp:
        # Create an array on disk
        array_filename = os.path.join(temp, 'carray')
        p = params(storage=array_filename)
        ds = dshape('1,int32')
        a = CArraySource([2], dshape=ds, params=p)
        del a

        # Open array with open function
        uri = 'carray://' + array_filename
        c = toplevel.open(uri)
        assert c.datashape == ds

        # Test delayed mode
        c = toplevel.open(uri, eclass=eclass.delayed)
        assert c.datashape == ds
コード例 #3
0
ファイル: test_query.py プロジェクト: renjiec/blaze-core
def test_simple():
    a = CArraySource([1, 2, 3])
    layout = ContiguousL(a)
    indexer = (0, )

    retrieve(layout.change_coordinates, indexer)
コード例 #4
0
ファイル: table.py プロジェクト: renjiec/blaze-core
    def __init__(self,
                 obj,
                 dshape=None,
                 metadata=None,
                 layout=None,
                 params=None):

        # Datashape
        # ---------

        if isinstance(dshape, basestring):
            dshape = _dshape(dshape)

        if not dshape:
            # No explicit dshape provided. Infer it from the source.
            # if the source is another blaze array just use its shape,
            # otherwile let the provider infer its data_shape
            if isinstance(obj, Array):
                dshape = obj.datashape
            else:
                dshape = CArraySource.infer_datashape(obj)
        else:
            # The user overlayed their custom dshape on this
            # data, check if it makes sense
            CArraySource.check_datashape(obj, given_dshape=dshape)

        self._datashape = dshape

        # Values
        # ------
        # Mimic NumPy behavior in that we have a variety of
        # possible arguments to the first argument which result
        # in different behavior for the values.
        if isinstance(obj, ByteProvider):
            self.data = obj
        elif isinstance(obj, Array):
            self.data = CArraySource(obj.data, dshape=dshape, params=params)
        else:
            self.data = CArraySource(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 = NDArray._metaheader + (metadata or [])

        # Parameters
        # ----------
        self.params = params