A list with a short ``repr()``. This is meant to be used for a homogeneous list of artists, so that they don't cause long, meaningless output. Instead of :: [ , ,
| 423 | |
| 424 | |
| 425 | class silent_list(list): |
| 426 | """ |
| 427 | A list with a short ``repr()``. |
| 428 | |
| 429 | This is meant to be used for a homogeneous list of artists, so that they |
| 430 | don't cause long, meaningless output. |
| 431 | |
| 432 | Instead of :: |
| 433 | |
| 434 | [<matplotlib.lines.Line2D object at 0x7f5749fed3c8>, |
| 435 | <matplotlib.lines.Line2D object at 0x7f5749fed4e0>, |
| 436 | <matplotlib.lines.Line2D object at 0x7f5758016550>] |
| 437 | |
| 438 | one will get :: |
| 439 | |
| 440 | <a list of 3 Line2D objects> |
| 441 | |
| 442 | If ``self.type`` is None, the type name is obtained from the first item in |
| 443 | the list (if any). |
| 444 | """ |
| 445 | |
| 446 | def __init__(self, type, seq=None): |
| 447 | self.type = type |
| 448 | if seq is not None: |
| 449 | self.extend(seq) |
| 450 | |
| 451 | def __repr__(self): |
| 452 | if self.type is not None or len(self) != 0: |
| 453 | tp = self.type if self.type is not None else type(self[0]).__name__ |
| 454 | return f"<a list of {len(self)} {tp} objects>" |
| 455 | else: |
| 456 | return "<an empty list>" |
| 457 | |
| 458 | |
| 459 | def _local_over_kwdict( |
no outgoing calls
no test coverage detected
searching dependent graphs…