Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

**kwargs input and anesthetic.NestedSamples output #90

Merged
merged 95 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
f1f52ed
neighbor spelling (assuming we're sticking to American spelling!)
AdamOrmondroyd May 19, 2022
2f0c339
Merge branch 'PolyChord:master' into master
AdamOrmondroyd May 28, 2022
6efc40c
updated run_poypolychord to use **kwargs rather than PolyChordSettings
AdamOrmondroyd Jul 27, 2022
df7b300
return anesthetic.NestedSamples output if installed
AdamOrmondroyd Jul 27, 2022
3f21a7b
added kwargs to run_pypolychord() docstring
AdamOrmondroyd Jul 27, 2022
85b7dfb
changed examples to use **kwargs
AdamOrmondroyd Jul 27, 2022
8cfcd22
accidental rename of run_polychord()
AdamOrmondroyd Jul 27, 2022
84c30c3
set kwarg defaults separately to run_pypolychord so that they can be …
AdamOrmondroyd Jul 27, 2022
6fe0516
run_polychord creates the paramnames file
AdamOrmondroyd Jul 27, 2022
51928d0
changed other examples paramnames are passed to run_pypolychord
AdamOrmondroyd Jul 27, 2022
da44aa7
mention anesthetic output in docstring (incomplete)
AdamOrmondroyd Jul 27, 2022
617ad12
tidied up grade_dims and nlives argument processing
AdamOrmondroyd Jul 27, 2022
d375810
logx should be logc
AdamOrmondroyd Jul 27, 2022
6270512
missing comma
AdamOrmondroyd Jul 27, 2022
1316fa8
removed settings argument
AdamOrmondroyd Jul 27, 2022
28ee39b
Restored old interface
AdamOrmondroyd Jul 28, 2022
50fa72b
run_polychord -> run
AdamOrmondroyd Jul 28, 2022
ae5c261
reverted Python_Functions/ (apart from logx->logc correction
AdamOrmondroyd Jul 28, 2022
247c51c
put PolyChordSettings back in __init__.py
AdamOrmondroyd Jul 28, 2022
cf54330
run() uses make_resume_file_kwargs_interface
AdamOrmondroyd Jul 28, 2022
dd2cf63
added run to __init__.py
AdamOrmondroyd Jul 28, 2022
7c06066
update nDerived, prior and dumper to kwargs
AdamOrmondroyd Jul 28, 2022
7b79d66
nDims is not a kwarg
AdamOrmondroyd Jul 28, 2022
9698948
add nDerived, prior and dumper to kwargs
AdamOrmondroyd Jul 28, 2022
5117092
use default_kwargs to set the defaults, then use this to see if kwarg…
AdamOrmondroyd Jul 28, 2022
aa64442
separate default_kwargs that refer to other default_kwargs
AdamOrmondroyd Jul 28, 2022
0f153cb
wrong brackets - think it's time to leave this for a moment
AdamOrmondroyd Jul 28, 2022
1ae0da3
removed accidental commas
AdamOrmondroyd Jul 29, 2022
477c796
pass kwargs directly rather than creating dict
AdamOrmondroyd Jul 29, 2022
0b5e998
added anesthetic to install_requires
AdamOrmondroyd Jul 29, 2022
25eb130
anesthetic now assumed to be installed, so new interface always retur…
AdamOrmondroyd Jul 29, 2022
4b4f29f
tidy up plotting to just use anesthetic output
AdamOrmondroyd Jul 29, 2022
8da3f8b
simplified to _make_resume_file(), plus wrapper _legacy_make_resume_f…
AdamOrmondroyd Jul 29, 2022
405f67d
added run_pypolychord_legacy_interface.py
AdamOrmondroyd Jul 29, 2022
78a9ca8
update run() docstring to anesthetic output
AdamOrmondroyd Jul 29, 2022
78654d8
removed unused sqrt from run_pypolychord.py
AdamOrmondroyd Jul 29, 2022
203f117
updated run_pypolychord.ipynb with py2nb
AdamOrmondroyd Jul 29, 2022
0730a18
change requirement to anesthetic==2.0.0b11
AdamOrmondroyd Jul 29, 2022
b963910
removed creation of .paramnames file from run(), added to run_pypolyc…
AdamOrmondroyd Aug 3, 2022
805db75
corrected kwargs error message
AdamOrmondroyd Aug 3, 2022
6b2ead8
exception handling if chains/ already exists
AdamOrmondroyd Aug 3, 2022
07f51e7
update to anesthetic 2.0.0b12
AdamOrmondroyd Sep 16, 2022
72bdea6
rather than repeating PolyChordOutput.make_paramnames_file(), make it…
AdamOrmondroyd Sep 16, 2022
25198cd
changed setup.py to point to github anesthetic as 2.0.0b12 hasn't bee…
AdamOrmondroyd Sep 18, 2022
52d6592
remove unecessary os import
AdamOrmondroyd Sep 22, 2022
5a750fa
removed commented out/empty lines around paramname creation
AdamOrmondroyd Sep 22, 2022
7f67a2a
removed unnecessary kwargs = kwargs.copy()
AdamOrmondroyd Sep 26, 2022
23a766f
double quotes to be more civilised
AdamOrmondroyd Oct 3, 2022
77fe885
change to single quotes to make Lucas happy
AdamOrmondroyd Oct 13, 2022
d05cfd2
Merge branch 'master' into anesthetic_output
williamjameshandley Feb 7, 2023
f860614
Merge branch 'master' into anesthetic_output
AdamOrmondroyd Feb 20, 2023
83597a0
Merge branch 'master' into anesthetic_output
AdamOrmondroyd Jan 9, 2024
6c650ad
update for more recent anesthetic
AdamOrmondroyd Jan 9, 2024
02c3b73
line spacing and remove todo (see pr 110
AdamOrmondroyd Jan 9, 2024
0f073cf
Merge remote-tracking branch 'upstream/master' into anesthetic_output
AdamOrmondroyd Jan 9, 2024
aed15cf
get anesthetic from pypi instead of gh
AdamOrmondroyd Jan 9, 2024
bd763d4
might as well do some formatting
AdamOrmondroyd Jan 9, 2024
bd6dff1
also fix wrap_loglikelihood for new interface (#110)
AdamOrmondroyd Jan 9, 2024
f6adbb5
Merge remote-tracking branch 'upstream/master' into anesthetic_output
AdamOrmondroyd Jan 9, 2024
34488e7
anesthetic back to optional, return None if not installed
AdamOrmondroyd Jan 9, 2024
a7c3347
version bump to 1.22.0
AdamOrmondroyd Jan 9, 2024
9852ba3
py2nb run_pypolychord.py
AdamOrmondroyd Jan 9, 2024
5503a09
Fix names of run scripts/notebooks
AdamOrmondroyd Jan 9, 2024
5b962d4
remove testing print statement
AdamOrmondroyd Jan 9, 2024
ca9c0c8
remove sqrt import, who knows where this came from
AdamOrmondroyd Jan 9, 2024
89ed507
Updated with new recommended interface
williamjameshandley Jan 9, 2024
eac2ffb
Merge branch 'anesthetic_output' of github.com:AdamOrmondroyd/PolyCho…
williamjameshandley Jan 9, 2024
7c8eae9
anesthetic root is deprecated
AdamOrmondroyd Jan 9, 2024
2e3208d
Update README.rst
williamjameshandley Jan 9, 2024
e54ad78
more anesthetic 2 madness
AdamOrmondroyd Jan 9, 2024
b6c50ca
update notebooks
AdamOrmondroyd Jan 9, 2024
e646727
remove () from dict
AdamOrmondroyd Jan 9, 2024
0937387
play around with tests
AdamOrmondroyd Jan 9, 2024
f0cdfdb
add anesthetic to CI install step
AdamOrmondroyd Jan 9, 2024
ddff239
only run tests on python>=3.8
AdamOrmondroyd Jan 9, 2024
2dabeef
test likelihood without derived parameters
AdamOrmondroyd Jan 9, 2024
ae0bb6d
some test housekeeping
AdamOrmondroyd Jan 9, 2024
be5e7c9
Merge remote-tracking branch 'upstream/master' into anesthetic_output
AdamOrmondroyd Jan 10, 2024
8143c0a
use or between the two loglikelihood return options
AdamOrmondroyd Jan 10, 2024
3465c20
use pathlib.Path to save OSError nonsense
AdamOrmondroyd Jan 10, 2024
9885121
explain paramnames more clearly
AdamOrmondroyd Jan 10, 2024
82add9d
check that grade_dims add up to nDims and test
AdamOrmondroyd Jan 10, 2024
b9cc4fe
update run docstring anesthetic stuff
AdamOrmondroyd Jan 10, 2024
2cae544
correct run_pypolychord return
AdamOrmondroyd Jan 10, 2024
9b4be33
correct missing blank lines in run() docstring
AdamOrmondroyd Jan 10, 2024
45e9f8c
add cluster_dir to kwargs, since technically it could be changed in P…
AdamOrmondroyd Jan 10, 2024
387b0d0
remove os entirely in favour of pathlib
AdamOrmondroyd Jan 10, 2024
4f5270f
fix line too long
AdamOrmondroyd Jan 10, 2024
a17d78d
update date
AdamOrmondroyd Jan 10, 2024
cdaf063
fix default grade_frac
AdamOrmondroyd Jan 10, 2024
40cb559
remove pytest-mpi requirement from CI
AdamOrmondroyd Jan 10, 2024
d420526
remove unecessary cast to set
AdamOrmondroyd Jan 25, 2024
cc807f5
don't use ac shorthand, but also don't clutter the namespace with log…
AdamOrmondroyd Jan 27, 2024
6d735e5
Revert "don't use ac shorthand, but also don't clutter the namespace …
AdamOrmondroyd Jan 28, 2024
5d9dadf
from anesthetic import make_2d_axes
AdamOrmondroyd Jan 28, 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
9 changes: 3 additions & 6 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
include:
- os: ubuntu-20.04
python-version: '3.6'
python-version: ['3.8', '3.9', '3.10', '3.11']

steps:
- uses: actions/checkout@v3
Expand All @@ -75,7 +72,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install mpi4py pytest pytest-mpi fortranformat
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe these should be added to requirements.txt (or requirements_test.txt)?

python -m pip install mpi4py pytest fortranformat anesthetic

- name: Install pypolychord
run: pip install -v '.[test]'
Expand All @@ -84,4 +81,4 @@ jobs:
run: python -m pytest tests

- name: Test pypolychord (MPI)
run: mpirun --oversubscribe -np 3 python -m pytest tests --only-mpi
run: mpirun --oversubscribe -np 3 python -m pytest tests
61 changes: 36 additions & 25 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
:target: https://arxiv.org/abs/1506.00171
:alt: Open-access paper

PolyChord v 1.21.4
PolyChord v 1.22.0

Will Handley, Mike Hobson & Anthony Lasenby

[email protected]

arXiv:1502.01856
`arXiv:1502.01856 <https://arxiv.org/abs/1502.01856>`_

arXiv:1506.00171
`arXiv:1506.00171 <https://arxiv.org/abs/1506.00171>`_

Latest version Released Apr 2020
Latest version Released Jan 2024


PolyChord Licence
Expand All @@ -26,11 +26,12 @@ file. PolyChord is free for academic usage

Users are also required to cite the PolyChord papers:

- arXiv:1502.01856
- arXiv:1506.00171
- `arXiv:1502.01856 <https://arxiv.org/abs/1502.01856>`_
- `arXiv:1506.00171 <https://arxiv.org/abs/1506.00171>`_

in their publications.


Python quickstart
=================

Expand All @@ -39,34 +40,44 @@ For Python users in a hurry:
.. code:: bash

pip install git+https://github.com/PolyChord/PolyChordLite@master
wget https://raw.githubusercontent.com/PolyChord/PolyChordLite/master/run_pypolychord.py
python run_pypolychord.py
wget https://raw.githubusercontent.com/PolyChord/PolyChordLite/master/quickstart.py
python quickstart.py

You can then modify the file run_pypolychord.py to your needs. If you have mpi compilers available, this version can be run in parallel with mpi.
You should make sure that you have gfortran/gcc (or equivalent) fortran compilers installed.

You should make sure that you have gfortran (or equivalent) fortran compilers installed.
You can then modify the file quickstart.py to your needs. If you have mpi compilers available, this version can be run in parallel with mpi.

If any of the above steps fail (this can in general happen for certain Mac OSX versions), then try installing without pip:
If any of the above steps fail (this can in general happen for certain macOS versions), then try installing without pip:

.. code:: bash

git clone https://github.com/PolyChord/PolyChordLite.git
cd PolyChordLite
python setup.py install

or perhaps:

.. code:: bash

git clone https://github.com/PolyChord/PolyChordLite.git
cd PolyChordLite
make
pip install .

our apologies -- the shifting sands that are macOS do not play well with the delicate dance of fortran, C and Python that is (py)PolyChordLite.
williamjameshandley marked this conversation as resolved.
Show resolved Hide resolved

If you do not have sudo access/virtual environments/anaconda, then appending `--user` to the install command may be necessary.

Post Processing
===============

We recommend the tool `anesthetic <https://github.com/handley-lab/anesthetic>`_ for post-processing your nested sampling runs. A plot gallery can be found `here <http://htmlpreview.github.io/?https://github.com/williamjameshandley/cosmo_example/blob/master/demos/demo.html>`_
We recommend the pip-installable tool `anesthetic <https://github.com/handley-lab/anesthetic>`_ for post-processing your nested sampling runs. A plot gallery can be found `here <https://anesthetic.readthedocs.io/en/latest/plotting.html>`_

.. code:: bash

https://github.com/handley-lab/anesthetic
pip install anesthetic

```
pip install anesthetic
```
If `anesthetic` is already installed, then `pypolychord.run()` will return an `anesthetic.NestedSamples` object, which can be used directly for post-processing.

MPI Support
===========
Expand Down Expand Up @@ -211,7 +222,6 @@ You can install direct from the git repository using:

pip install https://github.com/PolyChord/PolyChordLite/archive/master.zip

(N.B. PyPi coming soon)
or you can install locally with the command:

.. code:: bash
Expand All @@ -232,26 +242,27 @@ and check that it's working by running:

.. code:: bash

$ python run_pypolychord.py
$ python quickstart.py

or in MPI:

.. code:: bash

$ mpirun -np 4 python run_pypolychord.py
$ mpirun -np 4 python quickstart.py

If so, the rest of the interface is relatively painless. Follow the example in
run_pypolychord.py, and consult the docstring if you need help:
quickstart.py, and consult the docstring if you need help:

.. code:: python

import pypolychord
from pypolychord.settings import PolyChordSettings
>>> import pypolychord
>>> help(pypolychord.run)

There is also a demo `python notebook <https://github.com/PolyChord/PolyChordLite/blob/master/quickstart.ipynb>`_.

To post-process nested sampling runs we recommend the pip-installable tool `anesthetic <https://github.com/handley-lab/anesthetic>`_. A plot gallery can be found `here <https://anesthetic.readthedocs.io/en/latest/plotting.html>`_

help(pypolychord.run_polychord)
help(PolyChordSettings)

There is also a demo `python notebook <https://github.com/PolyChord/PolyChordLite/blob/master/run_pypolychord.ipynb>`_.

Output files
=============
Expand Down
4 changes: 2 additions & 2 deletions pypolychord/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__version__ = "1.21.4"
__version__ = "1.22.0"
from pypolychord.settings import PolyChordSettings
from pypolychord.polychord import run_polychord
from pypolychord.polychord import run_polychord, run
3 changes: 2 additions & 1 deletion pypolychord/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ def make_paramnames_files(self, paramnames):
self._create_pandas_table(paramnames = paramnames)


def make_paramnames_file(self, paramnames, filename):
@staticmethod
def make_paramnames_file(paramnames, filename):
with open(filename, 'w') as f:
for name, latex in paramnames:
f.write('%s %s\n' % (name, latex))
Expand Down
Loading
Loading