MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / _make_str_method

Function _make_str_method

lib/matplotlib/transforms.py:54–79  ·  view source on GitHub ↗

Generate a ``__str__`` method for a `.Transform` subclass. After :: class T: __str__ = _make_str_method("attr", key="other") ``str(T(...))`` will be .. code-block:: text {type(T).__name__}( {self.attr}, key={self.other})

(*args, **kwargs)

Source from the content-addressed store, hash-verified

52
53
54def _make_str_method(*args, **kwargs):
55 """
56 Generate a ``__str__`` method for a `.Transform` subclass.
57
58 After ::
59
60 class T:
61 __str__ = _make_str_method("attr", key="other")
62
63 ``str(T(...))`` will be
64
65 .. code-block:: text
66
67 {type(T).__name__}(
68 {self.attr},
69 key={self.other})
70 """
71 indent = functools.partial(textwrap.indent, prefix=" " * 4)
72 def strrepr(x): return repr(x) if isinstance(x, str) else str(x)
73 return lambda self: (
74 type(self).__name__ + "("
75 + ",".join([*(indent("\n" + strrepr(getattr(self, arg)))
76 for arg in args),
77 *(indent("\n" + k + "=" + strrepr(getattr(self, arg)))
78 for k, arg in kwargs.items())])
79 + ")")
80
81
82class TransformNode:

Callers 13

TransformedBboxClass · 0.85
LockableBboxClass · 0.85
TransformWrapperClass · 0.85
Affine2DClass · 0.85
IdentityTransformClass · 0.85
_BlendedMixinClass · 0.85
CompositeAffine2DClass · 0.85
BboxTransformClass · 0.85
BboxTransformToClass · 0.85
BboxTransformFromClass · 0.85
ScaledTranslationClass · 0.85

Calls 2

strreprFunction · 0.85
joinMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…