Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_defaults_both(self):
# noinspection PyTypeChecker
phase = phase_extensions.InversionBackgroundBothPhase(MockPhase())
constant = af.ModelInstance()
constant.hyper_image_sky = hd.HyperImageSky()
constant.hyper_background_noise = hd.HyperBackgroundNoise()
mapper = phase.make_variable(constant)
assert isinstance(mapper.hyper_image_sky, af.PriorModel)
assert isinstance(mapper.hyper_background_noise, af.PriorModel)
assert mapper.hyper_image_sky.cls == hd.HyperImageSky
assert mapper.hyper_background_noise.cls == hd.HyperBackgroundNoise
def __init__(
self,
model_image=None,
mask=None,
galaxy_images=(),
constant=None,
analysis=None,
optimizer=None,
pixelization=None,
):
self.model_image = model_image
self.unmasked_model_image = model_image
self.mask_2d = mask
self.galaxy_images = galaxy_images
self.constant = constant or af.ModelInstance()
self.variable = af.ModelMapper()
self.analysis = analysis
self.optimizer = optimizer
self.pixelization = pixelization
self.hyper_combined = MockHyperCombinedPhase()
def run(self, positions, pixel_scale, results):
self.positions = positions
self.pixel_scale = pixel_scale
self.results = results
return af.Result(af.ModelInstance(), 1)
def run(self, positions, pixel_scales, results):
self.save_metadata(MockImagingData())
self.positions = positions
self.pixel_scales = pixel_scales
self.results = results
return af.Result(af.ModelInstance(), 1)
def test__defaults_both(self):
# noinspection PyTypeChecker
phase = al.InversionBackgroundBothPhase(MockPhase())
instance = af.ModelInstance()
instance.hyper_image_sky = al.hyper_data.HyperImageSky()
instance.hyper_background_noise = al.hyper_data.HyperBackgroundNoise()
mapper = phase.make_model(instance)
assert isinstance(mapper.hyper_image_sky, af.PriorModel)
assert isinstance(mapper.hyper_background_noise, af.PriorModel)
assert mapper.hyper_image_sky.cls == al.hyper_data.HyperImageSky
assert mapper.hyper_background_noise.cls == al.hyper_data.HyperBackgroundNoise
def test__phase_is_extended_with_hyper_phases__sets_up_hyper_images(
self, interferometer_7, mask_7x7
):
galaxies = af.ModelInstance()
galaxies.lens = al.Galaxy(redshift=0.5)
galaxies.source = al.Galaxy(redshift=1.0)
instance = af.ModelInstance()
instance.galaxies = galaxies
hyper_galaxy_image_path_dict = {
("galaxies", "lens"): al.Array.ones(shape_2d=(3, 3), pixel_scales=1.0),
("galaxies", "source"): al.Array.full(
fill_value=2.0, shape_2d=(3, 3), pixel_scales=1.0
),
}
hyper_galaxy_visibilities_path_dict = {
("galaxies", "lens"): al.Visibilities.full(fill_value=4.0, shape_1d=(7,)),
("galaxies", "source"): al.Visibilities.full(fill_value=5.0, shape_1d=(7,)),
}
results = mock.MockResults(
hyper_galaxy_image_path_dict=hyper_galaxy_image_path_dict,
def __init__(
self,
model_image=None,
mask=None,
galaxy_images=(),
constant=None,
analysis=None,
optimizer=None,
pixelization=None,
):
self.model_image = model_image
self.unmasked_model_image = model_image
self.mask_2d = mask
self.galaxy_images = galaxy_images
self.constant = constant or af.ModelInstance()
self.variable = af.ModelMapper()
self.analysis = analysis
self.optimizer = optimizer
self.pixelization = pixelization
self.hyper_combined = MockHyperCombinedPhase()
def make_instance(all_galaxies):
instance = af.ModelInstance()
instance.galaxies = all_galaxies
return instance
def test_defaults_hyper_image_sky(self):
# noinspection PyTypeChecker
phase = phase_extensions.InversionBackgroundSkyPhase(MockPhase())
constant = af.ModelInstance()
constant.hyper_image_sky = hd.HyperImageSky()
mapper = phase.make_variable(constant)
assert isinstance(mapper.hyper_image_sky, af.PriorModel)
assert mapper.hyper_image_sky.cls == hd.HyperImageSky