Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d7a229a

Browse files
committed
Improve readability of mathtext internal structures.
This changes the repr of mathtext lists from e.g. ``` [Hlist <70.39 41.78 0.00 0.00> [Hlist <0.00 0.00 0.00 0.00> ] [Hlist <37.62 40.09 0.00 0.00> `V` k1.11] [Hlist <32.76 41.78 0.00 0.00> ` ` `l` k10.34]] ``` to ``` Hlist<w=70.39 h=41.78 d=0.00 s=0.00>[Hlist<w=0.00 h=0.00 d=0.00 s=0.00>[], Hlist<w=37.62 h=40.09 d=0.00 s=0.00>[`V`, k1.11], Hlist<w=32.76 h=41.78 d=0.00 s=0.00>[` `, `l`, k10.34]] ``` These are internal structures that should only ever be seen when debugging mathtext layout and can be quite deeply nested, so a somewhat concise notation should is good (e.g., backticks for Chars, k for Kerns), but still... - indicate what each of the four numbers correspond to (width/height/descent shift), - move the brackets *after* the class name and metrics, which makes it clearer what is info about the list instance itself and what are the contents of the instance (in particular, the empty hlist at the beginning is now clearer), - separate list items with commas.
1 parent 0d0799b commit d7a229a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/matplotlib/_mathtext.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,11 +1236,11 @@ def __init__(self, elements):
12361236
self.glue_order = 0 # The order of infinity (0 - 3) for the glue
12371237

12381238
def __repr__(self):
1239-
return '[%s <%.02f %.02f %.02f %.02f> %s]' % (
1239+
return '%s<w=%.02f h=%.02f d=%.02f s=%.02f>[%s]' % (
12401240
super().__repr__(),
12411241
self.width, self.height,
12421242
self.depth, self.shift_amount,
1243-
' '.join([repr(x) for x in self.children]))
1243+
', '.join([repr(x) for x in self.children]))
12441244

12451245
@staticmethod
12461246
def _determine_order(totals):

0 commit comments

Comments
 (0)