Class TFCDict#

Inheritance Relationships#

Base Type#

  • public OrderedDict

Class Documentation#

tfc.utils.TFCUtils.TFCDict : public OrderedDict
This is the TFC dictionary class. It extends an OrderedDict and
adds a few methods that enable:

  - Adding dictionaries with the same keys together
  - Turning a dictionary into a 1-D array
  - Turning a 1-D array into a dictionary

Public Functions

__init__(self, *Any args)#
Initialize TFCDict using the OrderedDict method.

Parameters
----------
*args : Any
    Arguments to pass to the OrderedDict
getSlices(self)#
Function that creates slices for each of the keys in the dictionary.
update(self, *Any args)#
Overload the update method to update the _keys variable as well.

Parameters
----------
*args : Any
    Same as *args for the update method of ordered dict.
toArray(self)#
Send dictionary to a flat JAX array.

Returns
-------
np.ndarray
    This dictionary as a flat JAX array.
toDict(self, np.ndarray arr)#
Send a flat JAX array to a TFCDict with the same keys.

Parameters
----------
arr : ndarray
    Flat JAX array to convert to TFCDict. Must have the same number of elements as total number of elements in the dictionary.

Returns
-------
TFCDict
    JAX array as a TFCDict
block_until_ready(self)#
Mimics block_until_ready for jax arrays. Used to halt the program until the computation that created the
dictionary is finished.

Returns
-------
TFCDict
    This TFCDict.
__iadd__(self, TFCDictAddable o)#
Used to overload "+=" for TFCDict so that 2 TFCDict's can be added together.

Parameters
----------
o : TFCDictAddable
    Values to add to the current dicitonary.

Returns
----------
self : TFCDict
    A copy of self after adding in the values from o.
__isub__(self, TFCDictAddable o)#
Used to overload "-=" for TFCDict so that 2 TFCDict's can be subtracted.

Parameters
----------
o : TFCDictAddable
    Values to subtract from the current dicitonary.

Returns
-------
self : TFCDict
    A copy of self after subtracting the values from o.
__add__(self, TFCDictAddable o)#
Used to overload "+" for TFCDict so that 2 TFCDict's can be added together.

Parameters
----------
o : TFCDictAddable
    Values to add to the current dicitonary.

Returns
----------
out : TFCDict
    A TFCDict with values = self + o.
__sub__(self, TFCDictAddable o)#
Used to overload "-" for TFCDict so that 2 TFCDict's can be subtracted.

Parameters
----------
o : TFCDictAddable
    Values to subtract from the current dicitonary.

Returns
----------
self : TFCDict
    A TFCDict with values = self - o.

Protected Attributes

_keys#
_nKeys#
_slices#