Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions autofit/non_linear/analysis/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions autofit/non_linear/analysis/visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions autofit/non_linear/fitness.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]:
Expand Down
4 changes: 2 additions & 2 deletions autofit/non_linear/plot/plot_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

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__)


def skip_in_test_mode(func):
@wraps(func)
def wrapper(*args, **kwargs):
if is_test_mode():
if skip_visualization():
return
return func(*args, **kwargs)

Expand Down
4 changes: 2 additions & 2 deletions autofit/non_linear/samples/samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand Down
9 changes: 4 additions & 5 deletions autofit/non_linear/search/abstract_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down Expand Up @@ -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` /
Expand All @@ -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
)
Expand Down
4 changes: 2 additions & 2 deletions autofit/non_linear/test_mode.py
Original file line number Diff line number Diff line change
@@ -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"]
6 changes: 3 additions & 3 deletions autofit/text/text_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []

Expand Down
4 changes: 2 additions & 2 deletions test_autofit/non_linear/test_initializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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():
Expand Down
Loading