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

Function check_segments

lib/matplotlib/tests/test_collections.py:272–295  ·  view source on GitHub ↗

Test helper checking that all values in the segment are correct, given a particular set of inputs.

(coll, positions, linelength, lineoffset, orientation)

Source from the content-addressed store, hash-verified

270
271
272def check_segments(coll, positions, linelength, lineoffset, orientation):
273 """
274 Test helper checking that all values in the segment are correct, given a
275 particular set of inputs.
276 """
277 segments = coll.get_segments()
278 if (orientation.lower() == 'horizontal'
279 or orientation.lower() == 'none' or orientation is None):
280 # if horizontal, the position in is in the y-axis
281 pos1 = 1
282 pos2 = 0
283 elif orientation.lower() == 'vertical':
284 # if vertical, the position in is in the x-axis
285 pos1 = 0
286 pos2 = 1
287 else:
288 raise ValueError("orientation must be 'horizontal' or 'vertical'")
289
290 # test to make sure each segment is correct
291 for i, segment in enumerate(segments):
292 assert segment[0, pos1] == lineoffset + linelength / 2
293 assert segment[1, pos1] == lineoffset - linelength / 2
294 assert segment[0, pos2] == positions[i]
295 assert segment[1, pos2] == positions[i]
296
297
298def test_collection_norm_autoscale():

Calls 1

get_segmentsMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…