| 417 | |
| 418 | |
| 419 | class 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 | |
| 452 | def get_subcontainers(modules, set_names=True): |