Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 2 additions & 3 deletions pints/_abc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ class ABCSampler(pints.Loggable, pints.TunableMethod):
:class:`pints.TunableMethod` interfaces.
"""

@classmethod
def name(self):
"""
Returns this method's full name.
"""
""" Returns this method's full name. """
raise NotImplementedError

def ask(self):
Expand Down
1 change: 1 addition & 0 deletions pints/_abc/_abc_rejection.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def __init__(self, log_prior):
self._xs = None
self._ready_for_tell = False

@classmethod
def name(self):
""" See :meth:`pints.ABCSampler.name()`. """
return 'Rejection ABC'
Expand Down
1 change: 1 addition & 0 deletions pints/_abc/_abc_smc.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def __init__(self, log_prior, perturbation_kernel=None,
raise ValueError('Provided perturbation kernel must be an instance'
' of pints.LogPrior')

@classmethod
def name(self):
""" See :meth:`pints.ABCSampler.name()`. """
return 'ABC-SMC'
Expand Down
4 changes: 2 additions & 2 deletions pints/_boundaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class RectangularBoundaries(Boundaries):
The corresponding upper boundaries
"""
def __init__(self, lower, upper):
super(RectangularBoundaries, self).__init__()
super().__init__()

# Convert to shape (n,) vectors, copy to ensure they remain unchanged
self._lower = pints.vector(lower)
Expand Down Expand Up @@ -205,7 +205,7 @@ class LogPDFBoundaries(Boundaries):
within bounds. Anything _above_ the threshold counts as within bounds.
"""
def __init__(self, log_pdf, threshold=-np.inf):
super(LogPDFBoundaries, self).__init__()
super().__init__()

# Check log pdf
if not isinstance(log_pdf, pints.LogPDF):
Expand Down
4 changes: 2 additions & 2 deletions pints/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ForwardModel(object):
"""

def __init__(self):
super(ForwardModel, self).__init__()
super().__init__()

def n_parameters(self):
"""
Expand Down Expand Up @@ -67,7 +67,7 @@ class ForwardModelS1(ForwardModel):
"""

def __init__(self):
super(ForwardModelS1, self).__init__()
super().__init__()

def simulateS1(self, parameters, times):
"""
Expand Down
14 changes: 7 additions & 7 deletions pints/_error_measures.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class ProblemErrorMeasure(ErrorMeasure):
:class:`multi-output<pints.MultiOutputProblem>` problems.
"""
def __init__(self, problem):
super(ProblemErrorMeasure, self).__init__()
super().__init__()
self._problem = problem
self._times = problem.times()
self._values = problem.values()
Expand Down Expand Up @@ -96,7 +96,7 @@ class MeanSquaredError(ProblemErrorMeasure):

"""
def __init__(self, problem, weights=None):
super(MeanSquaredError, self).__init__(problem)
super().__init__(problem)
self._ninv = 1.0 / np.prod(self._values.shape)

if weights is None:
Expand Down Expand Up @@ -147,7 +147,7 @@ class NormalisedRootMeanSquaredError(ProblemErrorMeasure):
A :class:`pints.SingleOutputProblem`.
"""
def __init__(self, problem):
super(NormalisedRootMeanSquaredError, self).__init__(problem)
super().__init__(problem)

if not isinstance(problem, pints.SingleOutputProblem):
raise ValueError(
Expand All @@ -174,7 +174,7 @@ class ProbabilityBasedError(ErrorMeasure):
The LogPDF to base this error on.
"""
def __init__(self, log_pdf):
super(ProbabilityBasedError, self).__init__()
super().__init__()
if not isinstance(log_pdf, pints.LogPDF):
raise ValueError(
'Given log_pdf must be an instance of pints.LogPDF.')
Expand Down Expand Up @@ -216,7 +216,7 @@ class RootMeanSquaredError(ProblemErrorMeasure):
A :class:`pints.SingleOutputProblem`.
"""
def __init__(self, problem):
super(RootMeanSquaredError, self).__init__(problem)
super().__init__(problem)

if not isinstance(problem, pints.SingleOutputProblem):
raise ValueError(
Expand Down Expand Up @@ -271,7 +271,7 @@ class SumOfErrors(ErrorMeasure):

"""
def __init__(self, error_measures, weights=None):
super(SumOfErrors, self).__init__()
super().__init__()

# Check input arguments
if len(error_measures) < 1:
Expand Down Expand Up @@ -360,7 +360,7 @@ class SumOfSquaresError(ProblemErrorMeasure):

"""
def __init__(self, problem, weights=None):
super(SumOfSquaresError, self).__init__(problem)
super().__init__(problem)

if weights is None:
weights = [1] * self._n_outputs
Expand Down
8 changes: 4 additions & 4 deletions pints/_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def __init__(
max_tasks_per_worker=500,
n_numpy_threads=1,
args=None):
super(ParallelEvaluator, self).__init__(function, args)
super().__init__(function, args)

# Determine number of workers
if n_workers is None:
Expand Down Expand Up @@ -437,7 +437,7 @@ class MultiSequentialEvaluator(Evaluator):
``f(x, *args)``.
"""
def __init__(self, functions, args=None):
super(MultiSequentialEvaluator, self).__init__(functions[0], args)
super().__init__(functions[0], args)

# Check functions
for function in functions:
Expand Down Expand Up @@ -473,7 +473,7 @@ class SequentialEvaluator(Evaluator):
specified, ``f`` will be called as ``f(x, *args)``.
"""
def __init__(self, function, args=None):
super(SequentialEvaluator, self).__init__(function, args)
super().__init__(function, args)

def _evaluate(self, positions):
scores = [0] * len(positions)
Expand Down Expand Up @@ -530,7 +530,7 @@ class _Worker(multiprocessing.Process):
def __init__(
self, function, args, tasks, results, max_tasks, max_threads,
errors, error):
super(_Worker, self).__init__()
super().__init__()
self.daemon = True
self._function = function
self._args = args
Expand Down
39 changes: 18 additions & 21 deletions pints/_log_likelihoods.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class AR1LogLikelihood(pints.ProblemLogLikelihood):
"""

def __init__(self, problem):
super(AR1LogLikelihood, self).__init__(problem)
super().__init__(problem)

# Get number of times, number of outputs
self._nt = len(self._times) - 1
Expand Down Expand Up @@ -149,7 +149,7 @@ class ARMA11LogLikelihood(pints.ProblemLogLikelihood):
"""

def __init__(self, problem):
super(ARMA11LogLikelihood, self).__init__(problem)
super().__init__(problem)

# Get number of times, number of outputs
self._nt = len(self._times) - 2
Expand Down Expand Up @@ -205,7 +205,7 @@ class CauchyLogLikelihood(pints.ProblemLogLikelihood):
"""

def __init__(self, problem):
super(CauchyLogLikelihood, self).__init__(problem)
super().__init__(problem)

# Get number of times, number of outputs
self._nt = len(self._times)
Expand Down Expand Up @@ -326,7 +326,7 @@ class CensoredGaussianLogLikelihood(pints.ProblemLogLikelihood):
"""

def __init__(self, problem, lower=None, upper=None):
super(CensoredGaussianLogLikelihood, self).__init__(problem)
super().__init__(problem)

# Get number of times, number of outputs
self._nt = len(self._times)
Expand Down Expand Up @@ -617,8 +617,7 @@ class ConstantAndMultiplicativeGaussianLogLikelihood(
"""

def __init__(self, problem):
super(ConstantAndMultiplicativeGaussianLogLikelihood, self).__init__(
problem)
super().__init__(problem)

# Get number of times and number of noise parameters
self._nt = len(self._times)
Expand Down Expand Up @@ -819,8 +818,7 @@ class GaussianIntegratedLogUniformLogLikelihood(pints.ProblemLogLikelihood):
"""

def __init__(self, problem):
super(GaussianIntegratedLogUniformLogLikelihood,
self).__init__(problem)
super().__init__(problem)

# Get number of times, number of outputs
self._nt = len(self._times)
Expand Down Expand Up @@ -908,7 +906,7 @@ class GaussianIntegratedUniformLogLikelihood(pints.ProblemLogLikelihood):
"""

def __init__(self, problem, lower, upper):
super(GaussianIntegratedUniformLogLikelihood, self).__init__(problem)
super().__init__(problem)

# Get number of times, number of outputs
self._nt = len(self._times)
Expand Down Expand Up @@ -1012,7 +1010,7 @@ class GaussianKnownSigmaLogLikelihood(pints.ProblemLogLikelihood):
"""

def __init__(self, problem, sigma):
super(GaussianKnownSigmaLogLikelihood, self).__init__(problem)
super().__init__(problem)

# Store counts
self._no = problem.n_outputs()
Expand Down Expand Up @@ -1110,7 +1108,7 @@ class GaussianLogLikelihood(pints.ProblemLogLikelihood):
"""

def __init__(self, problem):
super(GaussianLogLikelihood, self).__init__(problem)
super().__init__(problem)

# Get number of times, number of outputs
self._nt = len(self._times)
Expand Down Expand Up @@ -1169,7 +1167,7 @@ def __init__(self, problem, sigma):
warnings.warn(
'The class `pints.KnownNoiseLogLikelihood` is deprecated.'
' Please use `pints.GaussianKnownSigmaLogLikelihood` instead.')
super(KnownNoiseLogLikelihood, self).__init__(problem, sigma)
super().__init__(problem, sigma)


class LogNormalLogLikelihood(pints.ProblemLogLikelihood):
Expand Down Expand Up @@ -1214,7 +1212,7 @@ class LogNormalLogLikelihood(pints.ProblemLogLikelihood):
"""

def __init__(self, problem, mean_adjust=False):
super(LogNormalLogLikelihood, self).__init__(problem)
super().__init__(problem)

# Get number of times, number of outputs
self._nt = len(self._times)
Expand Down Expand Up @@ -1352,7 +1350,7 @@ class MultiplicativeGaussianLogLikelihood(pints.ProblemLogLikelihood):
"""

def __init__(self, problem):
super(MultiplicativeGaussianLogLikelihood, self).__init__(problem)
super().__init__(problem)

# Get number of times and number of outputs
self._nt = len(self._times)
Expand Down Expand Up @@ -1411,13 +1409,11 @@ def __init__(self, log_likelihood):
if not isinstance(log_likelihood, pints.ProblemLogLikelihood):
raise ValueError(
'Given log_likelihood must extend pints.ProblemLogLikelihood')

# Call parent constructor
super(ScaledLogLikelihood, self).__init__(log_likelihood._problem)

# Store log-likelihood
self._log_likelihood = log_likelihood

# Call this only after checking log_likelihood type
super().__init__(log_likelihood._problem)

# Pre-calculate parts
self._f = 1.0 / np.prod(self._values.shape)

Expand Down Expand Up @@ -1465,7 +1461,7 @@ class StudentTLogLikelihood(pints.ProblemLogLikelihood):
"""

def __init__(self, problem):
super(StudentTLogLikelihood, self).__init__(problem)
super().__init__(problem)

# Get number of times, number of outputs
self._nt = len(self._times)
Expand Down Expand Up @@ -1515,4 +1511,5 @@ def __init__(self, problem):
warnings.warn(
'The class `pints.UnknownNoiseLogLikelihood` is deprecated.'
' Please use `pints.GaussianLogLikelihood` instead.')
super(UnknownNoiseLogLikelihood, self).__init__(problem)
super().__init__(problem)

8 changes: 4 additions & 4 deletions pints/_log_pdfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class PooledLogPDF(LogPDF):
pooled=[False, True])
"""
def __init__(self, log_pdfs, pooled):
super(PooledLogPDF, self).__init__()
super().__init__()

# Check input arguments
if len(log_pdfs) < 2:
Expand Down Expand Up @@ -329,7 +329,7 @@ class ProblemLogLikelihood(LogPDF):

"""
def __init__(self, problem):
super(ProblemLogLikelihood, self).__init__()
super().__init__()
self._problem = problem
# Cache some problem variables
self._values = problem.values()
Expand Down Expand Up @@ -364,7 +364,7 @@ class LogPosterior(LogPDF):
space.
"""
def __init__(self, log_likelihood, log_prior):
super(LogPosterior, self).__init__()
super().__init__()

# Check arguments
if not isinstance(log_prior, LogPrior):
Expand Down Expand Up @@ -453,7 +453,7 @@ class SumOfIndependentLogPDFs(LogPDF):
])
"""
def __init__(self, log_likelihoods):
super(SumOfIndependentLogPDFs, self).__init__()
super().__init__()

# Check input arguments
if len(log_likelihoods) < 2:
Expand Down
2 changes: 1 addition & 1 deletion pints/_log_priors.py
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,7 @@ def __init__(self, mean, standard_deviation):
warnings.warn(
'The class `pints.NormalLogPrior` is deprecated.'
' Please use `pints.GaussianLogPrior` instead.')
super(NormalLogPrior, self).__init__(mean, standard_deviation)
super().__init__(mean, standard_deviation)


class StudentTLogPrior(pints.LogPrior):
Expand Down
2 changes: 1 addition & 1 deletion pints/_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Logger(object):

"""
def __init__(self):
super(Logger, self).__init__()
super().__init__()

