예제 #1
0
 def test_access_ones(self):
     a = nd.ones(ndt.int32)
     self.assertEqual(a.access_flags, 'readwrite')
     a = nd.ones(ndt.int32, access='rw')
     self.assertEqual(a.access_flags, 'readwrite')
     a = nd.ones(ndt.int32, access='r')
     self.assertEqual(a.access_flags, 'immutable')
예제 #2
0
 def test_access_ones(self):
     a = nd.ones(ndt.int32)
     self.assertEqual(a.access_flags, 'readwrite')
     a = nd.ones(ndt.int32, access='rw')
     self.assertEqual(a.access_flags, 'readwrite')
     a = nd.ones(ndt.int32, access='r')
     self.assertEqual(a.access_flags, 'immutable')
def ones(dshape, ddesc=None):
    """Create an array and fill it with ones.

    Parameters
    ----------
    dshape : datashape
        The datashape for the resulting array.

    ddesc : data descriptor instance
        This comes with the necessary info for storing the data.  If
        None, a DyND_DDesc will be used.

    Returns
    -------
    out: a concrete blaze array.

    """
    dshape = _normalize_dshape(dshape)

    if ddesc is None:
        ddesc = DyND_DDesc(nd.ones(str(dshape), access='rw'))
        return Array(ddesc)
    if isinstance(ddesc, BLZ_DDesc):
        shape, dt = to_numpy(dshape)
        ddesc.blzarr = blz.ones(
            shape, dt, rootdir=ddesc.path, mode=ddesc.mode, **ddesc.kwargs)
    elif isinstance(ddesc, HDF5_DDesc):
        obj = nd.as_numpy(nd.empty(str(dshape)))
        with tb.open_file(ddesc.path, mode=ddesc.mode) as f:
            where, name = split_path(ddesc.datapath)
            f.create_earray(where, name, filters=ddesc.filters, obj=obj)
        ddesc.mode = 'a'  # change into 'a'ppend mode for further operations
    return Array(ddesc)
def ones(dshape, ddesc=None):
    """Create an array and fill it with ones.

    Parameters
    ----------
    dshape : datashape
        The datashape for the resulting array.

    ddesc : data descriptor instance
        This comes with the necessary info for storing the data.  If
        None, a DyND_DDesc will be used.

    Returns
    -------
    out: a concrete blaze array.

    """
    dshape = _normalize_dshape(dshape)

    if ddesc is None:
        ddesc = DyND_DDesc(nd.ones(str(dshape), access='rw'))
        return Array(ddesc)
    if isinstance(ddesc, BLZ_DDesc):
        shape, dt = to_numpy(dshape)
        ddesc.blzarr = blz.ones(shape,
                                dt,
                                rootdir=ddesc.path,
                                mode=ddesc.mode,
                                **ddesc.kwargs)
    elif isinstance(ddesc, HDF5_DDesc):
        obj = nd.as_numpy(nd.empty(str(dshape)))
        with tb.open_file(ddesc.path, mode=ddesc.mode) as f:
            where, name = split_path(ddesc.datapath)
            f.create_earray(where, name, filters=ddesc.filters, obj=obj)
        ddesc.mode = 'a'  # change into 'a'ppend mode for further operations
    return Array(ddesc)
예제 #5
0
 def test_access_ones(self):
     a = nd.ones(ndt.int32)
     self.assertEqual(a.access_flags, 'readwrite')
 def test_access_ones(self):
     a = nd.ones(ndt.int32)
     self.assertEqual(a.access_flags, "immutable")
     a = nd.ones(ndt.int32, access="rw")
     self.assertEqual(a.access_flags, "readwrite")
예제 #7
0
 def test_access_ones(self):
     a = nd.ones(ndt.int32)
     self.assertEqual(a.access_flags, 'readwrite')