ndict#

class ndict(*args, nameattr='name', type=None, strict=True, overwrite=False, **kwargs)[source]#

Bases: objdict

A dictionary-like class that provides additional functionalities for handling named items.

Parameters:
  • name (str) – The attribute of the item to use as the dict key (i.e., all items should have this attribute defined)

  • type (type) – The expected type of items.

  • strict (bool) – If True, only items with the specified attribute will be accepted.

  • overwrite (bool) – whether to allow adding a key when one has already been added

Examples:

networks = ss.ndict(ss.MFNet(), ss.MaternalNet())
networks = ss.ndict([ss.MFNet(), ss.MaternalNet()])
networks = ss.ndict({'mf':ss.MFNet(), 'maternal':ss.MaternalNet()})

Methods

__call__()[source]#

Shortcut for returning values

extend(*args, **kwargs)[source]#

Add new items to the ndict, by item, list, or dict

merge(other)[source]#

Merge another dictionary with this one

copy()[source]#

Shallow copy

__add__(other)[source]#

Allow c = a + b