Arrays

The escape.core.array module contains wrappers for internal ESCAPE array_t class. These wrappers, double_array_obj and mask_array_obj allow user to link array_t instances with numpy.ndarray arrays in python code using shared pointers or deep copy of source array.

Both wrapper classes support converting of ESCAPE arrays to numpy arrays using numpy.asarray method. To convert numpy arrays to ESCAPE arrays use double_array and mask_array helper functions or static convert method as following:

>>> a = np.arange(0, 10, 0.1)
>>> w = esc.double_array_obj.convert(a)    
escape.core.array.double_array(src, bool copy=False)

Returns an instance of double_array_obj - array of double values, which holds either a copy of source or wraps its data pointer.

Parameters
src: list or ndarray

Array to be wrapped.

copy: bool

If True the source data will be always copied. If False and source doesn’t own its data, i.e. source is an array view, source array will be not copied. If source doesn’t own its data and copying is not required, the returned object will always hold a source copy.

Returns

instance of double_array_obj

escape.core.array.mask_array(src, bool copy=False)

Returns an instance of bool_array_obj - array of boolean values, which holds either a copy of source or wraps its data pointer.

Parameters
src: list or ndarray

Array to be wrapped.

copy: bool

If True the source data will be always copied. If False and source doesn’t own its data, i.e. source is an array view, source array will be not copied. If source doesn’t own its data and copying is not required, the returned object will always hold a source copy.

Returns

instance of bool_array_obj

class escape.core.array.double_array_obj
static convert(input, bool copy=False)

Static method to create a wrapper of a numpy array or python list with double elements.

Parameters
input: object - ndarray or list

Array to be wrapped

copy: bool

If True the source data will be always copied. If False and source doesn’t own its data, i.e. source is an array view, source array will be not copied. If source doesn’t own its data and copying is not required, the returned object will always hold a source copy.

Returns

instance of double_array_obj

shape

Returns shape of ESCAPE array as a tuple (nrows, ncols)

class escape.core.array.mask_array_obj
static convert(input, bool copy=False)

Static method to create a wrapper of a numpy array or python list with boolean elements.

Parameters
input: object - ndarray or list

Array to be wrapped

copy: bool

If True the source data will be always copied. If False and source doesn’t own its data, i.e. source is an array view, source array will be not copied. If source doesn’t own its data and copying is not required, the returned object will always hold a source copy.

Returns

instance of bool_array_obj

shape

Returns shape of ESCAPE array as a tuple (nrows, ncols)