Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
48849a4
Merge branch 'feature/declarative_deterministic'
Oct 6, 2025
85bc594
fix delcarative thing brekaing unit tests
Oct 6, 2025
5038d4f
merge
Oct 6, 2025
e782a43
reinstate plot module
Oct 7, 2025
15dde06
fix imports
Oct 7, 2025
4293d90
try except on latent variable PDF drawingh
Oct 7, 2025
93ac19e
add Truncated Gaussian to from dict list
Oct 7, 2025
c19ca06
af.Gaussian -> af.ex.Gaussian
Oct 7, 2025
7c5e38b
fix TruncatedGaussian ids
Oct 7, 2025
9d279d1
Extend fitness API for better JAX support
Oct 8, 2025
02e576e
update fitness for more flexibility
Oct 8, 2025
74a920a
remove MPI
Oct 8, 2025
33b9871
all tests pass
Oct 8, 2025
5c347e8
err
Oct 8, 2025
b64291d
remove prints
Oct 8, 2025
5c6d71a
more fixes
Oct 14, 2025
e104303
add model centred to autofit result
Oct 16, 2025
d5d939a
'Updated version in __init__ to 2025.10.16.1
rhayes777 Oct 16, 2025
89d6774
'Updated version in __init__ to 2025.10.16.2
rhayes777 Oct 16, 2025
c67705e
quick update visualization works nice
Oct 19, 2025
2a5f5d7
update text_util to be used for quick update
Oct 19, 2025
d92f4ea
implementation seems to work, now to fix unit tests
Oct 19, 2025
14f58ac
fremove Maximum Log Posterior
Oct 19, 2025
950b333
ierations per update i configs
Oct 19, 2025
44dabba
remove analysos n cores
Oct 19, 2025
cc1a2a1
more iterations update fixes
Oct 19, 2025
0202b6e
add unit tests pass
Oct 19, 2025
fb76039
remove print
Oct 19, 2025
941d405
Merge pull request #1159 from rhayes777/feature/quick_update
Jammy2211 Oct 19, 2025
ddf4916
minor edits
Oct 19, 2025
99dcbd3
float conversion
Oct 19, 2025
eb44458
simpify update message
Oct 19, 2025
416bf1a
disable graph visualization
Oct 19, 2025
00087f7
enviroment variable JAX fast time check
Oct 20, 2025
13abefd
final fixes
Oct 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion autofit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@
from .non_linear.result import ResultsCollection
from .non_linear.settings import SettingsSearch
from .non_linear.samples.pdf import marginalize
from .example.model import Gaussian, Exponential
from .text import formatter
from .text import samples_text
from .visualise import VisualiseGraph
Expand Down Expand Up @@ -129,6 +128,7 @@
"LogUniform",
"Gaussian",
"LogGaussian",
"TruncatedGaussian",
"compound",
"Constant",
):
Expand Down
2 changes: 1 addition & 1 deletion autofit/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
def make_model_gaussian_x1():

return af.Model(
af.Gaussian
af.ex.Gaussian
)


Expand Down
1 change: 1 addition & 0 deletions autofit/mapper/prior/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ def from_dict(
)
if id_ is not None:
loaded_ids[id_] = prior

return prior

