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

Method _update_path

lib/matplotlib/patches.py:1169–1203  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1167 super().__init__(self._path, **kwargs)
1168
1169 def _update_path(self):
1170 if np.isnan(np.sum(self._edges)):
1171 raise ValueError('Nan values in "edges" are disallowed')
1172 if self._edges.size - 1 != self._values.size:
1173 raise ValueError('Size mismatch between "values" and "edges". '
1174 "Expected `len(values) + 1 == len(edges)`, but "
1175 f"`len(values) = {self._values.size}` and "
1176 f"`len(edges) = {self._edges.size}`.")
1177 # Initializing with empty arrays allows supporting empty stairs.
1178 verts, codes = [np.empty((0, 2))], [np.empty(0, dtype=Path.code_type)]
1179
1180 _nan_mask = np.isnan(self._values)
1181 if self._baseline is not None:
1182 _nan_mask |= np.isnan(self._baseline)
1183 for idx0, idx1 in cbook.contiguous_regions(~_nan_mask):
1184 x = np.repeat(self._edges[idx0:idx1+1], 2)
1185 y = np.repeat(self._values[idx0:idx1], 2)
1186 if self._baseline is None:
1187 y = np.concatenate([y[:1], y, y[-1:]])
1188 elif self._baseline.ndim == 0: # single baseline value
1189 y = np.concatenate([[self._baseline], y, [self._baseline]])
1190 elif self._baseline.ndim == 1: # baseline array
1191 base = np.repeat(self._baseline[idx0:idx1], 2)[::-1]
1192 x = np.concatenate([x, x[::-1]])
1193 y = np.concatenate([base[-1:], y, base[:1],
1194 base[:1], base, base[-1:]])
1195 else: # no baseline
1196 raise ValueError('Invalid `baseline` specified')
1197 if self.orientation == 'vertical':
1198 xy = np.column_stack([x, y])
1199 else:
1200 xy = np.column_stack([y, x])
1201 verts.append(xy)
1202 codes.append([Path.MOVETO] + [Path.LINETO]*(len(xy)-1))
1203 self._path = Path(np.concatenate(verts), np.concatenate(codes))
1204
1205 def get_data(self):
1206 """Get `.StepPatch` values, edges and baseline as namedtuple."""

Callers 2

__init__Method · 0.95
set_dataMethod · 0.95

Calls 1

PathClass · 0.85

Tested by

no test coverage detected