MCPcopy Create free account
hub / github.com/ahalev/python-microgrid / ModuleList

Class ModuleList

src/pymgrid/modules/module_container.py:419–449  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

417
418
419class ModuleList(UserList):
420 def item(self):
421 """
422 Get the value of a singleton list.
423
424 Returns
425 -------
426 module : BaseMicrogridModule
427 Item in a singleton list.
428
429 Raises
430 ------
431 ValueError :
432 If there is more than one item in the list.
433
434 """
435 if len(self) != 1:
436 raise ValueError("Can only convert a ModuleList of length one to a scalar")
437 return self[0]
438
439 def to_list(self):
440 """
441 :meta private:
442
443 Function to be compatible with Container API.
444
445 """
446 return self
447
448 def verbose_eq(self, other, indent=0):
449 verbose_eq(self, other, list(range(len(self))), indent=indent)
450
451
452def get_subcontainers(modules, set_names=True):

Callers 1

get_subcontainersFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected