dantro
v0.13.1
  • Usage Examples
  • Philosophy and Design Concepts
  • Specializing dantro Classes
  • Integrating dantro into your Project

Data Handling and Transformation

  • The DataManager
  • Data Processing
  • Data Transformation Framework
  • Handling Large Amounts of Data
  • Multidimensional Data
  • DAG Syntax Operation Hooks
  • Data Transformation Examples
  • Data Handling FAQs

Data Structures

  • Groups

Plotting

  • The PlotManager
  • Plot Creators
  • Automated Plot Data Selection
  • Plot Functions
  • Plot Configuration Reference
  • Plot Creator Auto Detection
  • Plotting FAQs

API Reference

  • dantro API Reference
    • Subpackages
      • dantro.containers package
        • Submodules
      • dantro.data_loaders package
      • dantro.groups package
      • dantro.mixins package
      • dantro.plot_creators package
      • dantro.proxy package
      • dantro.utils package
    • Submodules
dantro
  • Docs »
  • dantro package »
  • dantro.containers package »
  • dantro.containers.link module
  • View page source

dantro.containers.link module¶

Implements the Link class and the LinkContainer.

class dantro.containers.link.LinkContainer(*, name: str, data, attrs=None)[source]¶

Bases: dantro.mixins.base.CheckDataMixin, dantro.containers.general.PassthroughContainer

A LinkContainer is a container containing a Link object.

It forwards all attribute calls to the Link object, which in turn forwards all attribute calls to the linked object, thereby emulating the behaviour of the linked object.

DATA_EXPECTED_TYPES = (<class 'dantro.utils.link.Link'>,)¶
_format_info() → str[source]¶

A __format__ helper function: returns info about the item

In this case, the anchor and relative path of the associated link is returned.

DATA_ALLOW_PROXY = False¶
DATA_UNEXPECTED_ACTION = 'warn'¶
FORWARD_ATTR_EXCLUDE = ()¶
FORWARD_ATTR_ONLY = None¶
FORWARD_ATTR_TO = 'data'¶
_ATTRS_CLS¶

alias of dantro.base.BaseDataAttrs

__delitem__(key)¶

Deletes an item

__format__(spec_str: str) → str¶

Creates a formatted string from the given specification.

Invokes further methods which are prefixed by _format_.

__getattr__(attr_name: str)¶

Forward attributes that were not available in this class to some other attribute of the group or container.

Parameters

attr_name (str) – The name of the attribute that was tried to be accessed but was not available in self.

Returns

The attribute attr_name of getattr(self, self.FORWARD_ATTR_TO)

__getitem__(key)¶

Returns an item.

__init__(*, name: str, data, attrs=None)¶

Initialize a BaseDataContainer, which can store data and attributes.

Parameters
  • name (str) – The name of this data container

  • data – The data to store in this container

  • attrs (None, optional) – A mapping that is stored as attributes

__repr__() → str¶

Same as __str__

__setitem__(key, val)¶

Sets an item.

__sizeof__() → int¶

Returns the size of the data (in bytes) stored in this container’s data and its attributes.

Note that this value is approximate. It is computed by calling the sys.getsizeof function on the data, the attributes, the name and some caching attributes that each dantro data tree class contains. Importantly, this is not a recursive algorithm.

Also, derived classes might implement further attributes that are not taken into account either. To be more precise in a subclass, create a specific __sizeof__ method and invoke this parent method additionally.

For more information, see the documentation of sys.getsizeof:

https://docs.python.org/3/library/sys.html#sys.getsizeof

__str__() → str¶

An info string, that describes the object. This invokes the formatting helpers to show the log string (type and name) as well as the info string of this object.

_abc_impl = <_abc_data object>¶
_attrs = None¶
_check_data(data) → None¶

A general method to check the received data for its type

Parameters

data – The data to check

Raises
  • TypeError – If the type was unexpected and the action was ‘raise’

  • ValueError – Illegal value for DATA_UNEXPECTED_ACTION class variable

Returns

None

_check_name(new_name: str) → None¶

Called from name.setter and can be used to check the name that the container is supposed to have. On invalid name, this should raise.

This method can be subclassed to implement more specific behaviour. To propagate the parent classes’ behaviour the subclassed method should always call its parent method using super().

Parameters

new_name (str) – The new name, which is to be checked.

_format_cls_name() → str¶

A __format__ helper function: returns the class name

_format_logstr() → str¶

A __format__ helper function: returns the log string, a combination of class name and name

_format_name() → str¶

A __format__ helper function: returns the name

_format_path() → str¶

A __format__ helper function: returns the path to this container

_forward_attr_get_forwarding_target()¶

Get the object that the attribute call is to be forwarded to

_forward_attr_post_hook(attr)¶

Invoked before attribute forwarding occurs

_forward_attr_pre_hook(attr_name: str = None)¶

Invoked before attribute forwarding occurs

_item_access_convert_list_key(key)¶

If given something that is not a list, just return that key

property attrs¶

The container attributes.

property classname¶

Returns the name of this DataContainer-derived class

property data¶

The stored data.

property logstr¶

Returns the classname and name of this object; a combination often used in logging…

property name¶

The name of this DataContainer-derived object.

property parent¶

The associated parent of this container or group

property path¶

The path to get to this container or group from some root path

Next Previous

© Copyright 2020, Utopia Developers Revision 720291e2.

Built with Sphinx using a theme provided by Read the Docs.