bambi/backends/pymc.py
Killed 64 out of 94 mutantsSurvived
Survived mutation testing. These mutants show holes in your test suite.Mutant 680
--- bambi/backends/pymc.py
+++ bambi/backends/pymc.py
@@ -15,7 +15,7 @@
links = {
"identity": lambda x: x,
"logit": theano.tensor.nnet.sigmoid,
- "inverse": theano.tensor.inv,
+ "XXinverseXX": theano.tensor.inv,
"inverse_squared": lambda x: theano.tensor.inv(theano.tensor.sqrt(x)),
"log": theano.tensor.exp,
}
Mutant 681
--- bambi/backends/pymc.py
+++ bambi/backends/pymc.py
@@ -16,7 +16,7 @@
"identity": lambda x: x,
"logit": theano.tensor.nnet.sigmoid,
"inverse": theano.tensor.inv,
- "inverse_squared": lambda x: theano.tensor.inv(theano.tensor.sqrt(x)),
+ "XXinverse_squaredXX": lambda x: theano.tensor.inv(theano.tensor.sqrt(x)),
"log": theano.tensor.exp,
}
Mutant 682
--- bambi/backends/pymc.py
+++ bambi/backends/pymc.py
@@ -16,7 +16,7 @@
"identity": lambda x: x,
"logit": theano.tensor.nnet.sigmoid,
"inverse": theano.tensor.inv,
- "inverse_squared": lambda x: theano.tensor.inv(theano.tensor.sqrt(x)),
+ "inverse_squared": lambda x: None,
"log": theano.tensor.exp,
}
Mutant 684
--- bambi/backends/pymc.py
+++ bambi/backends/pymc.py
@@ -20,7 +20,7 @@
"log": theano.tensor.exp,
}
- dists = {"HalfFlat": pm.Bound(pm.Flat, lower=0)}
+ dists = {"XXHalfFlatXX": pm.Bound(pm.Flat, lower=0)}
def __init__(self):
self.reset()
Mutant 685
--- bambi/backends/pymc.py
+++ bambi/backends/pymc.py
@@ -20,7 +20,7 @@
"log": theano.tensor.exp,
}
- dists = {"HalfFlat": pm.Bound(pm.Flat, lower=0)}
+ dists = {"HalfFlat": pm.Bound(pm.Flat, lower=1)}
def __init__(self):
self.reset()
Mutant 686
--- bambi/backends/pymc.py
+++ bambi/backends/pymc.py
@@ -20,7 +20,7 @@
"log": theano.tensor.exp,
}
- dists = {"HalfFlat": pm.Bound(pm.Flat, lower=0)}
+ dists = None
def __init__(self):
self.reset()
Mutant 687
--- bambi/backends/pymc.py
+++ bambi/backends/pymc.py
@@ -26,7 +26,7 @@
self.reset()
# Attributes defined elsewhere
- self.mu = None # build()
+ self.mu = "" # build()
self.spec = None # build()
self.trace = None # build()
self.advi_params = None # build()
Mutant 688
--- bambi/backends/pymc.py
+++ bambi/backends/pymc.py
@@ -27,7 +27,7 @@
# Attributes defined elsewhere
self.mu = None # build()
- self.spec = None # build()
+ self.spec = "" # build()
self.trace = None # build()
self.advi_params = None # build()
Mutant 689
--- bambi/backends/pymc.py
+++ bambi/backends/pymc.py
@@ -28,7 +28,7 @@
# Attributes defined elsewhere
self.mu = None # build()
self.spec = None # build()
- self.trace = None # build()
+ self.trace = "" # build()
self.advi_params = None # build()
def reset(self):
Mutant 690
--- bambi/backends/pymc.py
+++ bambi/backends/pymc.py
@@ -29,7 +29,7 @@
self.mu = None # build()
self.spec = None # build()
self.trace = None # build()
- self.advi_params = None # build()
+ self.advi_params = "" # build()
def reset(self):
"""Reset PyMC3 model and all tracked distributions and parameters."""
Mutant 692
--- bambi/backends/pymc.py
+++ bambi/backends/pymc.py
@@ -34,7 +34,7 @@
def reset(self):
"""Reset PyMC3 model and all tracked distributions and parameters."""
self.model = pm.Model()
- self.mu = None
+ self.mu = ""
self.par_groups = {}
def _build_dist(self, spec, label, dist, **kwargs):
Mutant 693
--- bambi/backends/pymc.py
+++ bambi/backends/pymc.py
@@ -35,7 +35,7 @@
"""Reset PyMC3 model and all tracked distributions and parameters."""
self.model = pm.Model()
self.mu = None
- self.par_groups = {}
+ self.par_groups = None
def _build_dist(self, spec, label, dist, **kwargs):
"""Build and return a PyMC3 Distribution."""
Mutant 697
--- bambi/backends/pymc.py
+++ bambi/backends/pymc.py
@@ -61,7 +61,7 @@
# Non-centered parameterization for hyperpriors
if (
spec.noncentered
- and "sigma" in kwargs
+ and "XXsigmaXX" in kwargs
and "observed" not in kwargs
and isinstance(kwargs["sigma"], pm.model.TransformedRV)
):
Mutant 706
--- bambi/backends/pymc.py
+++ bambi/backends/pymc.py
@@ -66,7 +66,7 @@
and isinstance(kwargs["sigma"], pm.model.TransformedRV)
):
old_sigma = kwargs["sigma"]
- _offset = pm.Normal(label + "_offset", mu=0, sigma=1, shape=kwargs["shape"])
+ _offset = pm.Normal(label + "XX_offsetXX", mu=0, sigma=1, shape=kwargs["shape"])
return pm.Deterministic(label, _offset * old_sigma)
return dist(label, **kwargs)
Mutant 707
--- bambi/backends/pymc.py
+++ bambi/backends/pymc.py
@@ -66,7 +66,7 @@
and isinstance(kwargs["sigma"], pm.model.TransformedRV)
):
old_sigma = kwargs["sigma"]
- _offset = pm.Normal(label + "_offset", mu=0, sigma=1, shape=kwargs["shape"])
+ _offset = pm.Normal(label + "_offset", mu=1, sigma=1, shape=kwargs["shape"])
return pm.Deterministic(label, _offset * old_sigma)
return dist(label, **kwargs)
Mutant 708
--- bambi/backends/pymc.py
+++ bambi/backends/pymc.py
@@ -66,7 +66,7 @@
and isinstance(kwargs["sigma"], pm.model.TransformedRV)
):
old_sigma = kwargs["sigma"]
- _offset = pm.Normal(label + "_offset", mu=0, sigma=1, shape=kwargs["shape"])
+ _offset = pm.Normal(label + "_offset", mu=0, sigma=2, shape=kwargs["shape"])
return pm.Deterministic(label, _offset * old_sigma)
return dist(label, **kwargs)
Mutant 711
--- bambi/backends/pymc.py
+++ bambi/backends/pymc.py
@@ -67,7 +67,7 @@
):
old_sigma = kwargs["sigma"]
_offset = pm.Normal(label + "_offset", mu=0, sigma=1, shape=kwargs["shape"])
- return pm.Deterministic(label, _offset * old_sigma)
+ return pm.Deterministic(label, _offset / old_sigma)
return dist(label, **kwargs)
Mutant 712
--- bambi/backends/pymc.py
+++ bambi/backends/pymc.py
@@ -71,7 +71,7 @@
return dist(label, **kwargs)
- def build(self, spec, reset=True): # pylint: disable=arguments-differ
+ def build(self, spec, reset=False): # pylint: disable=arguments-differ
"""Compile the PyMC3 model from an abstract model specification.
Parameters
Mutant 722
--- bambi/backends/pymc.py
+++ bambi/backends/pymc.py
@@ -98,7 +98,7 @@
coef = self._build_dist(spec, label, dist_name, shape=n_cols, **dist_args)
if t.random:
- self.mu += coef[t.group_index][:, None] * t.predictor
+ self.mu = coef[t.group_index][:, None] * t.predictor
else:
self.mu += pm.math.dot(data, coef)[:, None]
Mutant 723
--- bambi/backends/pymc.py
+++ bambi/backends/pymc.py
@@ -98,7 +98,7 @@
coef = self._build_dist(spec, label, dist_name, shape=n_cols, **dist_args)
if t.random:
- self.mu += coef[t.group_index][:, None] * t.predictor
+ self.mu -= coef[t.group_index][:, None] * t.predictor
else:
self.mu += pm.math.dot(data, coef)[:, None]
Mutant 725
--- bambi/backends/pymc.py
+++ bambi/backends/pymc.py
@@ -100,7 +100,7 @@
if t.random:
self.mu += coef[t.group_index][:, None] * t.predictor
else:
- self.mu += pm.math.dot(data, coef)[:, None]
+ self.mu = pm.math.dot(data, coef)[:, None]
y = spec.y.data
y_prior = spec.family.prior
Mutant 734
--- bambi/backends/pymc.py
+++ bambi/backends/pymc.py
@@ -112,7 +112,7 @@
y_prior.args[spec.family.parent] = link_f(self.mu)
y_prior.args["observed"] = y
self._build_dist(spec, spec.y.name, y_prior.name, **y_prior.args)
- self.spec = spec
+ self.spec = None
# pylint: disable=arguments-differ, inconsistent-return-statements
def run(self, start=None, method="mcmc", init="auto", n_init=50000, **kwargs):
Mutant 737
--- bambi/backends/pymc.py
+++ bambi/backends/pymc.py
@@ -115,7 +115,7 @@
self.spec = spec
# pylint: disable=arguments-differ, inconsistent-return-statements
- def run(self, start=None, method="mcmc", init="auto", n_init=50000, **kwargs):
+ def run(self, start=None, method="mcmc", init="auto", n_init=50001, **kwargs):
"""Run the PyMC3 MCMC sampler.
Parameters
Mutant 742
--- bambi/backends/pymc.py
+++ bambi/backends/pymc.py
@@ -143,7 +143,7 @@
model = self.model
if method.lower() == "mcmc":
- samples = kwargs.pop("samples", 1000)
+ samples = kwargs.pop("samples", 1001)
with model:
self.trace = pm.sample(samples, start=start, init=init, n_init=n_init, **kwargs)
Mutant 746
--- bambi/backends/pymc.py
+++ bambi/backends/pymc.py
@@ -149,7 +149,7 @@
return from_pymc3(self.trace, model=model)
- elif method.lower() == "advi":
+ elif method.lower() == "XXadviXX":
with model:
self.advi_params = pm.variational.ADVI(start, **kwargs)
return (
Mutant 754
--- bambi/backends/pymc.py
+++ bambi/backends/pymc.py
@@ -178,7 +178,7 @@
varis = [v for v in model.unobserved_RVs if not pm.util.is_transformed_name(v.name)]
maps = pm.find_MAP(start=model.test_point, vars=varis)
hessian = pm.find_hessian(maps, vars=varis)
- if np.linalg.det(hessian) == 0:
+ if np.linalg.det(hessian) == 1:
raise np.linalg.LinAlgError("Singular matrix. Use mcmc or advi method")
stds = np.diag(np.linalg.inv(hessian) ** 0.5)
maps = [v for (k, v) in maps.items() if not pm.util.is_transformed_name(k)]
Mutant 760
--- bambi/backends/pymc.py
+++ bambi/backends/pymc.py
@@ -182,7 +182,7 @@
raise np.linalg.LinAlgError("Singular matrix. Use mcmc or advi method")
stds = np.diag(np.linalg.inv(hessian) ** 0.5)
maps = [v for (k, v) in maps.items() if not pm.util.is_transformed_name(k)]
- modes = [v.item() if v.size == 1 else v for v in maps]
+ modes = [v.item() if v.size != 1 else v for v in maps]
names = [v.name for v in varis]
shapes = [np.atleast_1d(mode).shape for mode in modes]
stds_reshaped = []
Mutant 761
--- bambi/backends/pymc.py
+++ bambi/backends/pymc.py
@@ -182,7 +182,7 @@
raise np.linalg.LinAlgError("Singular matrix. Use mcmc or advi method")
stds = np.diag(np.linalg.inv(hessian) ** 0.5)
maps = [v for (k, v) in maps.items() if not pm.util.is_transformed_name(k)]
- modes = [v.item() if v.size == 1 else v for v in maps]
+ modes = [v.item() if v.size == 2 else v for v in maps]
names = [v.name for v in varis]
shapes = [np.atleast_1d(mode).shape for mode in modes]
stds_reshaped = []
Mutant 769
--- bambi/backends/pymc.py
+++ bambi/backends/pymc.py
@@ -188,7 +188,7 @@
stds_reshaped = []
idx0 = 0
for shape in shapes:
- idx1 = idx0 + sum(shape)
+ idx1 = None
stds_reshaped.append(np.reshape(stds[idx0:idx1], shape))
idx0 = idx1
return dict(zip(names, zip(modes, stds_reshaped)))
Mutant 770
--- bambi/backends/pymc.py
+++ bambi/backends/pymc.py
@@ -190,6 +190,6 @@
for shape in shapes:
idx1 = idx0 + sum(shape)
stds_reshaped.append(np.reshape(stds[idx0:idx1], shape))
- idx0 = idx1
+ idx0 = None
return dict(zip(names, zip(modes, stds_reshaped)))