r""" Parameters ---------- X : tuple (X0, X1, ...) of length equal to the number of colormaps X0, X1 ...: float or int, `~numpy.ndarray` or scalar The data value(s) to convert to RGBA. For floats, *Xi...* should be in the interv
(self, X, alpha=None, bytes=False, clip=True)
| 1463 | self._rgba_bad = (0.0, 0.0, 0.0, 0.0) # If bad, don't paint anything. |
| 1464 | |
| 1465 | def __call__(self, X, alpha=None, bytes=False, clip=True): |
| 1466 | r""" |
| 1467 | Parameters |
| 1468 | ---------- |
| 1469 | X : tuple (X0, X1, ...) of length equal to the number of colormaps |
| 1470 | X0, X1 ...: |
| 1471 | float or int, `~numpy.ndarray` or scalar |
| 1472 | The data value(s) to convert to RGBA. |
| 1473 | For floats, *Xi...* should be in the interval ``[0.0, 1.0]`` to |
| 1474 | return the RGBA values ``X*100`` percent along the Colormap line. |
| 1475 | For integers, *Xi...* should be in the interval ``[0, self[i].N)`` to |
| 1476 | return RGBA values *indexed* from colormap [i] with index ``Xi``, where |
| 1477 | self[i] is colormap i. |
| 1478 | alpha : float or array-like or None |
| 1479 | Alpha must be a scalar between 0 and 1, a sequence of such |
| 1480 | floats with shape matching *Xi*, or None. |
| 1481 | bytes : bool, default: False |
| 1482 | If False (default), the returned RGBA values will be floats in the |
| 1483 | interval ``[0, 1]`` otherwise they will be `numpy.uint8`\s in the |
| 1484 | interval ``[0, 255]``. |
| 1485 | clip : bool, default: True |
| 1486 | If True, clip output to 0 to 1 |
| 1487 | |
| 1488 | Returns |
| 1489 | ------- |
| 1490 | Tuple of RGBA values if X[0] is scalar, otherwise an array of |
| 1491 | RGBA values with a shape of ``X.shape + (4, )``. |
| 1492 | """ |
| 1493 | |
| 1494 | if len(X) != len(self): |
| 1495 | raise ValueError( |
| 1496 | f'For the selected colormap the data must have a first dimension ' |
| 1497 | f'{len(self)}, not {len(X)}') |
| 1498 | rgba, mask_bad = self[0]._get_rgba_and_mask(X[0], bytes=False) |
| 1499 | for c, xx in zip(self[1:], X[1:]): |
| 1500 | sub_rgba, sub_mask_bad = c._get_rgba_and_mask(xx, bytes=False) |
| 1501 | rgba[..., :3] += sub_rgba[..., :3] # add colors |
| 1502 | rgba[..., 3] *= sub_rgba[..., 3] # multiply alpha |
| 1503 | mask_bad |= sub_mask_bad |
| 1504 | |
| 1505 | if self.combination_mode == 'sRGB_sub': |
| 1506 | rgba[..., :3] -= len(self) - 1 |
| 1507 | |
| 1508 | rgba[mask_bad] = self.get_bad() |
| 1509 | |
| 1510 | if clip: |
| 1511 | rgba = np.clip(rgba, 0, 1) |
| 1512 | |
| 1513 | if alpha is not None: |
| 1514 | if clip: |
| 1515 | alpha = np.clip(alpha, 0, 1) |
| 1516 | if np.shape(alpha) not in [(), np.shape(X[0])]: |
| 1517 | raise ValueError( |
| 1518 | f"alpha is array-like but its shape {np.shape(alpha)} does " |
| 1519 | f"not match that of X[0] {np.shape(X[0])}") |
| 1520 | rgba[..., -1] *= alpha |
| 1521 | |
| 1522 | if bytes: |
nothing calls this directly
no test coverage detected