AmuseContainer

class amuse_util.datamodel.AmuseContainer(wrapped: Any, name: str, _inputs: Optional[inspect.BoundArguments] = None)[source]

Bases: ObjectProxy

AmuseContainer for object that can hold channels.

AmuseContainer is built with wrapt.ObjectProxy, so looks like the object it holds, with a few added attributes and methods.

Attributes
name: str

the name of the object

channel_to: AttrDict

dictionary of channels to other objects

channel_from: AttrDict

dictionary of channels from other objects

_inputs: BoundArguments or None

arguments used to create the contained object needed for reconstructing socket objects like BHTree

# _min_p_recon: int, optional
# whether can make a blank version of the wrapped object
# if None (default), make full
# if int, the minimum number of particles to create before replacing

Initialize container, adding name and channel info.

Methods Summary

add_channel_from(self, going_from, name, …)

Channels from things.

add_channel_to(self, going_to, name, …)

Channels to things.

copy(self, with_channels)

Parameters

Methods Documentation

add_channel_from(self, going_from: Any, name: Union[str, NoneType] = None, attributes: Union[list, NoneType] = None)[source]

Channels from things.

Parameters
going_from: object

something that supports AMUSE channels

name: str, optional

needed if going_from is not an AmuseContainer with a name overrides the name in going_from, if going_from has a .name

attributes: list, optional

attributes in the channel see AMUSE docs

Returns
channel

see AMUSE docs

Raises
ValueError

if going_from is not an AmuseContainer and name is None or if self.name == name

warning

if name (or going_from.name) is already in .channel_from

add_channel_to(self, going_to: Any, name: Union[str, NoneType] = None, attributes: Union[list, NoneType] = None)[source]

Channels to things.

Parameters
going_to: object

something that supports AMUSE channels

name: str, optional

needed if going_to is not an AmuseContainer with a name overrides the name in going_to, if going_to has a .name

attributes: list, optional

attributes in the channel see AMUSE docs

Returns
channel

see AMUSE docs

Raises
ValueError

if going_to is not an AmuseContainer and name is None or if self.name == name

warning

if name (or going_to.name) is already in .channel_to

copy(self, with_channels: bool = False)[source]
Parameters
with_channels: bool

whether to copy channels

Warning

copying a channel copies to the original object. so if two AmuseContainer objects are linked then copying both does not link them. System objects implement a copy method to keep intra-System objects linked.

Returns
AmuseContainer