Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
187 commits
Select commit Hold shift + click to select a range
ac570e8
fixed test
rhayes777 Jul 1, 2024
10ad4f9
creating an Array model
rhayes777 Jul 1, 2024
2588854
instance from prior medians for special case of 2d array
rhayes777 Jul 1, 2024
f9e4820
generalised instance for method
rhayes777 Jul 1, 2024
66d055e
use set and get item to simplify implementation
rhayes777 Jul 1, 2024
08f8a73
test modification
rhayes777 Jul 1, 2024
a0f0b87
modifying values + fix
rhayes777 Jul 1, 2024
dcc1195
more testing
rhayes777 Jul 1, 2024
f5116ab
array from dict
rhayes777 Jul 1, 2024
fc30f86
testing complex dict
rhayes777 Jul 1, 2024
7a50b5a
properly handling from dict
rhayes777 Jul 1, 2024
718fed9
docs and typws
rhayes777 Jul 1, 2024
00ba187
test 1d array
rhayes777 Jul 1, 2024
df708b7
modifying values on 1d arrays
rhayes777 Jul 1, 2024
5353631
tree flatten and unflatten for pytrees (jax)
rhayes777 Jul 8, 2024
fd44f53
array prior passing
rhayes777 Jul 8, 2024
ed5c582
docs
rhayes777 Jul 8, 2024
f04c56a
fix test
rhayes777 Jul 22, 2024
2375966
readd model to samples summary when aggregating in database
rhayes777 Jul 22, 2024
8a9b6a7
test
rhayes777 Jul 22, 2024
34e91f1
retain model in summary JSON so aggregator features work
rhayes777 Jul 22, 2024
a468317
Merge pull request #1024 from rhayes777/feature/samples_summary_model
Jammy2211 Jul 23, 2024
e88af1f
merge main
Jammy2211 Jul 23, 2024
b3ad3eb
model cookbook doc
Jammy2211 Jul 23, 2024
526f4c8
docs
Jammy2211 Jul 23, 2024
b7b9472
physical values added to SensitivityResult
Jammy2211 Jul 23, 2024
2013c05
x0 input supported
Jammy2211 Jul 24, 2024
355af89
Merge pull request #1021 from rhayes777/feature/prior_array
Jammy2211 Jul 26, 2024
c675cd7
Merge branch 'main' into feature/lbfgs
Jammy2211 Jul 26, 2024
9052e96
added history storage to fitness, enabling MLE plot
Jammy2211 Jul 26, 2024
246ce9b
imrpvoed visuyalization
Jammy2211 Jul 26, 2024
968bdd1
MLE plotting now works
Jammy2211 Jul 26, 2024
5672d72
split LBFGS into LBFGS and BFGS
Jammy2211 Jul 26, 2024
52808e5
added BFGS to config
Jammy2211 Jul 26, 2024
ee45a3e
SpecificRangeInitializer -> InitializerParamBounds
Jammy2211 Jul 31, 2024
7549183
docstring
Jammy2211 Jul 31, 2024
46a893c
initializer tested
Jammy2211 Jul 31, 2024
dab40f0
remove manual input of x0 for LBFGS
Jammy2211 Jul 31, 2024
505c84d
added info from model to param bounds
Jammy2211 Jul 31, 2024
cc63811
info display improved
Jammy2211 Jul 31, 2024
6f93f57
dediciate starting point visualization
Jammy2211 Jul 31, 2024
eca4f20
move plotting of start point to AbstractOptimizer
Jammy2211 Jul 31, 2024
1ee3e2a
model start info updated, output and tested
Jammy2211 Jul 31, 2024
3098150
MLE conversion complete
Jammy2211 Jul 31, 2024
e13aa37
undo hack
Jammy2211 Jul 31, 2024
50809c1
uncommented code
Jammy2211 Jul 31, 2024
c0d153e
Merge branch 'main' into feature/sensitivity_result
Jammy2211 Aug 2, 2024
fab9d45
perturbation -> pertrub
Jammy2211 Aug 2, 2024
21993b2
fix unit test
Jammy2211 Aug 2, 2024
2f4dae5
naive implementation of physical_centres_from
rhayes777 Aug 5, 2024
a71bc25
revieq
Jammy2211 Aug 5, 2024
558c440
review complete
Jammy2211 Aug 5, 2024
d468551
Merge pull request #1029 from rhayes777/feature/mle
Jammy2211 Aug 5, 2024
e43cfb4
Merge branch 'main' into feature/grid_quantities
Jammy2211 Aug 5, 2024
6e3a762
illustrating two separate physical_centres
rhayes777 Aug 5, 2024
24e1b15
also support tuples of results
rhayes777 Aug 5, 2024
40842a0
promoted physical_centres_lists_from to abstract class used by both g…
rhayes777 Aug 5, 2024
612b032
Merge branch 'feature/grid_quantities' of https://github.com/rhayes77…
Jammy2211 Aug 5, 2024
d29e8b2
Merge branch 'main' into feature/grid_quantities
rhayes777 Aug 5, 2024
07989f3
perturbed centres
rhayes777 Aug 5, 2024
3e0ac78
stuff
Jammy2211 Aug 5, 2024
4a4a272
update typing
Jammy2211 Aug 5, 2024
e9164a6
Merge pull request #1025 from rhayes777/feature/model_in_summary
rhayes777 Aug 5, 2024
534ca87
Merge pull request #1034 from rhayes777/feature/grid_quantities
rhayes777 Aug 5, 2024
89656cb
sensitivity works
Jammy2211 Aug 5, 2024
e9c2774
Merge pull request #1027 from rhayes777/feature/sensitivity_result
Jammy2211 Aug 5, 2024
4930b87
cast to list before iterating f_locals
rhayes777 Aug 7, 2024
75d8a50
fix test
rhayes777 Aug 7, 2024
839d7bb
fix
Jammy2211 Aug 7, 2024
05b711f
handle astropy string annotations
rhayes777 Aug 12, 2024
ba2f1c9
handle list annotation
rhayes777 Aug 12, 2024
16594de
astropy when self not seen in constructor (ffs)
rhayes777 Aug 12, 2024
3376b5e
use get_type_hints to ensure string type hints are resolved correctly
rhayes777 Aug 12, 2024
a519407
manually computing namespace
rhayes777 Aug 12, 2024
3cd3a7c
handle function case
rhayes777 Aug 12, 2024
84a7c5d
check if default has default and use default - fixing astropy interac…
rhayes777 Aug 12, 2024
6c7fe09
fix setting attribute rather than calling in constructor. could cause…
rhayes777 Aug 12, 2024
9282b5f
actually use constructor argument names
rhayes777 Aug 12, 2024
718ce6f
improving handling of pytress
rhayes777 Aug 12, 2024
29d6e2c
Merge pull request #1035 from rhayes777/feature/resume_fix
Jammy2211 Aug 20, 2024
bed5607
Merge pull request #1036 from rhayes777/feature/astropy_magic
Jammy2211 Aug 20, 2024
edbd5d1
Merge pull request #1037 from rhayes777/feature/jax_pytree
Jammy2211 Aug 20, 2024
3454565
updated scipy
Jammy2211 Aug 20, 2024
03c6981
update emcee and corner
Jammy2211 Aug 20, 2024
1e8e87e
dynesty
Jammy2211 Aug 20, 2024
e73f406
update ultranest
Jammy2211 Aug 20, 2024
1b81858
fix typo
Jammy2211 Aug 20, 2024
725e125
nautilus
Jammy2211 Aug 20, 2024
5dec5c6
use hidden module to continue use of scalar_search_wolfe1
rhayes777 Aug 23, 2024
7835b87
use simpson instead of deprecated trapz
rhayes777 Aug 23, 2024
da62988
fix test
rhayes777 Aug 23, 2024
abfc027
Mapped type annotations
rhayes777 Aug 23, 2024
89bd95b
wrap query in query()
rhayes777 Aug 23, 2024
18bb966
wrap query in text
rhayes777 Aug 23, 2024
1a25aa5
latest version of sqlalchemy
rhayes777 Aug 23, 2024
ab087f1
remove support for 3.8
rhayes777 Aug 23, 2024
3a97595
Merge pull request #1038 from rhayes777/feature/update_dependencies
Jammy2211 Aug 27, 2024
2865fb8
change declarative base import
Jammy2211 Aug 27, 2024
b6a2c27
silence float warning
Jammy2211 Aug 27, 2024
0563a23
change n_effective to maxcall
Jammy2211 Aug 27, 2024
b1e74b0
scipy import!
Jammy2211 Aug 27, 2024
a1df4f1
drop 3.8 doc
Jammy2211 Aug 27, 2024
542ff8c
include python 3.12
Jammy2211 Aug 27, 2024
2cd0996
fix
Jammy2211 Aug 27, 2024
0992a11
minor
Jammy2211 Aug 31, 2024
d6bbffc
emcee force search internal True
Jammy2211 Aug 31, 2024
afb4d1f
Fix Zeus
Jammy2211 Aug 31, 2024
69d2b25
exception for pyswamrs in notebook
Jammy2211 Aug 31, 2024
5fda6dc
pyswarms output
Jammy2211 Sep 1, 2024
e6dfaa3
pyswamrs notebook bug fixed
Jammy2211 Sep 1, 2024
e8132b0
notebook fix
Jammy2211 Sep 1, 2024
16cb216
check tests
Jammy2211 Sep 6, 2024
3e44f5e
remove Recusi
Jammy2211 Sep 6, 2024
bbf692a
Merge pull request #1039 from rhayes777/feature/silence_tests
Jammy2211 Sep 6, 2024
25f9a16
Merge pull request #1043 from rhayes777/feature/build_fixes
Jammy2211 Sep 6, 2024
ecd54c2
skip calling combined analysis visualise. May need to come up with ge…
rhayes777 Sep 6, 2024
a4bf484
fixing sql warnings...;
rhayes777 Sep 6, 2024
90ac4c6
more back populated
rhayes777 Sep 6, 2024
7e68cc5
samples/latent samples
rhayes777 Sep 6, 2024
6c85854
pickles and jsons
rhayes777 Sep 6, 2024
b014ccb
hdus and arrays
rhayes777 Sep 6, 2024
a240b08
handling dictionaries with arbitrary keys in database
rhayes777 Sep 6, 2024
24c343a
Merge branch 'main' into feature/build_fixes
rhayes777 Sep 6, 2024
77338f0
fix regression
rhayes777 Sep 6, 2024
ff4d621
Merge pull request #1044 from rhayes777/feature/build_fixes
rhayes777 Sep 6, 2024
effa065
ignore assertions when computing latent variables
rhayes777 Sep 6, 2024
3864493
Merge pull request #1045 from rhayes777/feature/latent_sample_assertions
rhayes777 Sep 6, 2024
f5c77bb
return config exception rather than throwing other error
rhayes777 Sep 6, 2024
ef2c29f
test illustrating issue
rhayes777 Sep 13, 2024
ebc6c96
fix attribute relationships
rhayes777 Sep 13, 2024
c8ef9ef
Merge pull request #1048 from rhayes777/feature/fit_attrs_fix
rhayes777 Sep 13, 2024
24c5be1
Merge pull request #1046 from rhayes777/feature/config_bug
Jammy2211 Sep 14, 2024
54a159b
do not throw away model when minimising samples
rhayes777 Sep 20, 2024
f12eed1
updates to fix build
Jammy2211 Sep 20, 2024
5d0e308
Merge pull request #1050 from rhayes777/feature/readthedocs
Jammy2211 Sep 20, 2024
74d9873
Merge pull request #1049 from rhayes777/feature/samples_model
Jammy2211 Sep 20, 2024
7c73206
version
Jammy2211 Sep 21, 2024
4deb3c6
version
Jammy2211 Sep 21, 2024
8f6c8c9
Merge pull request #1051 from rhayes777/feature/version
Jammy2211 Sep 27, 2024
275b6f0
use write_table to output sensitivity csv with whitespace formatting
rhayes777 Sep 27, 2024
53b2cd9
Merge pull request #1052 from rhayes777/feature/sensitivity_csv_format
rhayes777 Sep 27, 2024
8a52762
optionally include unique tag in the output path
rhayes777 Sep 27, 2024
0819fbb
ensure sample objects get passed to CombinedResult
rhayes777 Sep 27, 2024
3435c81
Merge pull request #1054 from rhayes777/feature/combined_samples
rhayes777 Sep 27, 2024
3078f2d
do not put unique tag in path prefix
rhayes777 Sep 27, 2024
410a25a
unique tag after path prefix and before name
rhayes777 Sep 27, 2024
121fd96
Merge pull request #1053 from rhayes777/feature/unique_tag
rhayes777 Sep 27, 2024
8a6f2e1
merged with main
Jammy2211 Oct 3, 2024
5d26635
fix implemented and tested
Jammy2211 Oct 3, 2024
61f2b3a
added mask input to sensitivity map and test its shape
Jammy2211 Oct 9, 2024
0996f8e
docstring
Jammy2211 Oct 9, 2024
5b4afb5
jobs skipped
Jammy2211 Oct 9, 2024
119fb8c
added instance to fit __call__
Jammy2211 Oct 9, 2024
915983c
fix test
rhayes777 Oct 11, 2024
c1ed1ee
review
Jammy2211 Oct 11, 2024
8c7c423
Merge pull request #1056 from rhayes777/feature/iterations_per_update…
Jammy2211 Oct 11, 2024
c3fa287
fix added
Jammy2211 Oct 11, 2024
3a51aa7
illustrating issue
rhayes777 Oct 11, 2024
7608c86
masked job result
rhayes777 Oct 11, 2024
d68e0ff
extracted bypass function
rhayes777 Oct 11, 2024
71b8bfd
make a job for a number
rhayes777 Oct 11, 2024
3600955
implemented dummy result mechanism
rhayes777 Oct 11, 2024
8d8e3da
fix
rhayes777 Oct 11, 2024
7666a65
fix
rhayes777 Oct 11, 2024
875e96e
remove bypass check from job creation
rhayes777 Oct 11, 2024
bd93666
docs
rhayes777 Oct 11, 2024
7d5171d
check if a job is complete
rhayes777 Oct 11, 2024
41095a0
skip simulation if job is complete
rhayes777 Oct 11, 2024
f03dce0
Merge pull request #1060 from rhayes777/feature/zeus_fix
Jammy2211 Oct 12, 2024
8715751
Merge branch 'main' into feature/sensitivity_mask
rhayes777 Oct 16, 2024
bb8e4cc
fixture
rhayes777 Oct 16, 2024
f025d3d
model for masked result
rhayes777 Oct 16, 2024
e14ea07
default likelihood and evidence
rhayes777 Oct 16, 2024
6cea6f7
give model perturbation
rhayes777 Oct 16, 2024
1e6652a
with_limits implementation for uniform prior
rhayes777 Oct 16, 2024
e517a07
illustrate x,y,etc params available from perturb model
rhayes777 Oct 16, 2024
fd01def
with limits for log gaussian prior
rhayes777 Oct 16, 2024
653e948
abstract with_limits
rhayes777 Oct 16, 2024
8045f8e
remove test
rhayes777 Oct 16, 2024
2aaf47a
path value dicts
rhayes777 Oct 16, 2024
1fefff2
pass a path value dict to results
rhayes777 Oct 16, 2024
49e6b5d
Revert "pass a path value dict to results"
rhayes777 Oct 16, 2024
2c6a8be
test_perturbed_physical_centres_list_from
rhayes777 Oct 16, 2024
1e324b6
fix tests
rhayes777 Oct 16, 2024
f7d510b
Merge pull request #1061 from rhayes777/feature/sensitivity_mask
Jammy2211 Oct 16, 2024
f230c0e
Merge pull request #1062 from rhayes777/feature/sensitivity_skip
Jammy2211 Oct 16, 2024
fc08c4a
Merge branch 'main' into feature/jax_wrapper_main_resolve
Jammy2211 Oct 16, 2024
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 .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.9, '3.10', '3.11']
python-version: [3.9, '3.10', '3.11', '3.12']
steps:
- name: Checkout PyAutoConf
uses: actions/checkout@v2
Expand Down
14 changes: 7 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,13 @@ venv.bak/
.idea
workspace/output/
output
test/optimize/test_fit
test/mle/test_fit
test/test_files/text/
test/
test_autofit/optimize/test_fit/
test_autofit/mle/test_fit/
test_autofit/test_files/text/psycopg2-binary==2.8.1
test_autofit/test_files/text/
fit/test_autofit/optimize/test_fit
fit/test_autofit/mle/test_fit
*.DS_Store

