Python API

Classes and Functions

bob.blitz.array A pythonic representation of an N-dimensional blitz::Array<T,N>
bob.blitz.as_blitz((x) -> array) Converts any compatible python object into a shallow
bob.blitz.get_config() Returns a string containing the configuration information.
bob.blitz.extension.Extension(*args, **kwargs) Extension building with pkg-config packages and blitz.array.
bob.blitz.extension.Library(*args, **kwargs) Pure C++ library building with blitz array.

Detailed Information

bob.blitz.get_config()[source]

Returns a string containing the configuration information.

class bob.blitz.array

Bases: object

A pythonic representation of an N-dimensional blitz::Array<T,N>

Objects of this class hold a pointer to C++ blitz::Array<T,N>. The C++ data type T is mapped to a numpy.dtype object, while the extents and number of dimensions N are mapped to a shape, similar to what is done for numpy.ndarray objects.

Objects of this class can be wrapped in numpy.ndarray quite efficiently, so that flexible numpy-like operations are possible on its contents. You can also deploy objects of this class wherever numpy.ndarray‘s may be input.

Constructor Documentation:

bob.blitz.array (shape, dtype)

Constructs a new bob.blitz.array

The implementation current supports a maximum of 4 dimensions. Building an array with more dimensions will raise a TypeError. There are no explicit limits for the size in each dimension, except for the machine’s maximum address size.

The following numpy data types are supported by this library:

  • numpy.bool_
  • numpy.int8
  • numpy.int16
  • numpy.int32
  • numpy.int64
  • numpy.uint8
  • numpy.uint16
  • numpy.uint32
  • numpy.uint64
  • numpy.float32
  • numpy.float64
  • numpy.float128 (if this architecture suppports it)
  • numpy.complex64
  • numpy.complex128
  • numpy.complex256 (if this architecture suppports it)

Parameters:

shape : iterable

An iterable, indicating the shape of the array to be constructed

dtype : numpy.dtype or dtype convertible object

The data type of the object to be created

Class Members:

as_ndarray([dtype]) → array

numpy.ndarray accessor

This function wraps this array as a numpy.ndarray. If dtype is given and the current data type is not the same, then forces the creation of a copy conforming to the require data type, if possible.

Parameters:

dtype : numpy.dtype or dtype convertible object

[optional] The data type of the array to create

Returns:

array : numpy.ndarray

This array converted to a :py:class`numpy.ndarray`
base

object <– If the memory of this array is borrowed from some other object, this is it

cast(dtype) → array

Casts an existing array into a (possibly) different data type, without changing its shape

If the data type matches the current array’s data type, then a new view to the same array is returned. Otherwise, a new array is allocated and returned.

Parameters:

dtype : numpy.dtype or dtype convertible object

The data type to convert this array into

Returns:

array : bob.blitz.array

This array converted to the given data type
dtype

numpy.dtype <– The data type for every element in this array

shape

tuple <– A tuple indicating the shape of this array (in elements)

stride

tuple <– A tuple indicating the strides of this array (in bytes)

writeable

bool <– A flag, indicating if this array is writeable

bob.blitz.as_blitz(x) → array

Converts any compatible python object into a shallow bob.blitz.array

This function works by first converting the input object x into a numpy.ndarray and then shallow wrapping that ndarray into a new bob.blitz.array. You can access the converted ndarray using the returned value’s bob.blitz.array.base() attribute. If the ndarray cannot be shallow-wrapped, a ValueError is raised.

In the case the input object x is already a behaved (C-style, memory-aligned, contiguous) numpy.ndarray, then this function only shallow wrap’s it into a bob.blitz.array skin.

Parameters:

x : object

Any object convertible into a numpy.ndarray

Returns:

array : bob.blitz.array

The converted array

Extension building for using this package

class bob.blitz.extension.Extension(*args, **kwargs)[source]

Bases: bob.extension.Extension

Extension building with pkg-config packages and blitz.array.

See the documentation for distutils.extension.Extension for more details on input parameters.

class bob.blitz.extension.Library(*args, **kwargs)[source]

Bases: bob.extension.Library

Pure C++ library building with blitz array.

See the documentation for bob.extension.Extension for more details on input parameters.

compile(build_directory, compiler=None, stdout=None)[source]

This function will automatically create a CMakeLists.txt file in the package_directory including the required information. Afterwards, the library is built using CMake in the given build_directory. The build type is automatically taken from the debug option in the buildout.cfg. To change the compiler, use the compiler parameter.