From b619fb2eb146df3ae31e8d989473fe06a6ffac6e Mon Sep 17 00:00:00 2001 From: Justin Ellis Date: Tue, 1 Nov 2022 07:15:25 -0400 Subject: [PATCH] Use scm for versioning (#33) * scm * new line * __version__ * go back to version file because python3.7 --- .gitignore | 1 + Makefile | 3 +-- PTMCMCSampler/__init__.py | 7 ++----- README.md | 28 +++++++++++++++++++--------- pyproject.toml | 9 +++++++-- setup.py | 1 - 6 files changed, 30 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index b6c97dc..9083a08 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ dist .vscode venv .DS_Store +**/version.py diff --git a/Makefile b/Makefile index 54a6ebd..e32d5a9 100644 --- a/Makefile +++ b/Makefile @@ -65,8 +65,7 @@ coverage: test ## check code coverage quickly with the default Python dist: clean ## builds source and wheel package - python setup.py sdist - python setup.py bdist_wheel + python -m build --sdist --wheel ls -l dist test-sdist: ## Test source distribution diff --git a/PTMCMCSampler/__init__.py b/PTMCMCSampler/__init__.py index a5fd461..0b9922e 100644 --- a/PTMCMCSampler/__init__.py +++ b/PTMCMCSampler/__init__.py @@ -1,8 +1,5 @@ -__version__ = "2.0.0" - from PTMCMCSampler import PTMCMCSampler # noqa: F401 +from .version import version -def test(): - # Run some tests here - print("{0} tests have passed".format(0)) +__version__ = version diff --git a/README.md b/README.md index ee906d4..36851ca 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,22 @@ # PTMCMCSampler + [![GitHub release (latest by date)](https://img.shields.io/github/v/release/jellis18/PTMCMCSampler)](https://github.com/jellis18/PTMCMCSampler/releases/latest) [![PyPI](https://img.shields.io/pypi/v/ptmcmcsampler)](https://pypi.org/project/ptmcmcsampler/) [![Conda Version](https://img.shields.io/conda/vn/conda-forge/ptmcmcsampler.svg)](https://anaconda.org/conda-forge/ptmcmcsampler) [![GitHub Workflow Status (event)](https://img.shields.io/github/workflow/status/jellis18/PTMCMCSampler/CI%20targets?label=CI%20Tests)](https://github.com/jellis18/PTMCMCSampler/actions/workflows/ci_test.yml) - [![DOI](https://zenodo.org/badge/32821232.svg)](https://zenodo.org/badge/latestdoi/32821232) -[![Python Versions](https://img.shields.io/badge/python-3.6%2C%203.7%2C%203.8%2C%203.9-blue.svg)]() +[![Python Versions](https://img.shields.io/badge/python-3.7%2C%203.8%2C%203.9%2C%203.10-blue.svg)]() [![GitHub license](https://img.shields.io/github/license/Naereen/StrapDown.js.svg)](https://github.com/jellis18/PTMCMCSampler/blob/master/LICENSE) - MPI enabled Parallel Tempering MCMC code written in Python. See the [examples](https://github.com/jellis18/PTMCMCSampler/tree/master/examples) for some simple use cases. For MPI support you will need A functional MPI 1.x/2.x/3.x implementation like: -* [MPICH](http://www.mpich.org/) + +- [MPICH](http://www.mpich.org/) + ```bash # mac brew install mpich @@ -23,7 +24,9 @@ For MPI support you will need A functional MPI 1.x/2.x/3.x implementation like: # debian sudo apt install mpich ``` -* [Open MPI](http://www.open-mpi.org/) + +- [Open MPI](http://www.open-mpi.org/) + ```bash # mac brew install open-mpi @@ -32,49 +35,53 @@ For MPI support you will need A functional MPI 1.x/2.x/3.x implementation like: sudo apt install libopenmpi-dev ``` - To run with MPI support you can run your script containing a sampler with: ```bash mpirun -np script.py ``` + This will kick off `np` chains running at different temperatures. The temperature ladder and sampling schemes can be set in the `PTMCMCSampler.sample()` method. ## Installation ### Development + For development clone this repo and run: + ```bash make init source venv/bin/activate ``` ### Via pip + ```bash pip install ptmcmcsampler ``` for MPI support use + ```bash pip install ptmcmcsampler[mpi] ``` ### Via conda + ```bash conda install -c conda-forge ptmcmcsampler ``` for MPI support use + ```bash conda install -c conda-forge ptmcmcsampler mpi4py ``` - - - ## Attribution If you make use of this code, please cite: + ``` @misc{justin_ellis_2017_1037579, author = {Justin Ellis and @@ -88,8 +95,11 @@ If you make use of this code, please cite: ``` ### Correlation Length + In order for the sampler to run correctly using `acor` with Python 3 kernels the GitHub version of acor needs to be installed. (Currently the PyPI version is behind the GitHub version.) It can be easily installed with: + ``` pip install git+https://github.com/dfm/acor.git@master ``` + > Note that `acor` is not required to run the sampler, it simply calculates the effective chain length for output in the chain file. diff --git a/pyproject.toml b/pyproject.toml index ccf49ec..7beb919 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,9 +27,14 @@ exclude = ''' )/ ) ''' + +[tool.setuptools_scm] +write_to = "PTMCMCSampler/version.py" + [build-system] requires = [ - "setuptools>=40.8.0", + "setuptools>=45", + "setuptools_scm[toml]>=6.2", "wheel", ] -build-backend = "setuptools.build_meta" +build-backend = "setuptools.build_meta" \ No newline at end of file diff --git a/setup.py b/setup.py index 446f508..b0d249c 100755 --- a/setup.py +++ b/setup.py @@ -2,7 +2,6 @@ setup( name="ptmcmcsampler", - version="2.0.0", author="Justin A. Ellis", author_email="justin.ellis18@gmail.com", packages=["PTMCMCSampler"],