test_autofit/config/priors/old
Expand All @@ -157,7 +157,7 @@ test_autofit/samples.csv
__MACOSX
*.swp
test/autofit/test_fit
# Byte-compiled / optimized / DLL files
# Byte-compiled / mled / DLL files
__pycache__/
*.py[cod]
*$py.class
Expand Down Expand Up @@ -264,13 +264,13 @@ venv.bak/
.idea
workspace/output/
output
test/optimize/test_fit
test/mle/test_fit
test/test_files/text/
test/
test_autofit/optimize/test_fit/
test_autofit/mle/test_fit/
test_autofit/test_files/text/psycopg2-binary==2.8.1
test_autofit/test_files/text/
fit/test_autofit/optimize/test_fit
fit/test_autofit/mle/test_fit
*.DS_Store

test_autofit/config/priors/old
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ The following links are useful for new starters:

- `The introduction Jupyter Notebook on Binder <https://mybinder.org/v2/gh/Jammy2211/autofit_workspace/release?filepath=notebooks/overview/overview_1_the_basics.ipynb>`_, where you can try **PyAutoFit** in a web browser (without installation).

- `The autofit_workspace GitHub repository <https://github.com/Jammy2211/autofit_workspace>`_, which includes example scripts and the `HowToFit Jupyter notebook lectures <https://github.com/Jammy2211/autofit_workspace/tree/master/notebooks/howtofit>`_ which give new users a step-by-step introduction to **PyAutoFit**.
- `The autofit_workspace GitHub repository <https://github.com/Jammy2211/autofit_workspace>`_, which includes example scripts and the `HowToFit Jupyter notebook lectures <https://github.com/Jammy2211/autofit_workspace/tree/main/notebooks/howtofit>`_ which give new users a step-by-step introduction to **PyAutoFit**.

