Apply this transformation on the given array of *values*. Parameters ---------- values : array-like The input values as an array of length :attr:`~Transform.input_dims` or shape (N, :attr:`~Transform.input_dims`). Returns ---
(self, values)
| 1527 | return self.get_affine().get_matrix() |
| 1528 | |
| 1529 | def transform(self, values): |
| 1530 | """ |
| 1531 | Apply this transformation on the given array of *values*. |
| 1532 | |
| 1533 | Parameters |
| 1534 | ---------- |
| 1535 | values : array-like |
| 1536 | The input values as an array of length :attr:`~Transform.input_dims` or |
| 1537 | shape (N, :attr:`~Transform.input_dims`). |
| 1538 | |
| 1539 | Returns |
| 1540 | ------- |
| 1541 | array |
| 1542 | The output values as an array of length :attr:`~Transform.output_dims` or |
| 1543 | shape (N, :attr:`~Transform.output_dims`), depending on the input. |
| 1544 | """ |
| 1545 | # Ensure that values is a 2d array (but remember whether |
| 1546 | # we started with a 1d or 2d array). |
| 1547 | values = np.asanyarray(values) |
| 1548 | ndim = values.ndim |
| 1549 | values = values.reshape((-1, self.input_dims)) |
| 1550 | |
| 1551 | # Transform the values |
| 1552 | res = self.transform_affine(self.transform_non_affine(values)) |
| 1553 | |
| 1554 | # Convert the result back to the shape of the input values. |
| 1555 | if ndim == 0: |
| 1556 | assert not np.ma.is_masked(res) # just to be on the safe side |
| 1557 | return res[0, 0] |
| 1558 | if ndim == 1: |
| 1559 | return res.reshape(-1) |
| 1560 | elif ndim == 2: |
| 1561 | return res |
| 1562 | raise ValueError( |
| 1563 | "Input values must have shape (N, {dims}) or ({dims},)" |
| 1564 | .format(dims=self.input_dims)) |
| 1565 | |
| 1566 | def transform_affine(self, values): |
| 1567 | """ |
no test coverage detected