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:
objectA 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 typeTis mapped to anumpy.dtypeobject, while the extents and number of dimensionsNare mapped to a shape, similar to what is done fornumpy.ndarrayobjects.Objects of this class can be wrapped in
numpy.ndarrayquite 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.arrayThe 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.int8numpy.int16numpy.int32numpy.int64numpy.uint8numpy.uint16numpy.uint32numpy.uint64numpy.float32numpy.float64numpy.float128(if this architecture suppports it)numpy.complex64numpy.complex128numpy.complex256(if this architecture suppports it)
Parameters:
shape: iterableAn iterable, indicating the shape of the array to be constructeddtype:numpy.dtypeordtypeconvertible objectThe data type of the object to be createdClass Members:
-
__array__([dtype]) → array¶ numpy.ndarrayaccessorThis function wraps this array as a
numpy.ndarray. Ifdtypeis 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.dtypeor dtype convertible object[optional] The data type of the array to createReturns:
array:numpy.ndarrayThis array converted to a :py:class`numpy.ndarray`
-
as_ndarray([dtype]) → array¶ numpy.ndarrayaccessorThis function wraps this array as a
numpy.ndarray. Ifdtypeis 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.dtypeor dtype convertible object[optional] The data type of the array to createReturns:
array:numpy.ndarrayThis 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.dtypeor dtype convertible objectThe data type to convert this array intoReturns:
array:bob.blitz.arrayThis 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.arrayThis function works by first converting the input object
xinto anumpy.ndarrayand then shallow wrapping thatndarrayinto a newbob.blitz.array. You can access the convertedndarrayusing the returned value’sbob.blitz.array.base()attribute. If thendarraycannot be shallow-wrapped, aValueErroris raised.In the case the input object
xis already a behaved (C-style, memory-aligned, contiguous)numpy.ndarray, then this function only shallow wrap’s it into abob.blitz.arrayskin.Parameters:
x: objectAny object convertible into anumpy.ndarrayReturns:
array:bob.blitz.arrayThe converted array
Extension building for using this package
-
class
bob.blitz.extension.Extension(*args, **kwargs)[source]¶ Bases:
bob.extension.ExtensionExtension building with pkg-config packages and blitz.array.
See the documentation for
distutils.extension.Extensionfor more details on input parameters.
-
class
bob.blitz.extension.Library(*args, **kwargs)[source]¶ Bases:
bob.extension.LibraryPure C++ library building with blitz array.
See the documentation for
bob.extension.Extensionfor more details on input parameters.