Support
-------
Expand All @@ -72,7 +72,7 @@ API Overview
To illustrate the **PyAutoFit** API, we use an illustrative toy model of fitting a one-dimensional Gaussian to
noisy 1D data. Here's the ``data`` (black) and the model (red) we'll fit:

.. image:: https://raw.githubusercontent.com/rhayes777/PyAutoFit/master/files/toy_model_fit.png
.. image:: https://raw.githubusercontent.com/rhayes777/PyAutoFit/main/files/toy_model_fit.png
:width: 400

We define our model, a 1D Gaussian by writing a Python class using the format below:
Expand Down
16 changes: 9 additions & 7 deletions autofit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
from .mapper.prior_model.annotation import AnnotationPriorModel
from .mapper.prior_model.collection import Collection
from .mapper.prior_model.prior_model import Model
from .mapper.prior_model.prior_model import Model
from .mapper.prior_model.array import Array
from .non_linear.search.abstract_search import NonLinearSearch
from .non_linear.analysis.visualize import Visualizer
from .non_linear.analysis.analysis import Analysis
Expand All @@ -66,18 +66,20 @@
from .non_linear.grid.sensitivity import Sensitivity
from .non_linear.initializer import InitializerBall
from .non_linear.initializer import InitializerPrior
from .non_linear.initializer import SpecificRangeInitializer
from .non_linear.initializer import InitializerParamBounds
from .non_linear.initializer import InitializerParamStartPoints
from .non_linear.search.mcmc.auto_correlations import AutoCorrelationsSettings
from .non_linear.search.mcmc.emcee.search import Emcee
from .non_linear.search.mcmc.zeus.search import Zeus
from .non_linear.search.nest.nautilus.search import Nautilus
from .non_linear.search.nest.dynesty.search.dynamic import DynestyDynamic
from .non_linear.search.nest.dynesty.search.static import DynestyStatic
from .non_linear.search.nest.ultranest.search import UltraNest
from .non_linear.search.optimize.drawer.search import Drawer
from .non_linear.search.optimize.lbfgs.search import LBFGS
from .non_linear.search.optimize.pyswarms.search.globe import PySwarmsGlobal
from .non_linear.search.optimize.pyswarms.search.local import PySwarmsLocal
from .non_linear.search.mle.drawer.search import Drawer
from .non_linear.search.mle.bfgs.search import BFGS
from .non_linear.search.mle.bfgs.search import LBFGS
from .non_linear.search.mle.pyswarms.search.globe import PySwarmsGlobal
from .non_linear.search.mle.pyswarms.search.local import PySwarmsLocal
from .non_linear.paths.abstract import AbstractPaths
from .non_linear.paths import DirectoryPaths
from .non_linear.paths import DatabasePaths
Expand Down Expand Up @@ -132,4 +134,4 @@ def save_abc(pickler, obj):

