|
| 1 | +import numpy as np |
| 2 | + |
| 3 | + |
| 4 | +class MockGeometry(object): |
| 5 | + def __init__( |
| 6 | + self, |
| 7 | + pixel_centres=None, |
| 8 | + pixel_neighbors=np.array([1]), |
| 9 | + pixel_neighbors_size=np.array([1]), |
| 10 | + ): |
| 11 | + |
| 12 | + self.pixel_scales = (1.0, 1.0) |
| 13 | + self.origin = (0.0, 0.0) |
| 14 | + self.pixel_centres = pixel_centres |
| 15 | + |
| 16 | + self.pixel_neighbors = pixel_neighbors.astype("int") |
| 17 | + self.pixel_neighbors_size = pixel_neighbors_size.astype("int") |
| 18 | + |
| 19 | + |
| 20 | +class MockPixelization(object): |
| 21 | + def __init__(self, value, grid=None): |
| 22 | + self.value = value |
| 23 | + self.grid = grid |
| 24 | + |
| 25 | + # noinspection PyUnusedLocal,PyShadowingNames |
| 26 | + def mapper_from_grid_and_pixelization_grid( |
| 27 | + self, grid, pixelization_grid, inversion_uses_border, hyper_image=None |
| 28 | + ): |
| 29 | + return self.value |
| 30 | + |
| 31 | + def pixelization_grid_from_grid(self, grid, cluster_grid, hyper_image): |
| 32 | + if hyper_image is None: |
| 33 | + return self.grid |
| 34 | + else: |
| 35 | + return self.grid * hyper_image |
| 36 | + |
| 37 | + |
| 38 | +class MockRegularization(object): |
| 39 | + def __init__(self, matrix_shape): |
| 40 | + self.shape = matrix_shape |
| 41 | + |
| 42 | + def regularization_matrix_from_pixel_neighbors( |
| 43 | + self, pixel_neighbors, pixel_neighbors_size |
| 44 | + ): |
| 45 | + return np.array([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]) |
| 46 | + |
| 47 | + def regularization_matrix_from_mapper(self, mapper): |
| 48 | + return np.array([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]) |
| 49 | + |
| 50 | + |
| 51 | +class MockRegMapper(object): |
| 52 | + |
| 53 | + def __init__(self, pixel_neighbors=None, pixel_neighbors_size=None, pixel_signals=None): |
| 54 | + self.pixel_neighbors = pixel_neighbors |
| 55 | + self.pixel_neighbors_size = pixel_neighbors_size |
| 56 | + self.pixel_signals = pixel_signals |
| 57 | + |
| 58 | + def pixel_signals_from_signal_scale(self, signal_scale): |
| 59 | + return self.pixel_signals |
| 60 | + |
| 61 | + |
| 62 | +class MockMapper(object): |
| 63 | + def __init__(self, matrix_shape, grid=None): |
| 64 | + |
| 65 | + self.grid = grid |
| 66 | + self.mapping_matrix = np.ones(matrix_shape) |
| 67 | + self.geometry = MockGeometry() |
| 68 | + |
| 69 | + |
| 70 | +class MockConvolver(object): |
| 71 | + def __init__(self, matrix_shape): |
| 72 | + self.shape = matrix_shape |
| 73 | + |
| 74 | + def convolve_mapping_matrix(self, mapping_matrix): |
| 75 | + return np.ones(self.shape) |
| 76 | + |
| 77 | + |
| 78 | +class MockInversion(object): |
| 79 | + def __init__(self): |
| 80 | + self.blurred_mapping_matrix = np.zeros((1, 1)) |
| 81 | + self.regularization_matrix = np.zeros((1, 1)) |
| 82 | + self.curvature_matrix = np.zeros((1, 1)) |
| 83 | + self.curvature_reg_matrix = np.zeros((1, 1)) |
| 84 | + self.solution_vector = np.zeros((1)) |
| 85 | + |
| 86 | + @property |
| 87 | + def reconstructed_image(self): |
| 88 | + return np.zeros((1, 1)) |
0 commit comments