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

Method sqrt

lib/matplotlib/_mathtext.py:2891–2930  ·  view source on GitHub ↗
(self, toks: ParseResults)

Source from the content-addressed store, hash-verified

2889 overset = underset = _genset
2890
2891 def sqrt(self, toks: ParseResults) -> T.Any:
2892 root = toks.get("root")
2893 body = toks["value"]
2894 state = self.get_state()
2895 thickness = state.get_current_underline_thickness()
2896
2897 # Determine the height of the body, and add a little extra to
2898 # the height so it doesn't seem cramped
2899 height = body.height - body.shift_amount + 5 * thickness
2900 depth = body.depth + body.shift_amount
2901 check = AutoHeightChar(r'\__sqrt__', height, depth, state)
2902 height = check.height - check.shift_amount
2903 depth = check.depth + check.shift_amount
2904
2905 # Put a little extra space to the left and right of the body
2906 padded_body = Hlist([Hbox(2 * thickness), body, Hbox(2 * thickness)])
2907 rightside = Vlist([Hrule(state), Glue('fill'), padded_body])
2908 # Stretch the glue between the hrule and the body
2909 rightside.vpack(height + (state.fontsize * state.dpi) / (100 * 12),
2910 'exactly', depth)
2911
2912 # Add the root and shift it upward so it is above the tick.
2913 # The value of 0.6 is a hard-coded hack ;)
2914 if not root:
2915 root = Box(0.5 * check.width, 0., 0.)
2916 else:
2917 root = Hlist(root)
2918 root.shrink()
2919 root.shrink()
2920
2921 root_vlist = Vlist([Hlist([root])])
2922 root_vlist.shift_amount = -height * 0.6
2923
2924 hlist = Hlist([
2925 root_vlist, # Root
2926 Kern(-0.5 * check.width), # Negative kerning to put root over tick
2927 check, # Check
2928 rightside, # Body
2929 ])
2930 return [hlist]
2931
2932 def overline(self, toks: ParseResults) -> T.Any:
2933 body = toks["body"]

Callers 15

_arcballMethod · 0.80
normalizeMethod · 0.80
_get_data_scaleFunction · 0.80
test_surface3d_shadedFunction · 0.80
test_axes3d_isometricFunction · 0.80
test_quaternionFunction · 0.80
test_rotateFunction · 0.80
__init__Method · 0.80
circleMethod · 0.80
unit_circle_righthalfMethod · 0.80
arcMethod · 0.80

Calls 13

get_stateMethod · 0.95
vpackMethod · 0.95
AutoHeightCharClass · 0.85
HlistClass · 0.85
HboxClass · 0.85
VlistClass · 0.85
HruleClass · 0.85
GlueClass · 0.85
BoxClass · 0.85
KernClass · 0.85
getMethod · 0.45

Tested by 15

test_surface3d_shadedFunction · 0.64
test_axes3d_isometricFunction · 0.64
test_quaternionFunction · 0.64
test_rotateFunction · 0.64
test_integration_optionsFunction · 0.64
test_imshowFunction · 0.64
test_imshow_clipFunction · 0.64
test_markeveryFunction · 0.64
test_markevery_lineFunction · 0.64
test_errorbarFunction · 0.64
test_errorbar_shapeFunction · 0.64