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¶
-
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 typeT
is mapped to anumpy.dtype
object, while the extents and number of dimensionsN
are mapped to a shape, similar to what is done fornumpy.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 wherevernumpy.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
: iterableAn iterable, indicating the shape of the array to be constructeddtype
:numpy.dtype
ordtype
convertible objectThe data type of the object to be createdClass Members:
-
__array__
([dtype]) → array¶ numpy.ndarray
accessorThis function wraps this array as a
numpy.ndarray
. Ifdtype
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 createReturns:
array
:numpy.ndarray
This array converted to a :py:class`numpy.ndarray`
-
as_ndarray
([dtype]) → array¶ numpy.ndarray
accessorThis function wraps this array as a
numpy.ndarray
. Ifdtype
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 createReturns:
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 objectThe data type to convert this array intoReturns:
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 anumpy.ndarray
and then shallow wrapping thatndarray
into a newbob.blitz.array
. You can access the convertedndarray
using the returned value’sbob.blitz.array.base()
attribute. If thendarray
cannot be shallow-wrapped, aValueError
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 abob.blitz.array
skin.Parameters:
x
: objectAny object convertible into anumpy.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.