Skip to content

Commit 46327f4

Browse files
committed
release v0.3.0
1 parent b68064e commit 46327f4

33 files changed

Lines changed: 211 additions & 188 deletions

autoarray/conf.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
from copy import deepcopy
44

55

6+
def get_matplotlib_backend():
7+
try:
8+
return instance.visualize.get("figures", "backend", str)
9+
except Exception:
10+
return "TKAgg"
11+
12+
613
def family(current_class):
714
yield current_class
815
for next_class in current_class.__bases__:

autoarray/dataset/imaging.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,9 @@ def simulate(
732732
)
733733
else:
734734
noise_map = arrays.Array.full(
735-
fill_value=noise_if_add_noise_false, shape_2d=image.shape_2d, pixel_scales=image.pixel_scales
735+
fill_value=noise_if_add_noise_false,
736+
shape_2d=image.shape_2d,
737+
pixel_scales=image.pixel_scales,
736738
)
737739
noise_realization = None
738740

autoarray/decorator_util.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,14 @@
1313
@numba.jit(nopython=True, cache=False, parallel=True)
1414
"""
1515

16-
nopython = conf.instance.general.get("numba", "nopython", bool)
17-
cache = conf.instance.general.get("numba", "cache", bool)
18-
parallel = conf.instance.general.get("numba", "parallel", bool)
16+
try:
17+
nopython = conf.instance.general.get("numba", "nopython", bool)
18+
cache = conf.instance.general.get("numba", "cache", bool)
19+
parallel = conf.instance.general.get("numba", "parallel", bool)
20+
except Exception:
21+
nopython = True
22+
cache = True
23+
parallel = False
1924

2025

2126
def jit(nopython=nopython, cache=cache, parallel=parallel):

autoarray/exc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ class InversionException(Exception):
3535

3636

3737
class PlottingException(Exception):
38-
pass
38+
pass

autoarray/fit/fit.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@
33
from autoarray.masked import masked_dataset as md
44
from autoarray.util import fit_util
55

6+
67
def fit_masked_dataset(masked_dataset, model_data, inversion=None):
7-
return fit(masked_dataset=masked_dataset, model_data=model_data, inversion=inversion)
8+
return fit(
9+
masked_dataset=masked_dataset, model_data=model_data, inversion=inversion
10+
)
11+
812

913
def fit(masked_dataset, model_data, inversion=None):
1014
if isinstance(masked_dataset, md.MaskedImaging):

autoarray/mask/mask.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,15 @@ def elliptical_annular(
373373
)
374374

375375
@classmethod
376-
def from_fits(cls, file_path, pixel_scales, hdu=0, sub_size=1, origin=(0.0, 0.0), resized_mask_shape=None):
376+
def from_fits(
377+
cls,
378+
file_path,
379+
pixel_scales,
380+
hdu=0,
381+
sub_size=1,
382+
origin=(0.0, 0.0),
383+
resized_mask_shape=None,
384+
):
377385
"""
378386
Loads the image from a .fits file.
379387
@@ -400,7 +408,9 @@ def from_fits(cls, file_path, pixel_scales, hdu=0, sub_size=1, origin=(0.0, 0.0)
400408

401409
if resized_mask_shape is not None:
402410

403-
mask = mask.mapping.resized_mask_from_new_shape(new_shape=resized_mask_shape)
411+
mask = mask.mapping.resized_mask_from_new_shape(
412+
new_shape=resized_mask_shape
413+
)
404414

405415
return mask
406416

autoarray/plotters/array_plotters.py

Lines changed: 20 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
from autoarray import exc
33
import matplotlib
44

5-
backend = conf.instance.visualize.get("figures", "backend", str)
5+
backend = conf.get_matplotlib_backend()
6+
67
matplotlib.use(backend)
78
import matplotlib.pyplot as plt
89
import matplotlib.colors as colors
@@ -203,30 +204,13 @@ def plot_array(
203204
cb_tick_values=cb_tick_values,
204205
cb_tick_labels=cb_tick_labels,
205206
)
206-
plot_origin(
207-
array=array,
208-
include_origin=include_origin,
209-
)
210-
plot_mask(
211-
mask=mask, pointsize=mask_pointsize
212-
)
207+
plot_origin(array=array, include_origin=include_origin)
208+
plot_mask(mask=mask, pointsize=mask_pointsize)
213209
plotter_util.plot_lines(line_lists=lines)
214-
plot_border(
215-
mask=mask,
216-
include_border=include_border,
217-
pointsize=border_pointsize,
218-
)
219-
plot_points(
220-
points=points,
221-
pointsize=point_pointsize,
222-
)
223-
plot_grid(
224-
grid=grid,
225-
pointsize=grid_pointsize,
226-
)
227-
plot_centres(
228-
centres=centres,
229-
)
210+
plot_border(mask=mask, include_border=include_border, pointsize=border_pointsize)
211+
plot_points(points=points, pointsize=point_pointsize)
212+
plot_grid(grid=grid, pointsize=grid_pointsize)
213+
plot_centres(centres=centres)
230214
plotter_util.output_figure(
231215
array,
232216
as_subplot=as_subplot,
@@ -306,8 +290,14 @@ def plot_figure(
306290
)
307291

308292
plt.imshow(array.in_2d, aspect=aspect, cmap=cmap, norm=norm_scale, extent=extent)
309-
plotter_util.set_yxticks(array=array, extent=extent, use_scaled_units=use_scaled_units,
310-
unit_conversion_factor=unit_conversion_factor, xticks_manual=xticks_manual, yticks_manual=yticks_manual)
293+
plotter_util.set_yxticks(
294+
array=array,
295+
extent=extent,
296+
use_scaled_units=use_scaled_units,
297+
unit_conversion_factor=unit_conversion_factor,
298+
xticks_manual=xticks_manual,
299+
yticks_manual=yticks_manual,
300+
)
311301

312302
return fig
313303

@@ -416,9 +406,8 @@ def plot_centres(centres):
416406
color = next(colors)
417407
for centre in centres_of_galaxy:
418408

419-
plt.scatter(
420-
y=centre[0], x=centre[1], s=300, c=color, marker="x"
421-
)
409+
plt.scatter(y=centre[0], x=centre[1], s=300, c=color, marker="x")
410+
422411

423412
def plot_mask(mask, pointsize):
424413
"""Plot the mask of the array on the figure.
@@ -503,9 +492,7 @@ def plot_points(points, pointsize):
503492

504493
if points is not None:
505494

506-
points = list(
507-
map(lambda position_set: np.asarray(position_set), points)
508-
)
495+
points = list(map(lambda position_set: np.asarray(position_set), points))
509496
point_colors = itertools.cycle(["m", "y", "r", "w", "c", "b", "g", "k"])
510497
for point_set in points:
511498

@@ -536,8 +523,5 @@ def plot_grid(grid, pointsize):
536523
if grid is not None:
537524

538525
plt.scatter(
539-
y=np.asarray(grid[:, 0]),
540-
x=np.asarray(grid[:, 1]),
541-
s=pointsize,
542-
c="k",
526+
y=np.asarray(grid[:, 0]), x=np.asarray(grid[:, 1]), s=pointsize, c="k"
543527
)

autoarray/plotters/fit_imaging_plotters.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import matplotlib
22
from autoarray import conf
33

4-
backend = conf.instance.visualize.get("figures", "backend", str)
4+
backend = conf.get_matplotlib_backend()
55
matplotlib.use(backend)
66
from matplotlib import pyplot as plt
77

@@ -432,6 +432,7 @@ def individuals(
432432
output_format=output_format,
433433
)
434434

435+
435436
def image(
436437
fit,
437438
mask=None,
@@ -520,8 +521,8 @@ def noise_map(
520521
mask=None,
521522
points=None,
522523
as_subplot=False,
523-
use_scaled_units=True,
524-
unit_conversion_factor=None,
524+
use_scaled_units=True,
525+
unit_conversion_factor=None,
525526
unit_label="scaled",
526527
figsize=(7, 7),
527528
aspect="square",
@@ -597,8 +598,8 @@ def signal_to_noise_map(
597598
mask=None,
598599
points=None,
599600
as_subplot=False,
600-
use_scaled_units=True,
601-
unit_conversion_factor=None,
601+
use_scaled_units=True,
602+
unit_conversion_factor=None,
602603
unit_label="scaled",
603604
figsize=(7, 7),
604605
aspect="square",
@@ -675,8 +676,8 @@ def model_image(
675676
lines=None,
676677
points=None,
677678
as_subplot=False,
678-
use_scaled_units=True,
679-
unit_conversion_factor=None,
679+
use_scaled_units=True,
680+
unit_conversion_factor=None,
680681
unit_label="scaled",
681682
figsize=(7, 7),
682683
aspect="square",
@@ -753,8 +754,8 @@ def residual_map(
753754
mask=None,
754755
points=None,
755756
as_subplot=False,
756-
use_scaled_units=True,
757-
unit_conversion_factor=None,
757+
use_scaled_units=True,
758+
unit_conversion_factor=None,
758759
unit_label="scaled",
759760
figsize=(7, 7),
760761
aspect="square",
@@ -830,8 +831,8 @@ def normalized_residual_map(
830831
mask=None,
831832
points=None,
832833
as_subplot=False,
833-
use_scaled_units=True,
834-
unit_conversion_factor=None,
834+
use_scaled_units=True,
835+
unit_conversion_factor=None,
835836
unit_label="scaled",
836837
figsize=(7, 7),
837838
aspect="square",
@@ -907,8 +908,8 @@ def chi_squared_map(
907908
mask=None,
908909
points=None,
909910
as_subplot=False,
910-
use_scaled_units=True,
911-
unit_conversion_factor=None,
911+
use_scaled_units=True,
912+
unit_conversion_factor=None,
912913
unit_label="scaled",
913914
figsize=(7, 7),
914915
aspect="square",

autoarray/plotters/fit_interferometer_plotters.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
from autoarray import conf
22
import matplotlib
33

4-
backend = conf.instance.visualize.get("figures", "backend", str)
4+
backend = conf.get_matplotlib_backend()
55
matplotlib.use(backend)
66
from matplotlib import pyplot as plt
77

88
from autoarray.plotters import grid_plotters, inversion_plotters, plotter_util
99

1010

11-
1211
def subplot(
1312
fit,
1413
unit_conversion_factor=None,

autoarray/plotters/grid_plotters.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from autoarray import conf
22
import matplotlib
33

4-
backend = conf.instance.visualize.get("figures", "backend", str)
4+
backend = conf.get_matplotlib_backend()
55
matplotlib.use(backend)
66
from matplotlib import pyplot as plt
77
import numpy as np
@@ -119,8 +119,14 @@ def plot_grid(
119119
symmetric_around_centre=symmetric_around_centre,
120120
)
121121

122-
plotter_util.set_yxticks(array=None, extent=grid.extent, use_scaled_units=True,
123-
unit_conversion_factor=unit_conversion_factor, xticks_manual=None, yticks_manual=None)
122+
plotter_util.set_yxticks(
123+
array=None,
124+
extent=grid.extent,
125+
use_scaled_units=True,
126+
unit_conversion_factor=unit_conversion_factor,
127+
xticks_manual=None,
128+
yticks_manual=None,
129+
)
124130

125131
plot_points(grid=grid, points=points, pointcolor=pointcolor)
126132
plotter_util.plot_lines(line_lists=lines)

0 commit comments

Comments
 (0)