# Log to screen
self._stream = sys.stdout
Expand Down
4 changes: 2 additions & 2 deletions pints/_mcmc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class MCMCSampler(pints.Loggable, pints.TunableMethod):
:class:`pints.TunableMethod` interfaces.
"""

@classmethod
def name(self):
"""
Returns this method's full name.
Expand Down Expand Up @@ -1128,8 +1129,7 @@ def __init__(self, log_pdf, chains, x0, sigma0=None, transformation=None,
warnings.warn(
'The class `pints.MCMCSampling` is deprecated.'
' Please use `pints.MCMCController` instead.')
super(MCMCSampling, self).__init__(log_pdf, chains, x0, sigma0,
transformation, method=method)
super().__init__(log_pdf, chains, x0, sigma0, transformation, method)


def mcmc_sample(log_pdf, chains, x0, sigma0=None, transformation=None,
Expand Down
2 changes: 1 addition & 1 deletion pints/_mcmc/_adaptive_covariance.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class AdaptiveCovarianceMC(pints.SingleChainMCMC):
"""

def __init__(self, x0, sigma0=None):
super(AdaptiveCovarianceMC, self).__init__(x0, sigma0)
super().__init__(x0, sigma0)

# Current running status, used to initialise on first run and check
# that certain methods are only called before or during run.
Expand Down
Loading