Skip to content

Commit f4d8891

Browse files
authored
Merge pull request #1155 from rhayes777/feature/jax_wrapper
Jax to Main!
2 parents 6913693 + 48384c3 commit f4d8891

126 files changed

Lines changed: 3014 additions & 1143 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@ PyAutoFit: Classy Probabilistic Programming
1717
.. |JOSS| image:: https://joss.theoj.org/papers/10.21105/joss.02550/status.svg
1818
:target: https://doi.org/10.21105/joss.02550
1919

20+
.. image:: https://www.repostatus.org/badges/latest/active.svg
21+
:target: https://www.repostatus.org/#active
22+
:alt: Project Status: Active
23+
24+
.. image:: https://img.shields.io/pypi/pyversions/autofit
25+
:target: https://pypi.org/project/autofit/
26+
:alt: Python Versions
27+
28+
.. image:: https://img.shields.io/pypi/v/autofit.svg
29+
:target: https://pypi.org/project/autofit/
30+
:alt: PyPI Version
31+
2032
|binder| |Tests| |Build| |RTD| |JOSS|
2133

2234
`Installation Guide <https://pyautofit.readthedocs.io/en/latest/installation/overview.html>`_ |

autofit/__init__.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1+
from autoconf.dictable import register_parser
2+
from . import conf
3+
4+
conf.instance.register(__file__)
5+
16
import abc
27
import pickle
3-
48
from dill import register
59

6-
from autoconf.dictable import register_parser
7-
from .non_linear.grid.grid_search import GridSearch as SearchGridSearch
8-
from . import conf
910
from . import exc
1011
from . import mock as m
12+
from .non_linear.grid.grid_search import GridSearch as SearchGridSearch
1113
from .aggregator.base import AggBase
1214
from .database.aggregator.aggregator import GridSearchAggregator
1315
from .graphical.expectation_propagation.history import EPHistory
@@ -54,6 +56,8 @@
5456
from .mapper.prior import GaussianPrior
5557
from .mapper.prior import LogGaussianPrior
5658
from .mapper.prior import LogUniformPrior
59+
from .mapper.prior import TruncatedGaussianPrior
60+
from .mapper.prior.vectorized import PriorVectorized
5761
from .mapper.prior.abstract import Prior
5862
from .mapper.prior.tuple_prior import TuplePrior
5963
from .mapper.prior import UniformPrior
@@ -136,6 +140,6 @@ def save_abc(pickler, obj):
136140
pickle._Pickler.save_type(pickler, obj)
137141

138142

139-
conf.instance.register(__file__)
143+
140144

141145
__version__ = "2025.5.10.1"

autofit/aggregator/summary/aggregate_fits.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
from enum import Enum
33
from typing import Dict, List, Union
44

5-
from astropy.table import Table
6-
from astropy.io import fits
75
from pathlib import Path
86

97
from autofit.aggregator.search_output import SearchOutput
@@ -53,7 +51,7 @@ def __init__(self, aggregator: Union[Aggregator, List[SearchOutput]]):
5351
def _hdus(
5452
result: SearchOutput,
5553
hdus: List[Enum],
56-
) -> List[fits.ImageHDU]:
54+
) -> "List[fits.ImageHDU]":
5755
"""
5856
Extract the HDUs from a given fits for a given search.
5957
@@ -68,6 +66,8 @@ def _hdus(
6866
-------
6967
The extracted HDUs.
7068
"""
69+
from astropy.io import fits
70+
7171
row = []
7272
for hdu in hdus:
7373
source = result.value(subplot_filename(hdu))
@@ -80,7 +80,7 @@ def _hdus(
8080
)
8181
return row
8282

83-
def extract_fits(self, hdus: List[Enum]) -> fits.HDUList:
83+
def extract_fits(self, hdus: List[Enum]) -> "fits.HDUList":
8484
"""
8585
Extract the HDUs from the fits files for every search in the aggregator.
8686
@@ -95,6 +95,8 @@ def extract_fits(self, hdus: List[Enum]) -> fits.HDUList:
9595
-------
9696
The extracted HDUs.
9797
"""
98+
from astropy.io import fits
99+
98100
output = [fits.PrimaryHDU()]
99101
for result in self.aggregator:
100102
output.extend(self._hdus(result, hdus))
@@ -117,6 +119,8 @@ def extract_csv(self, filename: str) -> List[Dict]:
117119
-------
118120
The extracted HDUs.
119121
"""
122+
from astropy.table import Table
123+
120124
output = []
121125
for result in self.aggregator:
122126
output.append(Table.read(result.value(filename), format="fits"))
@@ -144,6 +148,8 @@ def output_to_folder(
144148
The name of the fits file. This is the attribute of the search output that is used to name the file.
145149
OR a list of names for each HDU.
146150
"""
151+
from astropy.io import fits
152+
147153
folder.mkdir(parents=True, exist_ok=True)
148154

149155
for i, result in enumerate(self.aggregator):

