Example #1
0
 def infer_datashape(source):
     if isinstance(source, np.ndarray):
         return from_numpy(source.shape, source.dtype)
     elif isinstance(source, list):
         # TODO: um yeah, we'd don't actually want to do this
         cast = np.array(source)
         return from_numpy(cast.shape, cast.dtype)
     else:
         return dynamic
Example #2
0
 def infer_datashape(source):
     if isinstance(source, np.ndarray):
         return from_numpy(source.shape, source.dtype)
     elif isinstance(source, list):
         # TODO: um yeah, we'd don't actually want to do this
         cast = np.array(source)
         return from_numpy(cast.shape, cast.dtype)
     else:
         return dynamic
Example #3
0
 def infer_datashape(source):
     """
     The user has only provided us with a Python object ( could be
     a buffer interface, a string, a list, list of lists, etc) try
     our best to infer what the datashape should be in the context of
     what it would mean as a CArray.
     """
     if isinstance(source, np.ndarray):
         return from_numpy(source.shape, source.dtype)
     elif isinstance(source, list):
         # TODO: um yeah, we'd don't actually want to do this
         cast = np.array(source)
         return from_numpy(cast.shape, cast.dtype)
     else:
         return dynamic
Example #4
0
 def infer_datashape(source):
     """
     The user has only provided us with a Python object (
     could be a buffer interface, a string, a list, list of
     lists, etc) try our best to infer what the datashape
     should be in the context of this datasource.
     """
     if isinstance(source, np.ndarray):
         return from_numpy(source.shape, source.dtype)
     elif isinstance(source, list):
         # TODO: um yeah, we'd don't actually want to do this
         cast = np.array(source)
         return from_numpy(cast.shape, cast.dtype)
     else:
         return dynamic
Example #5
0
 def empty(self, dshape):
     """ Create a CArraySource from a datashape specification,
     downcasts into Numpy dtype and shape tuples if possible
     otherwise raises an exception.
     """
     shape, dtype = from_numpy(dshape)
     return CArraySource(carray([], dtype))
Example #6
0
 def empty(self, dshape):
     """ Create a CArraySource from a datashape specification,
     downcasts into Numpy dtype and shape tuples if possible
     otherwise raises an exception.
     """
     shape, dtype = from_numpy(dshape)
     return CArraySource(carray([], dtype))
Example #7
0
    def __init__(self, data=None, dshape=None, params=None):
        # need at least one of the three
        assert (data is not None) or (dshape is not None) or \
               (params.get('storage'))

        # Extract the relevant carray parameters from the more
        # general Blaze params object.
        if params:
            cparams, rootdir, format_flavor = to_cparams(params)
        else:
            rootdir,cparams = None, None

        if dshape:
            dtype = to_numpy(dshape)
            self.ca = carray.carray(data, dtype, rootdir=rootdir)
            self.dshape = dshape
        else:
            self.ca = carray.carray(data, rootdir=rootdir, cparams=cparams)
            self.dshape = from_numpy(self.ca.shape, self.ca.dtype)
Example #8
0
 def empty(self, dshape):
     shape, dtype = from_numpy(dshape)
     return CTableSource(carray([[]], dtype))
Example #9
0
def test_from_numpy():
    from_numpy((), np.int32) == blaze.int32
    from_numpy((), np.int_) == blaze.int_

    from_numpy((1,), np.int32) == blaze.dshape('1, int32')
    from_numpy((1,2), np.int32) == blaze.dshape('1, 2, int32')
Example #10
0
 def empty(self, datashape):
     shape, dtype = from_numpy(datashape)
     return ArraySource(np.ndarray(shape, dtype))
Example #11
0
 def empty(self, datashape):
     shape, dtype = from_numpy(datashape)
     return ArraySource(np.ndarray(shape, dtype))
Example #12
0
    def test_from_numpy(self):
        self.assertEqual(from_numpy((), np.int32), blaze.int32)
        self.assertEqual(from_numpy((), np.int_), blaze.int_)

        self.assertEqual(from_numpy((1,), np.int32), blaze.dshape('1, int32'))
        self.assertEqual(from_numpy((1,2), np.int32), blaze.dshape('1, 2, int32'))
Example #13
0
def test_from_numpy():
    from_numpy((), np.int32) == blaze.int32
    from_numpy((), np.int_) == blaze.int_

    from_numpy((1, ), np.int32) == blaze.dshape('1, int32')
    from_numpy((1, 2), np.int32) == blaze.dshape('1, 2, int32')
Example #14
0
 def empty(self, dshape):
     shape, dtype = from_numpy(dshape)
     return CTableSource(carray([[]], dtype))
Example #15
0
    def test_from_numpy(self):
        self.assertEqual(from_numpy((), np.int32), blaze.int32)
        self.assertEqual(from_numpy((), np.int_), blaze.int_)

        self.assertEqual(from_numpy((1,), np.int32), blaze.dshape('1, int32'))
        self.assertEqual(from_numpy((1,2), np.int32), blaze.dshape('1, 2, int32'))