conf.instance.register(__file__)

__version__ = "2024.07.16.1"
__version__ = "2024.9.21.2"
2 changes: 1 addition & 1 deletion autofit/config/non_linear/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ Files

- ``mcmc.yaml``: Settings default behaviour of MCMC non-linear searches (e.g. Emcee).
- ``nest.yaml``: Settings default behaviour of nested sampler non-linear searches (e.g. Dynesty).
- ``optimizer.yaml``: Settings default behaviour of optimizer non-linear searches (e.g. PySwarms).
- ``mle.yaml``: Settings default behaviour of maximum likelihood estimator (mle) searches (e.g. PySwarms).
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Configuration files that customize the default behaviour of non-linear searches.

# **PyAutoFit** supports the following optimizer algorithms:
# **PyAutoFit** supports the following maximum likelihood estimator (MLE) algorithms:

# - PySwarms: https://github.com/ljvmiranda921/pyswarms / https://pyswarms.readthedocs.io/en/latest/index.html

# Settings in the [search], [run] and [options] entries are specific to each nested algorithm and should be
# determined by consulting that optimizers method's own readthedocs.
# determined by consulting that method's own readthedocs.

PySwarmsGlobal:
run:
Expand Down Expand Up @@ -49,6 +49,44 @@ PySwarmsLocal:
updates:
iterations_per_update: 500 # The number of iterations of the non-linear search performed between every 'update', where an update performs tasks like outputting model.results.
remove_state_files_at_end: true # Whether to remove the savestate of the seach (e.g. the Emcee hdf5 file) at the end to save hard-disk space (results are still stored as PyAutoFit pickles and loadable).
BFGS:
search:
tol: null
options:
disp: false
eps: 1.0e-08
ftol: 2.220446049250313e-09
gtol: 1.0e-05
iprint: -1.0
maxcor: 10
maxfun: 15000
maxiter: 15000
maxls: 20
initialize: # The method used to generate where walkers are initialized in parameter space {prior | ball}.
method: ball # priors: samples are initialized by randomly drawing from each parameter's prior. ball: samples are initialized by randomly drawing unit values from a narrow uniform distribution.
ball_lower_limit: 0.49 # The lower limit of the uniform distribution unit values are drawn from when initializing walkers using the ball method.
ball_upper_limit: 0.51 # The upper limit of the uniform distribution unit values are drawn from when initializing walkers using the ball method.
parallel:
number_of_cores: 1 # The number of cores the search is parallelized over by default, using Python multiprocessing.
printing:
silence: false # If True, the default print output of the non-linear search is silcened and not printed by the Python interpreter.
updates:
iterations_per_update: 500 # The number of iterations of the non-linear search performed between every 'update', where an update performs tasks like outputting model.results.
remove_state_files_at_end: true # Whether to remove the savestate of the seach (e.g. the Emcee hdf5 file) at the end to save hard-disk space (results are still stored as PyAutoFit pickles and loadable).
Drawer:
search:
total_draws: 50
initialize: # The method used to generate where walkers are initialized in parameter space {prior | ball}.
method: ball # priors: samples are initialized by randomly drawing from each parameter's prior. ball: samples are initialized by randomly drawing unit values from a narrow uniform distribution.
ball_lower_limit: 0.49 # The lower limit of the uniform distribution unit values are drawn from when initializing walkers using the ball method.
ball_upper_limit: 0.51 # The upper limit of the uniform distribution unit values are drawn from when initializing walkers using the ball method.
parallel:
number_of_cores: 1 # The number of cores the search is parallelized over by default, using Python multiprocessing.
printing:
silence: false # If True, the default print output of the non-linear search is silcened and not printed by the Python interpreter.
updates:
iterations_per_update: 500 # The number of iterations of the non-linear search performed between every 'update', where an update performs tasks like outputting model.results.
remove_state_files_at_end: true # Whether to remove the savestate of the seach (e.g. the Emcee hdf5 file) at the end to save hard-disk space (results are still stored as PyAutoFit pickles and loadable).
LBFGS:
search:
tol: null
Expand Down
5 changes: 3 additions & 2 deletions autofit/config/visualize/plots_search.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ nest:
corner_anesthetic: true # Output corner figure (using anestetic) during a non-linear search fit?
mcmc:
corner_cornerpy: true # Output corner figure (using corner.py) during a non-linear search fit?
optimize:
corner_cornerpy: true # Output corner figure (using corner.py) during a non-linear search fit?
mle:
subplot_parameters: true # Output a subplot of the best-fit parameters of the model?
log_likelihood_vs_iteration: true # Output a plot of the log likelihood versus iteration number?
3 changes: 2 additions & 1 deletion autofit/database/aggregator/aggregator.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
from abc import ABC, abstractmethod
from sqlalchemy import text
from typing import Optional, List, Union, cast

