示例#1
0
    def test__units__from_config_or_via_manual_input(self):

        plotter = aplt.Plotter()

        assert plotter.units.use_scaled == True
        assert plotter.units.in_kpc == False
        assert plotter.units.conversion_factor == None

        plotter = aplt.Plotter(
            units=aplt.Units(in_kpc=True, conversion_factor=2.0))

        assert plotter.units.use_scaled == True
        assert plotter.units.in_kpc == True
        assert plotter.units.conversion_factor == 2.0

        sub_plotter = aplt.SubPlotter()

        assert sub_plotter.units.use_scaled == True
        assert sub_plotter.units.in_kpc == False
        assert sub_plotter.units.conversion_factor == None

        sub_plotter = aplt.SubPlotter(
            units=aplt.Units(use_scaled=False, conversion_factor=2.0))

        assert sub_plotter.units.use_scaled == False
        assert sub_plotter.units.in_kpc == False
        assert sub_plotter.units.conversion_factor == 2.0
示例#2
0
    def test__loads_values_from_config_if_not_manually_input(self):

        units = aplt.Units()

        assert units.use_scaled is True
        assert units.in_kpc is False
        assert units.conversion_factor == None

        units = aplt.Units(in_kpc=True, conversion_factor=2.0)

        assert units.use_scaled is True
        assert units.in_kpc is True
        assert units.conversion_factor == 2.0
示例#3
0
    def test__set__works_for_good_values(self):

        array = aa.Array2D.ones(shape_native=(2, 2), pixel_scales=1.0)

        units = aplt.Units(use_scaled=True, conversion_factor=None)

        yticks = aplt.YTicks(fontsize=34)

        extent = array.extent_of_zoomed_array(buffer=1)

        yticks.set(array=array,
                   min_value=extent[2],
                   max_value=extent[3],
                   units=units)

        yticks = aplt.YTicks(fontsize=34)

        units = aplt.Units(use_scaled=False, conversion_factor=None)

        yticks.set(array=array,
                   min_value=extent[2],
                   max_value=extent[3],
                   units=units)

        yticks = aplt.YTicks(fontsize=34)

        units = aplt.Units(use_scaled=True, conversion_factor=2.0)

        yticks.set(array=array,
                   min_value=extent[2],
                   max_value=extent[3],
                   units=units)

        yticks = aplt.YTicks(fontsize=34)

        units = aplt.Units(use_scaled=False, conversion_factor=2.0)

        yticks.set(array=array,
                   min_value=extent[2],
                   max_value=extent[3],
                   units=units)
示例#4
0
    def test__plotter_with_new_units__new_outputs_are_setup_correctly_if_input(
            self):

        plotter = aplt.Plotter(
            aplt.Units(use_scaled=True, in_kpc=True, conversion_factor=1.0))

        assert plotter.units.use_scaled == True
        assert plotter.units.in_kpc == True
        assert plotter.units.conversion_factor == 1.0

        plotter = plotter.plotter_with_new_units(use_scaled=False,
                                                 in_kpc=False,
                                                 conversion_factor=2.0)

        assert plotter.units.use_scaled == False
        assert plotter.units.in_kpc == False
        assert plotter.units.conversion_factor == 2.0

        plotter = plotter.plotter_with_new_units(conversion_factor=3.0)

        assert plotter.units.use_scaled == False
        assert plotter.units.in_kpc == False
        assert plotter.units.conversion_factor == 3.0