Previous topic

util

Next topic

util.cluster

This Page

util.bitset

Classes and functions for arrays of bitsets (i.e., sets of binary values).

class glimpse.util.bitset.BitsetArray(memory, bitset_shape)

A helper class for wrapping a byte array containing an ND-array of bitsets.

FromArray(bits, array_idx=None)

Set values of this packed bitset array from a boolean numpy array.

Reshape(array_shape)

Create a new view of this object’s memory in which the array of bitsets has a different shape.

The length of the component bitsets is unchanged.

ReshapeBitset(bitset_shape)

Create a new view of this object’s memory in which the component bitsets have a different length.

The shape of the array of bitsets is unchanged.

ToArray(array_idx=None)

Create a boolean numpy array from this packed bitset array.

shape

Get the shape of the array.

size

Get the total number of bits in the array of bitsets.

For example, if the shape of the array is (2, 3) and each bitset has 4 elements, then the size is 24 bits.

glimpse.util.bitset.FromArray(array, bitset_dims)

Create a bitset from a boolean array.

Parameters:bitset_dims (int) – Number of final dimensions of array that correspond to a single bitset.
glimpse.util.bitset.MakeBitsetArray(array_shape, bitset_shape, memory=None)

Create an ND-array of bitsets with the given shape.

glimpse.util.bitset.MakeBitsetArrayMemory(array_shape, bitset_shape)

Create a byte array whose size can support an array of bitsets with the given shape.

Parameters:
  • array_shape (list of int) – Dimensions of the array whose elements are bitsets.
  • bitset_shape (list of int) – Dimensions of the bit array stored in each bitset.