from ..sqlalchemy_ import sa
Expand Down Expand Up @@ -370,7 +371,7 @@ def _fits_for_query(self, query: str) -> List[m.Fit]:
query
"""
logger.debug(f"Executing query: {query}")
fit_ids = {row[0] for row in self.session.execute(query)}
fit_ids = {row[0] for row in self.session.execute(text(query))}

logger.info(f"{len(fit_ids)} fit(s) found matching query")
query = self.session.query(m.Fit).filter(m.Fit.id.in_(fit_ids))
Expand Down
85 changes: 18 additions & 67 deletions autofit/database/migration/migration.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import logging
from abc import ABC, abstractmethod
from hashlib import md5
from sqlalchemy import text
from typing import Union, Generator, Iterable, Optional

from .session_wrapper import SessionWrapper
from ..sqlalchemy_ import sa

logger = logging.getLogger(
__name__
)
logger = logging.getLogger(__name__)


class Identifiable(ABC):
Expand All @@ -19,22 +18,13 @@ def id(self) -> str:
A unique identifier generated by hashing a string
"""

def __eq__(
self,
other: Union["Identifiable", str]
) -> bool:
def __eq__(self, other: Union["Identifiable", str]) -> bool:
"""
Compares ids
"""
if isinstance(
other,
Identifiable
):
if isinstance(other, Identifiable):
return self.id == other.id
if isinstance(
other,
str
):
if isinstance(other, str):
return self.id == other
return False

