How to use the decorator.array_function function in decorator

To help you get started, we’ve selected a few decorator examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Jammy2211 / PyAutoLens / auto_lens / test_decorator.py View on Github external
def test__simple_assumptions(self, circular):
        array = decorator.array_function(circular.flux_at_coordinates)(x_min=0, x_max=101, y_min=0, y_max=101,
                                                                       pixel_scale=1)
        assert array.shape == (101, 101)
        assert array[51][51] > array[51][52]
        assert array[51][51] > array[52][51]
        assert all(map(lambda i: i > 0, array[0]))

        array = decorator.array_function(circular.flux_at_coordinates)(x_min=0, x_max=100, y_min=0, y_max=100,
                                                                       pixel_scale=0.5)
        assert array.shape == (200, 200)
github Jammy2211 / PyAutoLens / auto_lens / test_decorator.py View on Github external
def test_combined_array(self, circular):
        combined = profile.CombinedLightProfile(circular, circular)

        assert all(map(lambda i: i == 2,
                       decorator.array_function(combined.flux_at_coordinates)().flatten() / decorator.array_function(
                           circular.flux_at_coordinates)().flatten()))
github Jammy2211 / PyAutoLens / auto_lens / test_decorator.py View on Github external
def test_mask(self):
        mask = MockMask([(x, 0) for x in range(-5, 6)])
        array = decorator.array_function(lambda coordinates: 1)(-5, -5, 5, 5, 1, mask=mask)

        assert array[5][5] is None
        assert array[5][6] is not None
        assert array[6][5] is None
        assert array[0][0] is not None
        assert array[0][5] is None
github Jammy2211 / PyAutoLens / auto_lens / test_decorator.py View on Github external
def test__deflection_angle_array(self):
        mass_profile = profile.EllipticalIsothermalMassProfile(centre=(0, 0), axis_ratio=0.5, phi=45.0,
                                                               einstein_radius=2.0)
        # noinspection PyTypeChecker
        assert all(decorator.array_function(mass_profile.compute_deflection_angle)(-1, -1, -0.5, -0.5, 0.1)[0][
                       0] == mass_profile.compute_deflection_angle((-1, -1)))
github Jammy2211 / PyAutoLens / auto_lens / test_decorator.py View on Github external
def test_symmetric_profile(self, circular):
        circular.centre = (50, 50)
        array = decorator.array_function(circular.flux_at_coordinates)(x_min=0, x_max=100, y_min=0, y_max=100,
                                                                       pixel_scale=1.0)

        assert array[50][50] > array[50][51]
        assert array[50][50] > array[49][50]
        assert array[49][50] == array[50][51]
        assert array[50][51] == array[50][49]
        assert array[50][49] == array[51][50]

        array = decorator.array_function(circular.flux_at_coordinates)(x_min=0, x_max=100, y_min=0, y_max=100,
                                                                       pixel_scale=0.5)

        assert array[100][100] > array[100][101]
        assert array[100][100] > array[99][100]
        assert array[99][100] == array[100][101]
        assert array[100][101] == array[100][99]
        assert array[100][99] == array[101][100]
github Jammy2211 / PyAutoLens / auto_lens / test_decorator.py View on Github external
def test__flat_array(self, circular):
        array = decorator.array_function(circular.flux_at_coordinates)(x_min=0, x_max=100, y_min=0, y_max=100,
                                                                       pixel_scale=1)
        flat_array = decorator.array_function(circular.flux_at_coordinates)(x_min=0, x_max=100, y_min=0, y_max=100,
                                                                            pixel_scale=1).flatten()

        assert all(array[0] == flat_array[:100])
        assert all(array[1] == flat_array[100:200])
github Jammy2211 / PyAutoLens / auto_lens / test_decorator.py View on Github external
def test__flat_array(self, circular):
        array = decorator.array_function(circular.flux_at_coordinates)(x_min=0, x_max=100, y_min=0, y_max=100,
                                                                       pixel_scale=1)
        flat_array = decorator.array_function(circular.flux_at_coordinates)(x_min=0, x_max=100, y_min=0, y_max=100,
                                                                            pixel_scale=1).flatten()

        assert all(array[0] == flat_array[:100])
        assert all(array[1] == flat_array[100:200])
github Jammy2211 / PyAutoLens / auto_lens / test_decorator.py View on Github external
def test__ellipticity(self, circular, elliptical, vertical):
        array = decorator.array_function(circular.flux_at_coordinates)(x_min=0, x_max=101, y_min=0, y_max=101,
                                                                       pixel_scale=1)
        assert array[60][0] == array[0][60]

        array = decorator.array_function(elliptical.flux_at_coordinates)(x_min=0, x_max=100, y_min=0, y_max=100,
                                                                         pixel_scale=1)

        assert array[60][51] > array[51][60]

        array = decorator.array_function(vertical.flux_at_coordinates)(x_min=0, x_max=100, y_min=0, y_max=100,
                                                                       pixel_scale=1)
        assert array[60][51] < array[51][60]