def dict(self) -> dict:
Expand Down
4 changes: 1 addition & 3 deletions autofit/messages/truncated_normal.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,11 @@ def __init__(
----------
mean
The mean (μ) of the normal distribution.

sigma
The standard deviation (σ) of the distribution. Must be non-negative.

log_norm
An additive constant to the log probability of the message. Used internally for message-passing normalization.
Default is 0.0.

id_
An optional unique identifier used to track the message in larger probabilistic graphs or models.
"""
Expand All @@ -96,6 +93,7 @@ def __init__(
log_norm=log_norm,
id_=id_,
)

self.mean, self.sigma, self.lower_limit, self.upper_limit = self.parameters

def cdf(self, x: Union[float, np.ndarray]) -> Union[float, np.ndarray]:
Expand Down
3 changes: 3 additions & 0 deletions autofit/non_linear/plot/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
from autofit.non_linear.plot.samples_plotters import SamplesPlotter
from autofit.non_linear.plot.mcmc_plotters import MCMCPlotter
from autofit.non_linear.plot.mle_plotters import MLEPlotter
from autofit.non_linear.plot.nest_plotters import NestPlotter
from autofit.non_linear.plot.output import Output
9 changes: 8 additions & 1 deletion autofit/non_linear/search/abstract_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,14 @@ def perform_update(

logger.info(f"Creating latent samples by drawing {total_draws} from the PDF.")

latent_samples = samples.samples_drawn_randomly_via_pdf_from(total_draws=total_draws)
try:
latent_samples = samples.samples_drawn_randomly_via_pdf_from(total_draws=total_draws)
except AttributeError:
latent_samples = samples_save
logger.info(
"Drawing via PDF not available for this search, "
"using all samples above the samples weight threshold instead."
"")

else:

Expand Down
5 changes: 5 additions & 0 deletions autofit/plot/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from autofit.non_linear.plot.samples_plotters import SamplesPlotter
from autofit.non_linear.plot.mcmc_plotters import MCMCPlotter
from autofit.non_linear.plot.mle_plotters import MLEPlotter
from autofit.non_linear.plot.nest_plotters import NestPlotter
from autofit.non_linear.plot.output import Output
10 changes: 5 additions & 5 deletions test_autofit/aggregator/test_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ def test_without(directory):
aggregator = Aggregator.from_directory(directory)
model_list = [agg.model for agg in aggregator]

assert any([getattr(model, "cls", False) is af.Gaussian for model in model_list])
assert any([getattr(model, "cls", False) is af.ex.Gaussian for model in model_list])


def test_with():

aggregator = Aggregator.from_directory(
Path(__file__).parent,
reference={"": get_class_path(af.Exponential)},
reference={"": get_class_path(af.ex.Exponential)},
)
output_list = list(aggregator)
model_list = [output.model for output in output_list]
assert any([getattr(model, "cls", False) is af.Exponential for model in model_list])
assert any([getattr(model, "cls", False) is af.ex.Exponential for model in model_list])

@pytest.fixture(name="database_path")
def database_path(output_directory):
Expand All @@ -49,7 +49,7 @@ def database_aggregator(
)
aggregator.add_directory(
directory,
reference={"": get_class_path(af.Exponential)},
reference={"": get_class_path(af.ex.Exponential)},
completed_only=True,
)

Expand All @@ -59,7 +59,7 @@ def database_aggregator(
def test_database(database_aggregator):
fit = list(database_aggregator)[0]
model = fit.model
assert model.cls is af.Exponential
assert model.cls is af.ex.Exponential


@pytest.fixture(name="info")
Expand Down
4 changes: 2 additions & 2 deletions test_autofit/analysis/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Result(af.mock.MockResult):

class Analysis(af.Analysis):
def log_likelihood_function(self, instance):
return 1.0 if isinstance(instance, af.Gaussian) else 0.0
return 1.0 if isinstance(instance, af.ex.Gaussian) else 0.0

def make_result(self, samples):
return Result(
Expand All @@ -29,4 +29,4 @@ def analysis_class():

@pytest.fixture(name="model")
def make_model():
return af.Model(af.Gaussian)
return af.Model(af.ex.Gaussian)
4 changes: 2 additions & 2 deletions test_autofit/analysis/test_latent_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def make_latent_samples():
analysis = Analysis()
return analysis.compute_latent_samples(
SamplesPDF(
model=af.Model(af.Gaussian),
model=af.Model(af.ex.Gaussian),
sample_list=[
af.Sample(
log_likelihood=1.0,
Expand Down Expand Up @@ -123,7 +123,7 @@ def test_complex_model():
analysis = ComplexAnalysis()
latent_samples = analysis.compute_latent_samples(
SamplesPDF(
model=af.Model(af.Gaussian),
model=af.Model(af.ex.Gaussian),
sample_list=[
af.Sample(
log_likelihood=1.0,
Expand Down
2 changes: 1 addition & 1 deletion test_autofit/analysis/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def modify_after_fit(self, paths, model, result):


def test_result_type():
model = af.Model(af.Gaussian)
model = af.Model(af.ex.Gaussian)

analysis = MyAnalysis().with_model(model)

Expand Down
32 changes: 16 additions & 16 deletions test_autofit/database/identifier/test_identifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ def test_missing_field():

def test_change_class():
gaussian_0 = af.Model(
af.Gaussian, normalization=af.UniformPrior(lower_limit=1e-6, upper_limit=1e6)
af.ex.Gaussian, normalization=af.UniformPrior(lower_limit=1e-6, upper_limit=1e6)
)
gaussian_1 = af.Model(
af.Gaussian, normalization=af.LogUniformPrior(lower_limit=1e-6, upper_limit=1e6)
af.ex.Gaussian, normalization=af.LogUniformPrior(lower_limit=1e-6, upper_limit=1e6)
)

assert Identifier(gaussian_0) != Identifier(gaussian_1)
Expand Down Expand Up @@ -143,14 +143,14 @@ def test_identifier_fields():
def test_unique_tag():
search = af.m.MockSearch()

search.fit(model=af.Model(af.Gaussian), analysis=af.m.MockAnalysis())
search.fit(model=af.Model(af.ex.Gaussian), analysis=af.m.MockAnalysis())

identifier = search.paths.identifier

search = af.m.MockSearch(unique_tag="dataset")

search.fit(
model=af.Model(af.Gaussian),
model=af.Model(af.ex.Gaussian),
analysis=af.m.MockAnalysis(),
)

Expand All @@ -165,42 +165,42 @@ def test_prior():


def test_model():
identifier = af.Model(af.Gaussian, centre=af.UniformPrior()).identifier
assert identifier == af.Model(af.Gaussian, centre=af.UniformPrior()).identifier
identifier = af.Model(af.ex.Gaussian, centre=af.UniformPrior()).identifier
assert identifier == af.Model(af.ex.Gaussian, centre=af.UniformPrior()).identifier
assert (
identifier
!= af.Model(af.Gaussian, centre=af.UniformPrior(upper_limit=0.5)).identifier
!= af.Model(af.ex.Gaussian, centre=af.UniformPrior(upper_limit=0.5)).identifier
)


def test_collection():
identifier = af.Collection(
gaussian=af.Model(af.Gaussian, centre=af.UniformPrior())
gaussian=af.Model(af.ex.Gaussian, centre=af.UniformPrior())
).identifier
assert (
identifier
== af.Collection(
gaussian=af.Model(af.Gaussian, centre=af.UniformPrior())
gaussian=af.Model(af.ex.Gaussian, centre=af.UniformPrior())
).identifier
)
assert (
identifier
!= af.Collection(
gaussian=af.Model(af.Gaussian, centre=af.UniformPrior(upper_limit=0.5))
gaussian=af.Model(af.ex.Gaussian, centre=af.UniformPrior(upper_limit=0.5))
).identifier
)


def test_instance():
identifier = af.Collection(gaussian=af.Gaussian()).identifier
assert identifier == af.Collection(gaussian=af.Gaussian()).identifier
assert identifier != af.Collection(gaussian=af.Gaussian(centre=0.5)).identifier
identifier = af.Collection(gaussian=af.ex.Gaussian()).identifier
assert identifier == af.Collection(gaussian=af.ex.Gaussian()).identifier
assert identifier != af.Collection(gaussian=af.ex.Gaussian(centre=0.5)).identifier


def test__identifier_description():
model = af.Collection(
gaussian=af.Model(
af.Gaussian,
af.ex.Gaussian,
centre=af.UniformPrior(lower_limit=0.0, upper_limit=1.0),
normalization=af.LogUniformPrior(lower_limit=0.001, upper_limit=0.01),
sigma=af.GaussianPrior(
Expand Down Expand Up @@ -270,7 +270,7 @@ def test__identifier_description():
def test__identifier_description__after_model_and_instance():
model = af.Collection(
gaussian=af.Model(
af.Gaussian,
af.ex.Gaussian,
centre=af.UniformPrior(lower_limit=0.0, upper_limit=1.0),
normalization=af.LogUniformPrior(lower_limit=0.001, upper_limit=0.01),
sigma=af.GaussianPrior(
Expand Down Expand Up @@ -315,7 +315,7 @@ def test__identifier_description__after_model_and_instance():
def test__identifier_description__after_take_attributes():
model = af.Collection(
gaussian=af.Model(
af.Gaussian,
af.ex.Gaussian,
centre=af.UniformPrior(lower_limit=0.0, upper_limit=1.0),
normalization=af.LogUniformPrior(lower_limit=0.001, upper_limit=0.01),
sigma=af.GaussianPrior(
Expand Down
2 changes: 1 addition & 1 deletion test_autofit/database/paths/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def make_paths(session):
session
)
paths.model = af.Model(
af.Gaussian
af.ex.Gaussian
)
assert paths.is_complete is False
return paths
2 changes: 1 addition & 1 deletion test_autofit/database/paths/test_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def test_completion(


def test_object(paths):
gaussian = af.Gaussian(
gaussian = af.ex.Gaussian(
normalization=2.1
)

Expand Down
4 changes: 2 additions & 2 deletions test_autofit/database/paths/test_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def save_samples(
):
samples =af.m.MockSamples(
model=af.Model(
af.Gaussian
af.ex.Gaussian
),

)
Expand Down Expand Up @@ -57,7 +57,7 @@ def test_load_samples(
):
samples = paths._load_samples()

assert samples.model.cls is af.Gaussian
assert samples.model.cls is af.ex.Gaussian

sample, = samples.sample_list
assert sample.weight == 0.5
2 changes: 1 addition & 1 deletion test_autofit/database/paths/test_switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def make_search(session):
)
def make_model():
return af.Model(
af.Gaussian
af.ex.Gaussian
)


Expand Down
10 changes: 5 additions & 5 deletions test_autofit/database/query/internal/test_construction.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ def test_simple(aggregator):


def test_and(aggregator):
construction = ((aggregator.model.centre == af.Gaussian) & (aggregator.model.centre.x == 0))
construction = ((aggregator.model.centre == af.ex.Gaussian) & (aggregator.model.centre.x == 0))
assert construction.query == q.Q(
"centre",
q.And(
q.T(af.Gaussian),
q.T(af.ex.Gaussian),
q.Q(
"x",
q.V(
Expand All @@ -23,11 +23,11 @@ def test_and(aggregator):


def test_or(aggregator):
construction = ((aggregator.model.centre == af.Gaussian) | (aggregator.model.centre.x == 0))
construction = ((aggregator.model.centre == af.ex.Gaussian) | (aggregator.model.centre.x == 0))
assert construction.query == q.Q(
"centre",
q.Or(
q.T(af.Gaussian),
q.T(af.ex.Gaussian),
q.Q(
"x",
q.V(
Expand All @@ -51,7 +51,7 @@ def test_third_level(aggregator):


def test_with_type(aggregator):
assert (aggregator.model.centre == af.Gaussian).query == q.Q("centre", q.T(af.Gaussian)).query
assert (aggregator.model.centre == af.ex.Gaussian).query == q.Q("centre", q.T(af.ex.Gaussian)).query


def test_with_string(aggregator):
Expand Down
4 changes: 2 additions & 2 deletions test_autofit/database/query/query/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
def make_gaussian_1():
return db.Fit(
id="gaussian_1",
instance=af.Gaussian(
instance=af.ex.Gaussian(
centre=1
),
info={"info": 1},
Expand All @@ -26,7 +26,7 @@ def make_gaussian_1():
def make_gaussian_2():
return db.Fit(
id="gaussian_2",
instance=af.Gaussian(
instance=af.ex.Gaussian(
centre=2
),
info={"info": 2},
Expand Down
4 changes: 2 additions & 2 deletions test_autofit/database/query/query/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def test_embedded_query(
model_1 = db.Fit(
id="model_1",
instance=af.Collection(
gaussian=af.Gaussian(
gaussian=af.ex.Gaussian(
centre=1
)
),
Expand All @@ -18,7 +18,7 @@ def test_embedded_query(
model_2 = db.Fit(
id="model_2",
instance=af.Collection(
gaussian=af.Gaussian(
gaussian=af.ex.Gaussian(
centre=2
)
),
Expand Down
2 changes: 1 addition & 1 deletion test_autofit/database/query/query/test_order_by.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def make_gaussian_0(
):
gaussian_0 = db.Fit(
id="gaussian_0",
instance=af.Gaussian(
instance=af.ex.Gaussian(
centre=1
),
info={"info": 1},
Expand Down
Loading
Loading