Skip to content

Commit c2f0cfd

Browse files
Jammy2211Jammy2211
authored andcommitted
black
1 parent 341aba9 commit c2f0cfd

11 files changed

Lines changed: 32 additions & 37 deletions

File tree

autolens/analysis/analysis/dataset.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ class AnalysisDataset(AgAnalysisDataset, AnalysisLens):
2626
def __init__(
2727
self,
2828
dataset,
29-
positions_likelihood_list: Optional[
30-
List[PositionsLH]
31-
] = None,
29+
positions_likelihood_list: Optional[List[PositionsLH]] = None,
3230
adapt_image_maker: Optional[ag.AdaptImageMaker] = None,
3331
cosmology: ag.cosmo.LensingCosmology = ag.cosmo.Planck15(),
3432
settings_inversion: aa.SettingsInversion = None,

autolens/analysis/analysis/lens.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@
2121
class AnalysisLens:
2222
def __init__(
2323
self,
24-
positions_likelihood_list: Optional[
25-
List[PositionsLH]
26-
] = None,
24+
positions_likelihood_list: Optional[List[PositionsLH]] = None,
2725
cosmology: ag.cosmo.LensingCosmology = ag.cosmo.Planck15(),
2826
):
2927
"""

autolens/analysis/positions.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,10 @@ def output_positions_info(self, output_path: str, tracer: Tracer):
105105
with open_(path.join(output_path, "positions.info"), "a+") as f:
106106

107107
positions_fit = SourceMaxSeparation(
108-
data=self.positions, noise_map=None, tracer=tracer, plane_redshift=self.plane_redshift
108+
data=self.positions,
109+
noise_map=None,
110+
tracer=tracer,
111+
plane_redshift=self.plane_redshift,
109112
)
110113

111114
distances = positions_fit.data.distances_to_coordinate_from(
@@ -209,8 +212,7 @@ def log_likelihood_penalty_from(self, tracer: Tracer) -> Optional[float]:
209212
if not positions_fit.max_separation_within_threshold(self.threshold):
210213

211214
log_likelihood_penalty += self.log_likelihood_penalty_factor * (
212-
positions_fit.max_separation_of_plane_positions
213-
- self.threshold
215+
positions_fit.max_separation_of_plane_positions - self.threshold
214216
)
215217

216218
return log_likelihood_penalty

autolens/analysis/result.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ def source_plane_centre(self) -> aa.Grid2DIrregular:
5454
"""
5555
return self.source_plane_light_profile_centre
5656

57-
def image_plane_multiple_image_positions(self, plane_redshift : Optional[float] = None) -> aa.Grid2DIrregular:
57+
def image_plane_multiple_image_positions(
58+
self, plane_redshift: Optional[float] = None
59+
) -> aa.Grid2DIrregular:
5860
"""
5961
Backwards ray-trace the source-plane centres (see above) to the image-plane via the mass model, to determine
6062
the multiple image position of the source(s) in the image-plane.
@@ -89,7 +91,7 @@ def image_plane_multiple_image_positions(self, plane_redshift : Optional[float]
8991
return aa.Grid2DIrregular(values=multiple_images)
9092

9193
def image_plane_multiple_image_positions_for_single_image_from(
92-
self, plane_redshift : Optional[float] = None, increments: int = 20
94+
self, plane_redshift: Optional[float] = None, increments: int = 20
9395
) -> aa.Grid2DIrregular:
9496
"""
9597
If the standard point solver only locates one multiple image, finds one or more additional images, which are
@@ -149,7 +151,7 @@ def image_plane_multiple_image_positions_for_single_image_from(
149151
return aa.Grid2DIrregular(values=multiple_images)
150152

151153
logger.info(
152-
"""
154+
"""
153155
Could not find multiple images for maximum likelihood lens model, even after incrementally moving the source
154156
centre inwards to the centre of the source-plane.
155157
@@ -163,7 +165,7 @@ def positions_threshold_from(
163165
factor=1.0,
164166
minimum_threshold=None,
165167
positions: Optional[aa.Grid2DIrregular] = None,
166-
plane_redshift : Optional[float] = None,
168+
plane_redshift: Optional[float] = None,
167169
) -> float:
168170
"""
169171
Compute a new position threshold from these results corresponding to the image-plane multiple image positions
@@ -176,10 +178,10 @@ def positions_threshold_from(
176178
177179
This is used for non-linear search chaining, specifically updating the position threshold of a new model-fit
178180
using the maximum likelihood model of a previous search.
179-
181+
180182
The above behaviour assumes a single lens and single source plane, if there are multiple source planes (e.g.
181183
a double source plane lens) the input `plane_redshift_list` can be used to specify which source planea
182-
the position threshold is computed for.
184+
the position threshold is computed for.
183185
184186
Parameters
185187
----------
@@ -216,9 +218,7 @@ def positions_threshold_from(
216218
data=positions, noise_map=None, tracer=tracer, plane_redshift=plane_redshift
217219
)
218220

219-
threshold = factor * np.max(
220-
positions_fits.max_separation_of_plane_positions
221-
)
221+
threshold = factor * np.max(positions_fits.max_separation_of_plane_positions)
222222

223223
if minimum_threshold is not None:
224224
if threshold < minimum_threshold:
@@ -294,10 +294,15 @@ def positions_likelihood_from(
294294
positions = positions[distances > mass_centre_radial_distance_min]
295295

296296
threshold = self.positions_threshold_from(
297-
factor=factor, minimum_threshold=minimum_threshold, positions=positions, plane_redshift=plane_redshift
297+
factor=factor,
298+
minimum_threshold=minimum_threshold,
299+
positions=positions,
300+
plane_redshift=plane_redshift,
301+
)
302+
303+
return PositionsLH(
304+
positions=positions, threshold=threshold, plane_redshift=plane_redshift
298305
)
299-
300-
return PositionsLH(positions=positions, threshold=threshold, plane_redshift=plane_redshift)
301306

302307

303308
class ResultDataset(Result):

autolens/interferometer/model/analysis.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ class AnalysisInterferometer(AnalysisDataset):
2828
def __init__(
2929
self,
3030
dataset,
31-
positions_likelihood_list: Optional[
32-
PositionsLH
33-
] = None,
31+
positions_likelihood_list: Optional[PositionsLH] = None,
3432
adapt_image_maker: Optional[ag.AdaptImageMaker] = None,
3533
cosmology: ag.cosmo.LensingCosmology = ag.cosmo.Planck15(),
3634
settings_inversion: aa.SettingsInversion = None,

autolens/interferometer/model/visualizer.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,12 @@ def visualize_before_fit(
4040
positions_list = []
4141

4242
for positions_likelihood in analysis.positions_likelihood_list:
43-
positions_list.append(
44-
positions_likelihood.positions
45-
)
43+
positions_list.append(positions_likelihood.positions)
4644

4745
positions = ag.Grid2DIrregular(positions_list)
4846

4947
plotter_interface.image_with_positions(
50-
image=analysis.dataset.dirty_image,
51-
positions=positions
48+
image=analysis.dataset.dirty_image, positions=positions
5249
)
5350

5451
if analysis.adapt_images is not None:

autolens/lens/tracer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@ def cls_list_from(self, cls: Type) -> List:
801801

802802
return cls_list
803803

804-
def plane_index_via_redshift_from(self, redshift : float) -> Optional[int]:
804+
def plane_index_via_redshift_from(self, redshift: float) -> Optional[int]:
805805
"""
806806
Returns the index of a plane at a given redshift.
807807

autolens/point/max_separation.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ def __init__(
4242
except TypeError:
4343
plane_index = -1
4444

45-
self.plane_positions = tracer.traced_grid_2d_list_from(grid=data)[
46-
plane_index
47-
]
45+
self.plane_positions = tracer.traced_grid_2d_list_from(grid=data)[plane_index]
4846

4947
@property
5048
def furthest_separations_of_plane_positions(self) -> aa.ArrayIrregular:

test_autolens/analysis/test_positions.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ def test__check_positions_on_instantiation():
1717
# Positions input with threshold but positions are length 1.
1818

1919
with pytest.raises(exc.PositionsException):
20-
al.PositionsLH(
21-
positions=al.Grid2DIrregular([(1.0, 2.0)]), threshold=0.1
22-
)
20+
al.PositionsLH(positions=al.Grid2DIrregular([(1.0, 2.0)]), threshold=0.1)
2321

2422

2523
def test__output_positions_info():

test_autolens/analysis/test_result.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ def test__positions_likelihood_from(analysis_imaging_7x7):
253253
assert isinstance(positions_likelihood, al.PositionsLH)
254254
assert positions_likelihood.threshold == pytest.approx(0.2, 1.0e-4)
255255

256+
256257
def test__positions_likelihood_from__mass_centre_radial_distance_min(
257258
analysis_imaging_7x7,
258259
):
@@ -297,7 +298,6 @@ def test__results_include_mask__available_as_property(
297298
assert (result.mask == masked_imaging_7x7.mask).all()
298299

299300

300-
301301
def test___image_dict(analysis_imaging_7x7):
302302
galaxies = af.ModelInstance()
303303
galaxies.lens = al.Galaxy(redshift=0.5)

0 commit comments

Comments
 (0)