NPY#

IO interface to numpy arrays.

class Source(array=None, shape=None, dtype=None, order=None, name=None)[source]#

Bases: Source

Numpy array source.

as_buffer()[source]#
as_real()[source]#
as_virtual()[source]#

Return virtual source without array data to pass in parallel processing.

Returns

sourceSource class

The source class without array data.

property array#

The underlying data array.

Returns

arrayarray

The underlying data array of this source.

property dtype#

The data type of the source.

Returns

dtypedtype

The data type of the source.

property element_strides#

The strides of the array elements.

Returns

stridestuple

Strides of the array elements.

Note

The strides of the elements module itemsize instead of bytes.

property name#

The name of this source.

Returns

namestr

Name of this source.

property offset#

The offset of the memory map in the file.

Returns

offsetint

Offset of the memeory map in the file.

property order#

The order of how the data is stored in the source.

Returns

orderstr

Returns ‘C’ for C contigous and ‘F’ for fortran contigous, None otherwise.

property shape#

The shape of the source.

Returns

shapetuple

The shape of the source.

create(shape=None, dtype=None, order=None, array=None, as_source=True, **kwargs)[source]#

Create a numpy array.

Arguments

shapetuple or None

The shape of the memory map to create.

dtypedtype

The data type of the memory map.

order‘C’, ‘F’, or None

The contiguous order of the memmap.

arrayarray, Source or None

Optional source with data to fill the numpy array with.

as_sourcebool

If True, return as Source class.

Returns

arraynp.array

The numpy array.

Note

By default numpy arrays are initialized as fortran contiguous if order is None.

is_numpy(source)[source]#
order(array)[source]#

Returns the contigous order of an array.

Arguments

array : ndarray

Returns

order : ‘C’, ‘F’, None

read(source, slicing=None, as_source=None, as_array=None, processes=None, **kwargs)[source]#
write(sink, data, slicing=None, **kwargs)[source]#