autofit/config/general.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1+
jax:
2+
use_jax: false # If True, PyAutoFit uses JAX internally, whereas False uses normal Numpy.
13
analysis:
24
n_cores: 1 # The number of cores a parallelized sum of Analysis classes uses by default.
35
hpc:
46
hpc_mode: false # If True, use HPC mode, which disables GUI visualization, logging to screen and other settings which are not suited to running on a super computer.
57
iterations_per_update: 5000 # The number of iterations between every update (visualization, results output, etc) in HPC mode.
68
inversion:
79
check_reconstruction: true # If True, the inversion's reconstruction is checked to ensure the solution of a meshs's mapper is not an invalid solution where the values are all the same.
8-
reconstruction_vmax_factor: 0.5 # Plots of an Inversion's reconstruction use the reconstructed data's bright value multiplied by this factor.
9-
model:
10-
ignore_prior_limits: false # If ``True`` the limits applied to priors will be ignored, where limits set upper / lower limits. This stops PriorLimitException's from being raised.
10+
reconstruction_vmax_factor: 0.5 # Plots of an Inversion's reconstruction use the reconstructed data's bright value multiplied by this factor.
1111
output:
1212
force_pickle_overwrite: false # If True pickle files output by a search (e.g. samples.pickle) are recreated when a new model-fit is performed.
1313
force_visualize_overwrite: false # If True, visualization images output by a search (e.g. subplots of the fit) are recreated when a new model-fit is performed.

autofit/config/output.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,10 @@ start_point: true
8686
# manually after completing a successful model-fit. This will save computational run time by not computing latent
8787
# variables during a any model-fit which is unsuccessful.
8888

89-
latent_during_fit: true # Whether to output the `latent.csv`, `latent.results` and `latent_summary.json` files during the fit when it performs on-the-fly output.
89+
latent_during_fit: false # Whether to output the `latent.csv`, `latent.results` and `latent_summary.json` files during the fit when it performs on-the-fly output.
9090
latent_after_fit: true # If `latent_during_fit` is False, whether to output the `latent.csv`, `latent.results` and `latent_summary.json` files after the fit is complete.
91+
latent_draw_via_pdf : true # Whether to draw latent variable values via the PDF of every sample, which uses fewer samples to estimate latent variable errors. If False, latent variable values are drawn from every sample.
92+
latent_draw_via_pdf_size : 100 # The number of samples drawn to estimate latent variable errors if `latent_draw_via_pdf` is True.
9193
latent_csv: true # Whether to ouptut the `latent.csv` file.
9294
latent_results: true # Whether to output the `latent.results` file.
9395

autofit/config/priors/Exponential.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
centre:
2-
gaussian_limits:
2+
limits:
33
lower: -inf
44
upper: inf
55
lower_limit: 0.0
@@ -9,7 +9,7 @@ centre:
99
type: Absolute
1010
value: 20.0
1111
normalization:
12-
gaussian_limits:
12+
limits:
1313
lower: 0.0
1414
upper: inf
1515
lower_limit: 1.0e-06
@@ -19,7 +19,7 @@ normalization:
1919
type: Relative
2020
value: 0.5
2121
rate:
22-
gaussian_limits:
22+
limits:
2323
lower: 0.0
2424
upper: inf
2525
lower_limit: 0.0

autofit/config/priors/Gaussian.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
centre:
2-
gaussian_limits:
2+
limits:
33
lower: -inf
44
upper: inf
55
lower_limit: 0.0
@@ -9,7 +9,7 @@ centre:
99
type: Absolute
1010
value: 20.0
1111
normalization:
12-
gaussian_limits:
12+
limits:
1313
lower: 0.0
1414
upper: inf
1515
lower_limit: 1.0e-06
@@ -19,7 +19,7 @@ normalization:
1919
type: Relative
2020
value: 0.5
2121
sigma:
22-
gaussian_limits:
22+
limits:
2323
lower: 0.0
2424
upper: inf
2525
lower_limit: 0.0

autofit/config/priors/Gaussian2D.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
centre_0:
2-
gaussian_limits:
2+
limits:
33
lower: -inf
44
upper: inf
55
lower_limit: 0.0
@@ -9,7 +9,7 @@ centre_0:
99
type: Absolute
1010
value: 20.0
1111
centre_1:
12-
gaussian_limits:
12+
limits:
1313
lower: -inf
1414
upper: inf
1515
lower_limit: 0.0
@@ -19,7 +19,7 @@ centre_1:
1919
type: Absolute
2020
value: 20.0
2121
normalization:
22-
gaussian_limits:
22+
limits:
2323
lower: 0.0
2424
upper: inf
2525
lower_limit: 1.0e-06
@@ -29,7 +29,7 @@ normalization:
2929
type: Relative
3030
value: 0.5
3131
sigma:
32-
gaussian_limits:
32+
limits:
3333
lower: 0.0
3434
upper: inf
3535
lower_limit: 0.0

autofit/config/priors/GaussianKurtosis.yaml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
1-
GaussianPrior:
2-
lower_limit:
3-
type: Constant
4-
value: -inf
5-
upper_limit:
6-
type: Constant
7-
value: inf
81
centre:
9-
gaussian_limits:
2+
limits:
103
lower: -inf
114
upper: inf
125
lower_limit: 0.0
@@ -16,7 +9,7 @@ centre:
169
type: Absolute
1710
value: 20.0
1811
kurtosis:
19-
gaussian_limits:
12+
limits:
2013
lower: -inf
2114
upper: inf
2215
lower_limit: 0.0
@@ -26,7 +19,7 @@ kurtosis:
2619
type: Absolute
2720
value: 20.0
2821
normalization:
29-
gaussian_limits:
22+
limits:
3023
lower: 0.0
3124
upper: inf
3225
lower_limit: 1.0e-06
@@ -36,7 +29,7 @@ normalization:
3629
type: Relative
3730
value: 0.5
3831
sigma:
39-
gaussian_limits:
32+
limits:
4033
lower: 0.0
4134
upper: inf
4235
lower_limit: 0.0

autofit/config/priors/MultiLevelGaussians.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
higher_level_centre:
2-
gaussian_limits:
2+
limits:
33
lower: -inf
44
upper: inf
55
lower_limit: 0.0

0 commit comments

Comments
 (0)