Bamboost

bamboost.core.hdf5.attrsdict

This module provides AttrsDict, a dictionary-like object that is synced with the attributes of a group in the HDF5 file.

Key features:

  • The object is tied to a simulation. If the simulation is read-only, the object is read-only too.
  • Automatic synchronization: Updates to the mapping are pushed to the file immediately when the simulation is mutable.
  • Thread safe and MPI-compatible. Uses the single_process_queue of the file object to handle attribute updates.

Attributes

  • AttrsEncoder=_AttrsEncoder()

Classes

_AttrsEncoder

Attributes:
  • _encoders:typing.Dict[typing.Type, typing.Callable[[typing.Any], typing.Any]]={}
  • _decoders:typing.Dict[typing.Type, typing.Callable[[typing.Any], typing.Any]]={}
Arguments:
  • typ:typing.Union[typing.Type, typing.Sequence[typing.Type]]
  • encode:typing.Callable
Arguments:
  • typ:typing.Union[typing.Type, typing.Sequence[typing.Type]]
  • decode:typing.Callable
_AttrsEncoder.encode(self, obj) -> Any
Arguments:
  • obj:typing.Any
_AttrsEncoder.decode(self, obj) -> Any
Arguments:
  • obj:typing.Any

AttrsDict

AttrsDict(self, file, path)

A dictionary-like object for the attributes of a group in the HDF5 file.

This object is tied to a simulation. If the simulation is read-only, the object is immutable. If mutable, changes are pushed to the HDF5 file immediately.

Arguments:
  • file:HDF5File[bamboost._typing._MT]
  • path:str
Attributes:
  • mutable:bool=False
  • _path:str=bamboost.core.hdf5.attrsdict.AttrsDict(path)
  • _dict:collections.abc.MutableMapping=self.read()
  • _obj:h5py.h5py.HLObject
  • set=bamboost.core.hdf5.attrsdict.AttrsDict.__setitem__

    Set an attribute. This method is a an alias for __setitem__.

AttrsDict.__delitem__(self, key) -> None
Arguments:
  • key:str
AttrsDict.__setitem__(self, key, value) -> None
Arguments:
  • key:str
  • value:typing.Any
AttrsDict.__str__(self) -> str
AttrsDict.__repr__(self) -> str
AttrsDict.__getitem__(self, key) -> Any
Arguments:
  • key:str
AttrsDict.__new__(cls, *args, **kwargs)
Arguments:
  • cls
  • args=()
  • kwargs={}
AttrsDict.read(self) -> dict
AttrsDict.update(self, update_dict) -> None

Update the dictionary. This method pushes the update to the HDF5 file.

Arguments:
  • update_dict:dict

    new dictionary

AttrsDict._repr_pretty_(self, p, cycle)
Arguments:
  • p
  • cycle