pymc3/step_methods/hmc/quadpotential.py
Killed 74 out of 94 mutantsSurvived
Survived mutation testing. These mutants show holes in your test suite.Mutant 584
--- pymc3/step_methods/hmc/quadpotential.py
+++ pymc3/step_methods/hmc/quadpotential.py
@@ -151,7 +151,7 @@
dtype=None,
):
"""Set up a diagonal mass matrix."""
- if initial_diag is not None and initial_diag.ndim != 1:
+ if initial_diag is None and initial_diag.ndim != 1:
raise ValueError('Initial diagonal must be one-dimensional.')
if initial_mean.ndim != 1:
raise ValueError('Initial mean must be one-dimensional.')
Mutant 590
--- pymc3/step_methods/hmc/quadpotential.py
+++ pymc3/step_methods/hmc/quadpotential.py
@@ -155,7 +155,7 @@
raise ValueError('Initial diagonal must be one-dimensional.')
if initial_mean.ndim != 1:
raise ValueError('Initial mean must be one-dimensional.')
- if initial_diag is not None and len(initial_diag) != n:
+ if initial_diag is None and len(initial_diag) != n:
raise ValueError('Wrong shape for initial_diag: expected %s got %s'
% (n, len(initial_diag)))
if len(initial_mean) != n:
Mutant 599
--- pymc3/step_methods/hmc/quadpotential.py
+++ pymc3/step_methods/hmc/quadpotential.py
@@ -171,7 +171,7 @@
self.dtype = dtype
self._n = n
- self._var = np.array(initial_diag, dtype=self.dtype, copy=True)
+ self._var = np.array(initial_diag, dtype=self.dtype, copy=False)
self._var_theano = theano.shared(self._var)
self._stds = np.sqrt(initial_diag)
self._inv_stds = floatX(1.) / self._stds
Mutant 604
--- pymc3/step_methods/hmc/quadpotential.py
+++ pymc3/step_methods/hmc/quadpotential.py
@@ -174,7 +174,7 @@
self._var = np.array(initial_diag, dtype=self.dtype, copy=True)
self._var_theano = theano.shared(self._var)
self._stds = np.sqrt(initial_diag)
- self._inv_stds = floatX(1.) / self._stds
+ self._inv_stds = floatX(1.) * self._stds
self._foreground_var = _WeightedVariance(
self._n, initial_mean, initial_diag, initial_weight, self.dtype)
self._background_var = _WeightedVariance(self._n, dtype=self.dtype)
Mutant 612
--- pymc3/step_methods/hmc/quadpotential.py
+++ pymc3/step_methods/hmc/quadpotential.py
@@ -188,7 +188,7 @@
def energy(self, x, velocity=None):
"""Compute kinetic energy at a position in parameter space."""
- if velocity is not None:
+ if velocity is None:
return 0.5 * x.dot(velocity)
return 0.5 * x.dot(self._var * x)
Mutant 622
--- pymc3/step_methods/hmc/quadpotential.py
+++ pymc3/step_methods/hmc/quadpotential.py
@@ -214,7 +214,7 @@
return
self._foreground_var.add_sample(sample, weight=1)
- self._background_var.add_sample(sample, weight=1)
+ self._background_var.add_sample(sample, weight=2)
self._update_from_weightvar(self._foreground_var)
if self._n_samples > 0 and self._n_samples % self.adaptation_window == 0:
Mutant 624
--- pymc3/step_methods/hmc/quadpotential.py
+++ pymc3/step_methods/hmc/quadpotential.py
@@ -217,7 +217,7 @@
self._background_var.add_sample(sample, weight=1)
self._update_from_weightvar(self._foreground_var)
- if self._n_samples > 0 and self._n_samples % self.adaptation_window == 0:
+ if self._n_samples > 1 and self._n_samples % self.adaptation_window == 0:
self._foreground_var = self._background_var
self._background_var = _WeightedVariance(self._n, dtype=self.dtype)
self.adaptation_window = int(self.adaptation_window * self.adaptation_window_multiplier)
Mutant 631
--- pymc3/step_methods/hmc/quadpotential.py
+++ pymc3/step_methods/hmc/quadpotential.py
@@ -220,7 +220,7 @@
if self._n_samples > 0 and self._n_samples % self.adaptation_window == 0:
self._foreground_var = self._background_var
self._background_var = _WeightedVariance(self._n, dtype=self.dtype)
- self.adaptation_window = int(self.adaptation_window * self.adaptation_window_multiplier)
+ self.adaptation_window = int(self.adaptation_window / self.adaptation_window_multiplier)
self._n_samples += 1
Mutant 635
--- pymc3/step_methods/hmc/quadpotential.py
+++ pymc3/step_methods/hmc/quadpotential.py
@@ -222,7 +222,7 @@
self._background_var = _WeightedVariance(self._n, dtype=self.dtype)
self.adaptation_window = int(self.adaptation_window * self.adaptation_window_multiplier)
- self._n_samples += 1
+ self._n_samples += 2
def raise_ok(self, vmap):
"""Check if the mass matrix is ok, and raise ValueError if not.
Mutant 637
--- pymc3/step_methods/hmc/quadpotential.py
+++ pymc3/step_methods/hmc/quadpotential.py
@@ -314,7 +314,7 @@
"""Online algorithm for computing mean of variance."""
def __init__(self, nelem, initial_mean=None, initial_variance=None,
- initial_weight=0, dtype='d'):
+ initial_weight=0, dtype='XXdXX'):
self._dtype = dtype
self.n_samples = float(initial_weight)
if initial_mean is None:
Mutant 638
--- pymc3/step_methods/hmc/quadpotential.py
+++ pymc3/step_methods/hmc/quadpotential.py
@@ -315,7 +315,7 @@
def __init__(self, nelem, initial_mean=None, initial_variance=None,
initial_weight=0, dtype='d'):
- self._dtype = dtype
+ self._dtype = None
self.n_samples = float(initial_weight)
if initial_mean is None:
self.mean = np.zeros(nelem, dtype='d')
Mutant 644
--- pymc3/step_methods/hmc/quadpotential.py
+++ pymc3/step_methods/hmc/quadpotential.py
@@ -320,7 +320,7 @@
if initial_mean is None:
self.mean = np.zeros(nelem, dtype='d')
else:
- self.mean = np.array(initial_mean, dtype='d', copy=True)
+ self.mean = np.array(initial_mean, dtype='d', copy=False)
if initial_variance is None:
self.raw_var = np.zeros(nelem, dtype='d')
else:
Mutant 650
--- pymc3/step_methods/hmc/quadpotential.py
+++ pymc3/step_methods/hmc/quadpotential.py
@@ -324,7 +324,7 @@
if initial_variance is None:
self.raw_var = np.zeros(nelem, dtype='d')
else:
- self.raw_var = np.array(initial_variance, dtype='d', copy=True)
+ self.raw_var = np.array(initial_variance, dtype='d', copy=False)
self.raw_var[:] *= self.n_samples
Mutant 652
--- pymc3/step_methods/hmc/quadpotential.py
+++ pymc3/step_methods/hmc/quadpotential.py
@@ -326,7 +326,7 @@
else:
self.raw_var = np.array(initial_variance, dtype='d', copy=True)
- self.raw_var[:] *= self.n_samples
+ self.raw_var[:] = self.n_samples
if self.raw_var.shape != (nelem,):
raise ValueError('Invalid shape for initial variance.')
Mutant 672
--- pymc3/step_methods/hmc/quadpotential.py
+++ pymc3/step_methods/hmc/quadpotential.py
@@ -342,7 +342,7 @@
self.raw_var[:] += weight * old_diff * new_diff
def current_variance(self, out=None):
- if self.n_samples == 0:
+ if self.n_samples == 1:
raise ValueError('Can not compute variance without samples.')
if out is not None:
return np.divide(self.raw_var, self.n_samples, out=out)
Mutant 673
--- pymc3/step_methods/hmc/quadpotential.py
+++ pymc3/step_methods/hmc/quadpotential.py
@@ -344,7 +344,7 @@
def current_variance(self, out=None):
if self.n_samples == 0:
raise ValueError('Can not compute variance without samples.')
- if out is not None:
+ if out is None:
return np.divide(self.raw_var, self.n_samples, out=out)
else:
return (self.raw_var / self.n_samples).astype(self._dtype)
Mutant 674
--- pymc3/step_methods/hmc/quadpotential.py
+++ pymc3/step_methods/hmc/quadpotential.py
@@ -476,7 +476,7 @@
self.velocity(x, out=v_out)
return self.energy(x, v_out)
- __call__ = random
+ __call__ = None
class QuadPotentialFullAdapt(QuadPotentialFull):
Mutant 675
--- pymc3/step_methods/hmc/quadpotential.py
+++ pymc3/step_methods/hmc/quadpotential.py
@@ -588,7 +588,7 @@
initial_mean=None,
initial_covariance=None,
initial_weight=0,
- dtype="d",
+ dtype="XXdXX",
):
self._dtype = dtype
self.n_samples = float(initial_weight)
Mutant 676
--- pymc3/step_methods/hmc/quadpotential.py
+++ pymc3/step_methods/hmc/quadpotential.py
@@ -632,7 +632,7 @@
import sksparse.cholmod as cholmod
chol_available = True
except ImportError:
- chol_available = False
+ chol_available = True
if chol_available:
__all__ += ['QuadPotentialSparse']
Mutant 677
--- pymc3/step_methods/hmc/quadpotential.py
+++ pymc3/step_methods/hmc/quadpotential.py
@@ -632,7 +632,7 @@
import sksparse.cholmod as cholmod
chol_available = True
except ImportError:
- chol_available = False
+ chol_available = None
if chol_available:
__all__ += ['QuadPotentialSparse']