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

Function test_ellipse_vertices

lib/matplotlib/tests/test_patches.py:106–154  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

104
105
106def test_ellipse_vertices():
107 # expect 0 for 0 ellipse width, height
108 ellipse = Ellipse(xy=(0, 0), width=0, height=0, angle=0)
109 assert_almost_equal(
110 ellipse.get_vertices(),
111 [(0.0, 0.0), (0.0, 0.0)],
112 )
113 assert_almost_equal(
114 ellipse.get_co_vertices(),
115 [(0.0, 0.0), (0.0, 0.0)],
116 )
117
118 ellipse = Ellipse(xy=(0, 0), width=2, height=1, angle=30)
119 assert_almost_equal(
120 ellipse.get_vertices(),
121 [
122 (
123 ellipse.center[0] + ellipse.width / 4 * np.sqrt(3),
124 ellipse.center[1] + ellipse.width / 4,
125 ),
126 (
127 ellipse.center[0] - ellipse.width / 4 * np.sqrt(3),
128 ellipse.center[1] - ellipse.width / 4,
129 ),
130 ],
131 )
132 assert_almost_equal(
133 ellipse.get_co_vertices(),
134 [
135 (
136 ellipse.center[0] - ellipse.height / 4,
137 ellipse.center[1] + ellipse.height / 4 * np.sqrt(3),
138 ),
139 (
140 ellipse.center[0] + ellipse.height / 4,
141 ellipse.center[1] - ellipse.height / 4 * np.sqrt(3),
142 ),
143 ],
144 )
145 v1, v2 = np.array(ellipse.get_vertices())
146 np.testing.assert_almost_equal((v1 + v2) / 2, ellipse.center)
147 v1, v2 = np.array(ellipse.get_co_vertices())
148 np.testing.assert_almost_equal((v1 + v2) / 2, ellipse.center)
149
150 ellipse = Ellipse(xy=(2.252, -10.859), width=2.265, height=1.98, angle=68.78)
151 v1, v2 = np.array(ellipse.get_vertices())
152 np.testing.assert_almost_equal((v1 + v2) / 2, ellipse.center)
153 v1, v2 = np.array(ellipse.get_co_vertices())
154 np.testing.assert_almost_equal((v1 + v2) / 2, ellipse.center)
155
156
157def test_rotate_rect():

Callers

nothing calls this directly

Calls 5

get_verticesMethod · 0.95
get_co_verticesMethod · 0.95
EllipseClass · 0.90
sqrtMethod · 0.80
assert_almost_equalMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…