Expand All @@ -57,13 +47,7 @@ def id(self) -> str:
"""
Hash generated from underlying SQL statements
"""
return md5(
":".join(
self.strings
).encode(
"utf-8"
)
).hexdigest()
return md5(":".join(self.strings).encode("utf-8")).hexdigest()

def __str__(self):
return "\n".join(self.strings)
Expand All @@ -72,10 +56,7 @@ def __str__(self):


class Revision(Identifiable):
def __init__(
self,
steps: Iterable[Step]
):
def __init__(self, steps: Iterable[Step]):
"""
A specific revision of the database. This comprises
a set of sequential steps and is uniquely identified
Expand All @@ -95,12 +76,7 @@ def id(self) -> str:
A unique identifier created by joining and hashing the
identifiers of comprised steps.
"""
return md5(
":".join(
step.id for step
in self.steps
).encode("utf-8")
).hexdigest()
return md5(":".join(step.id for step in self.steps).encode("utf-8")).hexdigest()

def __sub__(self, other: "Revision") -> "Revision":
"""
Expand All @@ -121,17 +97,11 @@ def __sub__(self, other: "Revision") -> "Revision":
An object comprising steps required to move from the other
revision to this revision.
"""
return Revision(tuple(
step for step in self.steps
if step not in other.steps
))
return Revision(tuple(step for step in self.steps if step not in other.steps))


