ancb package

Module contents

class ancb.NumpyCircularBuffer(data, bounds: Tuple[int, int] = (0, 0))[source]

Bases: numpy.ndarray

Implements a circular (ring) buffer using a numpy array. This implmentation uses an internal size count and capacity count so that the data region is fully utilized.

all(*args, **kwargs)[source]

Returns True if all elements evaluate to True.

Returns

True if all elements evaluate to True, False otherwise.

See also

ndarray.all()

any(*args, **kwargs)[source]

Returns True if any elements evaluate to True.

Returns

True if any elements evaluate to True, False otherwise.

See also

ndarray.any()

append(value)[source]

Append a value to the buffer on the right. If the buffer is full, the buffer will advance forward (wrapping around at the ends) and overwrite an element.

Time complexity: O(1)

argmax(*args, **kwargs)[source]
Raises

NotImplementedError – This function will be implemented in the future

argmin(*args, **kwargs)[source]
Raises

NotImplementedError – This function will be implemented in the future

byteswap(inplace=False)[source]

Swap the bytes of the array elements over the valid range of the buffer

Toggle between low-endian and big-endian data representation by returning a byteswapped array, optionally swapped in-place. Arrays of byte-strings are not swapped. The real and imaginary parts of a complex number are swapped individually.

See also

ndarray.byteswap()

choose(choices, out=None, mode='raise')[source]
Raises

NotImplementedError – This function is being considered for implementation in the future

clip(min=None, max=None, out=None, **kwargs)[source]

Return an array whose values are limited to [min, max] over the valid range of the buffer. One of max or min must be given.

See also

numpy.clip()

conj()[source]

Complex-conjugate all elements over the valid range of the buffer.

See also

numpy.conjugate()

conjugate()[source]

Complex-conjugate all elements over the valid range of the buffer.

See also

numpy.conjugate()

copy(order='C', defrag=False)[source]

Return a copy of the array over the valid range of the buffer.

See also

ndarray.copy()

cumprod(axis=None, dtype=None, out=None)NoReturn[source]
Raises

NotImplementedError – This function will be implemented in the future

cumsum(axis=None, dtype=None, out=None)NoReturn[source]
Raises

NotImplementedError – This function will be implemented in the future

diagonal(offset=0, axis1=0, axis2=1)NoReturn[source]
Raises

NotImplementedError – This function will be implemented in the future

dot(b, out=None)NoReturn[source]
Raises

NotImplementedError – This function will be implemented in the future

dump(b, out=None)NoReturn[source]
Raises

NotImplementedError – This function will be implemented in the future

dumps(b, out=None)NoReturn[source]
Raises

NotImplementedError – This function will be implemented in the future

property empty

Property that returns True if the buffer is empty, False otherwise.

Time complexity: O(1)

Returns

True if buffer is empty, False otherwise.

Return type

bool

fill(value)[source]

Fill the valid region of the buffer with a scalar value.

Parameters

value ((scalar)) – All elements of a will be assigned this value.

See also

ndarray.fill()

flatten(order='C', defrag=False)[source]

Return a copy of the array collapsed into one dimension.

See also

ndarray.flatten()

property fragmented

Property that returns True if the buffer is fragmented (the beginning index is greater than the end index), False otherwise.

Time complexity: O(1)

Returns

True if buffer is fragmented, False otherwise.

Return type

bool

property full

Property that returns True if the buffer is full, False otherwise.

Time complexity: O(1)

Returns

True if buffer is full, False otherwise.

Return type

bool

get_partions()Union[numpy.ndarray, Tuple[numpy.ndarray, numpy.ndarray]][source]

Gets a slice of the buffer between the beginning and end indices. If the buffer is fragmented, a tuple of two slices of the two fragments sequentially. Concatenating the slices in the order they are in the tuple will return a list of elements in the correct order.

Time complexity: O(1)

Returns

slice or tuple of slices of the array elements in order

Return type

Union[ndarray, Tuple[ndarray, ndarray]]

getfield(offset=0)NoReturn[source]
Raises

NotImplementedError – This function is being considered for implementation in the future

item(*args)NoReturn[source]
Raises

NotImplementedError – This function is being considered for implementation in the future

