From 7ab13a11620c7eae8f0e730723f3e6a3723fa14e Mon Sep 17 00:00:00 2001 From: Andrew Nelson Date: Tue, 17 Mar 2020 11:55:27 +1100 Subject: [PATCH 1/4] BUG: initialise Sampler with betas=int --- .travis.yml | 6 ++---- ptemcee/tests.py | 7 +++++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 83a15c9..4e47717 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,9 @@ language: python cache: pip python: - - "2.7" - - "3.4" - - "3.5" - "3.6" - - "3.7-dev" + - "3.7" + - "3.8 install: - make init script: diff --git a/ptemcee/tests.py b/ptemcee/tests.py index 5869578..cb2094a 100644 --- a/ptemcee/tests.py +++ b/ptemcee/tests.py @@ -307,6 +307,13 @@ def test_temp_inf(self): betas=make_ladder(self.ndim, self.ntemps, Tmax=self.Tmax)) self.check_sampler(sampler, p0=self.p0) + def test_betas(self): + sampler = Sampler(self.nwalkers, self.ndim, + LogLikeGaussian(self.icov), + LogPriorGaussian(self.icov, cutoff=self.cutoff), + betas=20) + assert sampler.betas.shape[0] == 20 + def test_gaussian_adapt(self): sampler = Sampler(self.nwalkers, self.ndim, LogLikeGaussian(self.icov), From 1ca78be356df8b66dc5edc326ca510db2be1be5c Mon Sep 17 00:00:00 2001 From: Andrew Nelson Date: Tue, 17 Mar 2020 11:59:33 +1100 Subject: [PATCH 2/4] BUG: initialise Sampler with betas=int --- ptemcee/sampler.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ptemcee/sampler.py b/ptemcee/sampler.py index 177517b..bfa8e2d 100644 --- a/ptemcee/sampler.py +++ b/ptemcee/sampler.py @@ -5,6 +5,7 @@ __all__ = ['make_ladder', 'Sampler'] +import operator import attr import itertools import numpy as np @@ -185,6 +186,13 @@ def _validate_ndim(self, attribute, value): @betas.validator def _validate_betas(self, attribute, value): + try: + # see if betas is an integer. + operator.index(value) + return + except TypeError: + pass + if len(value) < 1: raise ValueError('Need at least one temperature!') if (value < 0).any(): From 462dc317d528c85c003a9b7c03c175cb31a97a06 Mon Sep 17 00:00:00 2001 From: Andrew Nelson Date: Tue, 17 Mar 2020 12:19:50 +1100 Subject: [PATCH 3/4] CI: fix travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4e47717..f197450 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ cache: pip python: - "3.6" - "3.7" - - "3.8 + - "3.8" install: - make init script: From c96d66937669591ca43924bcfb9603d1f616902e Mon Sep 17 00:00:00 2001 From: Andrew Nelson Date: Tue, 17 Mar 2020 12:29:48 +1100 Subject: [PATCH 4/4] MAINT: at least one temperature --- ptemcee/sampler.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ptemcee/sampler.py b/ptemcee/sampler.py index bfa8e2d..457b214 100644 --- a/ptemcee/sampler.py +++ b/ptemcee/sampler.py @@ -188,7 +188,9 @@ def _validate_ndim(self, attribute, value): def _validate_betas(self, attribute, value): try: # see if betas is an integer. - operator.index(value) + v = operator.index(value) + if v < 1: + raise ValueError("Need at least one temperature") return except TypeError: pass