class Migrator:
def __init__(
self,
*steps: Step
):
def __init__(self, *steps: Step):
"""
Manages migration of an old database.

Expand All @@ -153,14 +123,9 @@ def revisions(self) -> Generator[Revision, None, None]:
starting on the first step and terminating on any step
"""
for i in range(1, len(self._steps) + 1):
yield Revision(
self._steps[:i]
)
yield Revision(self._steps[:i])

def get_steps(
self,
revision_id: Optional[str] = None
) -> Iterable[Step]:
def get_steps(self, revision_id: Optional[str] = None) -> Iterable[Step]:
"""
Retrieve steps required to go from the specified
revision to the latest revision.
Expand Down Expand Up @@ -188,9 +153,7 @@ def latest_revision(self) -> Revision:
The latest revision according to the steps passed to the
Migrator
"""
return Revision(
self._steps
)
return Revision(self._steps)

def migrate(self, session: sa.orm.Session):
"""
Expand All @@ -207,19 +170,11 @@ def migrate(self, session: sa.orm.Session):
session
A session pointing at some database.
"""
wrapper = SessionWrapper(
session
)
wrapper = SessionWrapper(session)
revision_id = wrapper.revision_id
steps = list(
self.get_steps(
revision_id
)
)
steps = list(self.get_steps(revision_id))
if len(steps) == 0:
logger.info(
"Database already at latest revision"
)
logger.info("Database already at latest revision")
return

latest_revision_id = self.latest_revision.id
Expand All @@ -230,14 +185,10 @@ def migrate(self, session: sa.orm.Session):
for step in steps:
for string in step.strings:
try:
session.execute(
string
)
session.execute(text(string))
except sa.exc.OperationalError as e:
logger.debug(e)

wrapper.revision_id = self.latest_revision.id

logger.info(
f"revision_id updated to {wrapper.revision_id}"
)
logger.info(f"revision_id updated to {wrapper.revision_id}")
Loading
Loading