diff --git a/autofit/non_linear/analysis/analysis.py b/autofit/non_linear/analysis/analysis.py index 572acab7e..a6d161c40 100644 --- a/autofit/non_linear/analysis/analysis.py +++ b/autofit/non_linear/analysis/analysis.py @@ -328,9 +328,9 @@ def print_vram_use(self, model, batch_size : int) -> str: batch_size The batch size to profile, which is the number of model evaluations JAX will perform simultaneously. """ - from autofit.non_linear.test_mode import test_mode_level + from autofit.non_linear.test_mode import skip_fit_output - if test_mode_level() >= 2: + if skip_fit_output(): return if not self._use_jax: diff --git a/autofit/non_linear/analysis/visualize.py b/autofit/non_linear/analysis/visualize.py index 4c52b76b3..0e2ca5fab 100644 --- a/autofit/non_linear/analysis/visualize.py +++ b/autofit/non_linear/analysis/visualize.py @@ -6,7 +6,7 @@ from autofit.mapper.prior_model.abstract import AbstractPriorModel from autofit.non_linear.paths.database import DatabasePaths from autofit.non_linear.paths.null import NullPaths -from autofit.non_linear.test_mode import is_test_mode +from autofit.non_linear.test_mode import skip_visualization class Visualizer: @@ -41,7 +41,7 @@ def should_visualize( A bool determining whether visualization should be performed or not. """ - if is_test_mode(): + if skip_visualization(): return False if isinstance(paths, DatabasePaths) or isinstance(paths, NullPaths): diff --git a/autofit/non_linear/fitness.py b/autofit/non_linear/fitness.py index ebce1ce3a..c36800fc5 100644 --- a/autofit/non_linear/fitness.py +++ b/autofit/non_linear/fitness.py @@ -456,8 +456,8 @@ def check_log_likelihood(self, fitness): """ import numpy as np - from autofit.non_linear.test_mode import is_test_mode - if is_test_mode(): + from autofit.non_linear.test_mode import skip_fit_output + if skip_fit_output(): return if not conf.instance["general"]["test"]["check_likelihood_function"]: diff --git a/autofit/non_linear/plot/plot_util.py b/autofit/non_linear/plot/plot_util.py index 959dac1c7..0670ca68d 100644 --- a/autofit/non_linear/plot/plot_util.py +++ b/autofit/non_linear/plot/plot_util.py @@ -5,7 +5,7 @@ import numpy as np -from autofit.non_linear.test_mode import is_test_mode +from autofit.non_linear.test_mode import skip_visualization logger = logging.getLogger(__name__) @@ -13,7 +13,7 @@ def skip_in_test_mode(func): @wraps(func) def wrapper(*args, **kwargs): - if is_test_mode(): + if skip_visualization(): return return func(*args, **kwargs) diff --git a/autofit/non_linear/samples/samples.py b/autofit/non_linear/samples/samples.py index 876589647..c39d7f5a4 100644 --- a/autofit/non_linear/samples/samples.py +++ b/autofit/non_linear/samples/samples.py @@ -13,7 +13,7 @@ from autoconf.class_path import get_class_path from autofit import exc from autofit.mapper.model import ModelInstance -from autofit.non_linear.test_mode import is_test_mode +from autofit.non_linear.test_mode import skip_checks from autofit.mapper.prior_model.abstract import AbstractPriorModel from autofit.non_linear.samples.sample import Sample @@ -379,7 +379,7 @@ def samples_above_weight_threshold_from( if weight_threshold is None: weight_threshold = conf.instance["output"]["samples_weight_threshold"] - if is_test_mode(): + if skip_checks(): weight_threshold = None if weight_threshold is None: diff --git a/autofit/non_linear/search/abstract_search.py b/autofit/non_linear/search/abstract_search.py index c9de25b7c..d7c0f91d0 100644 --- a/autofit/non_linear/search/abstract_search.py +++ b/autofit/non_linear/search/abstract_search.py @@ -49,7 +49,7 @@ from autofit.graphical.expectation_propagation import AbstractFactorOptimiser from autofit.non_linear.fitness import get_timeout_seconds -from autofit.non_linear.test_mode import is_test_mode, test_mode_level +from autofit.non_linear.test_mode import is_test_mode, test_mode_level, skip_fit_output logger = logging.getLogger(__name__) @@ -497,15 +497,14 @@ class represented by model M and gives a score for their fitness. analysis = analysis.modify_before_fit(paths=self.paths, model=model) model.unfreeze() - mode = test_mode_level() - if mode < 2: + if not skip_fit_output(): self.pre_fit_output( analysis=analysis, model=model, info=info, ) else: - # Bypass mode still needs the metadata + identifier files written + # Skip mode still needs the metadata + identifier files written # so downstream aggregator scraping can discover the search # directory. `save_all` is lightweight (a handful of JSON dumps) # and skips the expensive `analysis.save_attributes` / @@ -527,7 +526,7 @@ class represented by model M and gives a score for their fitness. model=model, ) - if mode < 2: + if not skip_fit_output(): analysis = analysis.modify_after_fit( paths=self.paths, model=model, result=result ) diff --git a/autofit/non_linear/test_mode.py b/autofit/non_linear/test_mode.py index e824833b6..7c58385c0 100644 --- a/autofit/non_linear/test_mode.py +++ b/autofit/non_linear/test_mode.py @@ -1,3 +1,3 @@ -from autoconf.test_mode import test_mode_level, is_test_mode +from autoconf.test_mode import test_mode_level, is_test_mode, skip_fit_output, skip_visualization, skip_checks -__all__ = ["test_mode_level", "is_test_mode"] +__all__ = ["test_mode_level", "is_test_mode", "skip_fit_output", "skip_visualization", "skip_checks"] diff --git a/autofit/text/text_util.py b/autofit/text/text_util.py index 5f2945d90..c0893dcbf 100644 --- a/autofit/text/text_util.py +++ b/autofit/text/text_util.py @@ -55,10 +55,10 @@ def result_info_from(samples) -> str: Output the full model.results file, which include the most-likely model, most-probable model at 1 and 3 sigma confidence and information on the maximum log likelihood. """ - from autofit.non_linear.test_mode import test_mode_level + from autofit.non_linear.test_mode import skip_fit_output - if test_mode_level() >= 2: - return "[test mode — result info skipped]" + if skip_fit_output(): + return "[fit output skipped — PYAUTO_SKIP_FIT_OUTPUT=1]" results = [] diff --git a/test_autofit/non_linear/test_initializer.py b/test_autofit/non_linear/test_initializer.py index 313e07161..8038416d9 100644 --- a/test_autofit/non_linear/test_initializer.py +++ b/test_autofit/non_linear/test_initializer.py @@ -80,7 +80,7 @@ def test__priors__samples_from_model__raise_exception_if_all_likelihoods_identic def test__priors__samples_in_test_mode(): - os.environ["PYAUTOFIT_TEST_MODE"] = "1" + os.environ["PYAUTO_TEST_MODE"] = "1" model = af.Model(af.m.MockClassx4) model.one = af.UniformPrior(lower_limit=0.099, upper_limit=0.101) @@ -121,7 +121,7 @@ def test__priors__samples_in_test_mode(): assert figure_of_merit_list == [-1.0e99, -1.0e100] - os.environ["PYAUTOFIT_TEST_MODE"] = "0" + os.environ["PYAUTO_TEST_MODE"] = "0" def test__ball__samples_sample_centre_of_priors():