AmuseContainer¶
-
class
amuse_util.datamodel.AmuseContainer(wrapped: Any, name: str, _inputs: Optional[inspect.BoundArguments] = None)[source]¶ Bases:
ObjectProxyAmuseContainer 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_fromis not an AmuseContainer with a name overrides the name ingoing_from, ifgoing_fromhas a.name- attributes: list, optional
attributes in the channel see AMUSE docs
- Returns
- channel
see AMUSE docs
- Raises
- ValueError
if
going_fromis not an AmuseContainer andnameis None or if self.name ==name- warning
if
name(orgoing_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_tois not an AmuseContainer with a name overrides the name ingoing_to, ifgoing_tohas a.name- attributes: list, optional
attributes in the channel see AMUSE docs
- Returns
- channel
see AMUSE docs
- Raises
- ValueError
if
going_tois not an AmuseContainer andnameis None or if self.name ==name- warning
if
name(orgoing_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.
Systemobjects implement acopymethod to keep intra-System objects linked.
- Returns
- AmuseContainer