itemset(*args)NoReturn[source]
Raises

NotImplementedError – This function will be implemented in the future

max(axis=None, out=None, keepdims=False, initial=None, where=True)NoReturn[source]
Raises

NotImplementedError – This function will be implemented in the future

min(axis=None, out=None, keepdims=False, initial=None, where=True)NoReturn[source]
Raises

NotImplementedError – This function will be implemented in the future

newbyteorder(new_order='S')NoReturn[source]
Raises

NotImplementedError – This function will be implemented in the future

nonzero()NoReturn[source]
Raises

NotImplementedError – This function has no plan for implementation as of this version.

peek()[source]

Gets the element at the start of the buffer without advancing the start of the buffer.

Time complexity: O(1)

Raises

ValueError if buffer is empty

Returns

element at the start of the buffer

pop()[source]

Gets the element at the start of the buffer and advances the start of the buffer by one, consuming the element returned.

Time complexity: O(1)

Raises

ValueError if buffer is empty

Returns

element at the start of the buffer

prod(dtype=None, out=None, keepdims=False, initial=1, where=True)NoReturn[source]
Raises

NotImplementedError – This function will be implemented in the future

ptp(out=None, keepdims=False)NoReturn[source]
Raises

NotImplementedError – This function will be implemented in the future

put(values, mode='raise')NoReturn[source]
Raises

NotImplementedError – This function has no plan for implementation as of this version.

ravel()NoReturn[source]
Raises

NotImplementedError – This function will be implemented in the future

repeat()NoReturn[source]
Raises

NotImplementedError – This function will be implemented in the future

reset()[source]

Empties all elements from the buffer.

Time complexity: O(1)

Returns

True if buffer is empty, False otherwise.

Return type

bool

round(decimals=0, out=None)[source]

Return a copy of the valid region of the buffer with each element rounded to the given number of decimals.

See also

numpy.around()

searchsorted(v, side='left', sorter=None)NoReturn[source]
Raises

NotImplementedError – This function has no plan for implementation as of this version.

setfield(val, dtype, offset=0)NoReturn[source]
Raises

NotImplementedError – This function has no plan for implementation as of this version.

squeeze(axis=- 1)NoReturn[source]
Raises

NotImplementedError – This function will be implemented in the future

std(axis=- 1)NoReturn[source]
Raises

NotImplementedError – This function will be implemented in the future

sum(axis=- 1, dtype=None, out=None, keepdims=False, initial=0, where=True)NoReturn[source]
Raises

NotImplementedError – This function will be implemented in the future

swapaxes(axis1, axis2)NoReturn[source]
Raises

NotImplementedError – This function is being considered for implementation in the future

take(indices, axis=None, out=None, mode='raise')NoReturn[source]
Raises

NotImplementedError – This function will be implemented in the future

tobytes(order='C')NoReturn[source]
Raises

NotImplementedError – This function will be implemented in the future

tofile(fid, sep='', format='%s')NoReturn[source]
Raises

NotImplementedError – This function will be implemented in the future

tolist()NoReturn[source]
Raises

NotImplementedError – This function will be implemented in the future

tostring(order='C')NoReturn[source]
Raises

NotImplementedError – This function will be implemented in the future

transpose(*axes)NoReturn[source]
Raises

NotImplementedError – This function has no plan for implementation as of this version.

var(axis=None, dtype=None, out=None, ddof=0, keepdims=False, *, where=True)NoReturn[source]
Raises

NotImplementedError – This function will be implemented in the future

ancb.can_broadcast(shape1, shape2)bool[source]

Check if shapes shape1 and shape2 can be broadcast together.

Parameters
  • shape1 (Tuple) – first shape to parse

  • shape2 (Tuple) – second shape to parse

Returns

True if arr1 and arr2 can be broadcast together, False otherwise

Return type

bool

ancb.star_can_broadcast(starexpr)bool[source]

Check if shapes shape1 and shape2 can be broadcast together from a tuple of zip_longest(shape1, shape2, fillvalue=1) called the “starexpr”

Parameters

starexpr (Tuple) – starexpr to parse

Returns

True if shape1 and shape2 can be broadcast together, False otherwise

Return type

bool