diff --git a/.travis.yml b/.travis.yml index 83a15c9..f197450 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/sampler.py b/ptemcee/sampler.py index 177517b..457b214 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,15 @@ def _validate_ndim(self, attribute, value): @betas.validator def _validate_betas(self, attribute, value): + try: + # see if betas is an integer. + v = operator.index(value) + if v < 1: + raise ValueError("Need at least one temperature") + return + except TypeError: + pass + if len(value) < 1: raise ValueError('Need at least one temperature!') if (value < 0).any(): 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),