bambi/models.py

Killed 176 out of 291 mutants

Survived

Survived mutation testing. These mutants show holes in your test suite.

Mutant 261

--- bambi/models.py
+++ bambi/models.py
@@ -56,7 +56,7 @@
         auto_scale=True,
         dropna=False,
         taylor=None,
-        noncentered=True,
+        noncentered=False,
     ):
 
         if isinstance(data, str):

Mutant 270

--- bambi/models.py
+++ bambi/models.py
@@ -69,7 +69,7 @@
         self.data = data
         # Some random effects stuff later requires us to make guesses about
         # column groupings into terms based on patsy's naming scheme.
-        if re.search(r"[\[\]]+", "".join(data.columns)):
+        if re.search(r"[\[\]]+", "XXXX".join(data.columns)):
             warnings.warn(
                 "At least one of the column names in the specified "
                 "dataset contain square brackets ('[' or ']')."

Mutant 271

--- bambi/models.py
+++ bambi/models.py
@@ -79,7 +79,7 @@
             )
         self.reset()
 
-        self.auto_scale = auto_scale
+        self.auto_scale = None
         self.dropna = dropna
         self.taylor = taylor
         self.noncentered = noncentered

Mutant 273

--- bambi/models.py
+++ bambi/models.py
@@ -81,7 +81,7 @@
 
         self.auto_scale = auto_scale
         self.dropna = dropna
-        self.taylor = taylor
+        self.taylor = None
         self.noncentered = noncentered
         self._backend_name = None
 

Mutant 274

--- bambi/models.py
+++ bambi/models.py
@@ -82,7 +82,7 @@
         self.auto_scale = auto_scale
         self.dropna = dropna
         self.taylor = taylor
-        self.noncentered = noncentered
+        self.noncentered = None
         self._backend_name = None
 
         # build() will loop over these, calling _add() and _set_priors()

Mutant 275

--- bambi/models.py
+++ bambi/models.py
@@ -83,7 +83,7 @@
         self.dropna = dropna
         self.taylor = taylor
         self.noncentered = noncentered
-        self._backend_name = None
+        self._backend_name = ""
 
         # build() will loop over these, calling _add() and _set_priors()
         self.added_terms = []

Mutant 279

--- bambi/models.py
+++ bambi/models.py
@@ -91,7 +91,7 @@
 
         # if dropna=True, completes gets updated by add() to track complete cases
         self.completes = []
-        self.clean_data = None
+        self.clean_data = ""
 
         # attributes that are set later
         self.y = None  # _add_y()

Mutant 280

--- bambi/models.py
+++ bambi/models.py
@@ -94,7 +94,7 @@
         self.clean_data = None
 
         # attributes that are set later
-        self.y = None  # _add_y()
+        self.y = ""  # _add_y()
         self.family = None  # _add_y()
         self.backend = None  # _set_backend()
         self.dm_statistics = None  # build()

Mutant 281

--- bambi/models.py
+++ bambi/models.py
@@ -95,7 +95,7 @@
 
         # attributes that are set later
         self.y = None  # _add_y()
-        self.family = None  # _add_y()
+        self.family = ""  # _add_y()
         self.backend = None  # _set_backend()
         self.dm_statistics = None  # build()
         self._diagnostics = None  # build()

Mutant 282

--- bambi/models.py
+++ bambi/models.py
@@ -96,7 +96,7 @@
         # attributes that are set later
         self.y = None  # _add_y()
         self.family = None  # _add_y()
-        self.backend = None  # _set_backend()
+        self.backend = ""  # _set_backend()
         self.dm_statistics = None  # build()
         self._diagnostics = None  # build()
         self.built = False  # build()

Mutant 283

--- bambi/models.py
+++ bambi/models.py
@@ -97,7 +97,7 @@
         self.y = None  # _add_y()
         self.family = None  # _add_y()
         self.backend = None  # _set_backend()
-        self.dm_statistics = None  # build()
+        self.dm_statistics = ""  # build()
         self._diagnostics = None  # build()
         self.built = False  # build()
 

Mutant 284

--- bambi/models.py
+++ bambi/models.py
@@ -98,7 +98,7 @@
         self.family = None  # _add_y()
         self.backend = None  # _set_backend()
         self.dm_statistics = None  # build()
-        self._diagnostics = None  # build()
+        self._diagnostics = ""  # build()
         self.built = False  # build()
 
     def reset(self):

Mutant 285

--- bambi/models.py
+++ bambi/models.py
@@ -99,7 +99,7 @@
         self.backend = None  # _set_backend()
         self.dm_statistics = None  # build()
         self._diagnostics = None  # build()
-        self.built = False  # build()
+        self.built = True  # build()
 
     def reset(self):
         """Reset list of terms and y-variable."""

Mutant 286

--- bambi/models.py
+++ bambi/models.py
@@ -99,7 +99,7 @@
         self.backend = None  # _set_backend()
         self.dm_statistics = None  # build()
         self._diagnostics = None  # build()
-        self.built = False  # build()
+        self.built = None  # build()
 
     def reset(self):
         """Reset list of terms and y-variable."""

Mutant 288

--- bambi/models.py
+++ bambi/models.py
@@ -104,7 +104,7 @@
     def reset(self):
         """Reset list of terms and y-variable."""
         self.terms = OrderedDict()
-        self.y = None
+        self.y = ""
         self.backend = None
         self.added_terms = []
         self._added_priors = {}

Mutant 289

--- bambi/models.py
+++ bambi/models.py
@@ -105,7 +105,7 @@
         """Reset list of terms and y-variable."""
         self.terms = OrderedDict()
         self.y = None
-        self.backend = None
+        self.backend = ""
         self.added_terms = []
         self._added_priors = {}
         self.completes = []

Mutant 293

--- bambi/models.py
+++ bambi/models.py
@@ -109,7 +109,7 @@
         self.added_terms = []
         self._added_priors = {}
         self.completes = []
-        self.clean_data = None
+        self.clean_data = ""
 
     def _set_backend(self, backend):
         backend = backend.lower()

Mutant 297

--- bambi/models.py
+++ bambi/models.py
@@ -120,7 +120,7 @@
         else:
             raise ValueError("At the moment, only the PyMC3 backend is supported.")
 
-        self._backend_name = backend
+        self._backend_name = None
 
     def build(self, backend=None):
         """Set up the model for sampling/fitting.

Mutant 303

--- bambi/models.py
+++ bambi/models.py
@@ -144,7 +144,7 @@
             completes = range(len(self.data.index))
         self.clean_data = self.data.iloc[list(completes), :]
         # warn the user about any dropped rows
-        if len(completes) < n_total:
+        if len(completes) <= n_total:
             msg = "Automatically removing {}/{} rows from the dataset."
             msg = msg.format(n_total - len(completes), n_total)
             warnings.warn(msg)

Mutant 304

--- bambi/models.py
+++ bambi/models.py
@@ -145,7 +145,7 @@
         self.clean_data = self.data.iloc[list(completes), :]
         # warn the user about any dropped rows
         if len(completes) < n_total:
-            msg = "Automatically removing {}/{} rows from the dataset."
+            msg = "XXAutomatically removing {}/{} rows from the dataset.XX"
             msg = msg.format(n_total - len(completes), n_total)
             warnings.warn(msg)
 

Mutant 306

--- bambi/models.py
+++ bambi/models.py
@@ -146,7 +146,7 @@
         # warn the user about any dropped rows
         if len(completes) < n_total:
             msg = "Automatically removing {}/{} rows from the dataset."
-            msg = msg.format(n_total - len(completes), n_total)
+            msg = msg.format(n_total + len(completes), n_total)
             warnings.warn(msg)
 
         # loop over the added terms and actually _add() them

Mutant 307

--- bambi/models.py
+++ bambi/models.py
@@ -146,7 +146,7 @@
         # warn the user about any dropped rows
         if len(completes) < n_total:
             msg = "Automatically removing {}/{} rows from the dataset."
-            msg = msg.format(n_total - len(completes), n_total)
+            msg = None
             warnings.warn(msg)
 
         # loop over the added terms and actually _add() them

Mutant 309

--- bambi/models.py
+++ bambi/models.py
@@ -160,7 +160,7 @@
         for name, term in self.terms.items():
             type_ = (
                 "intercept"
-                if name == "Intercept"
+                if name == "XXInterceptXX"
                 else "random"
                 if self.terms[name].random
                 else "fixed"

Mutant 315

--- bambi/models.py
+++ bambi/models.py
@@ -187,7 +187,7 @@
         # X = fixed effects design matrix (excluding intercept/constant term)
         # r2_x = 1 - 1/VIF, i.e., R2 for predicting each x from all other x's.
         # only compute these stats if there are multiple terms in the model
-        terms = [t for t in self.fixed_terms.values() if t.name != "Intercept"]
+        terms = [t for t in self.fixed_terms.values() if t.name != "XXInterceptXX"]
 
         if len(self.fixed_terms) > 1:
 

Mutant 317

--- bambi/models.py
+++ bambi/models.py
@@ -189,7 +189,7 @@
         # only compute these stats if there are multiple terms in the model
         terms = [t for t in self.fixed_terms.values() if t.name != "Intercept"]
 
-        if len(self.fixed_terms) > 1:
+        if len(self.fixed_terms) >= 1:
 
             x_matrix = [pd.DataFrame(x.data, columns=x.levels) for x in terms]
             x_matrix = pd.concat(x_matrix, axis=1)

Mutant 318

--- bambi/models.py
+++ bambi/models.py
@@ -189,7 +189,7 @@
         # only compute these stats if there are multiple terms in the model
         terms = [t for t in self.fixed_terms.values() if t.name != "Intercept"]
 
-        if len(self.fixed_terms) > 1:
+        if len(self.fixed_terms) > 2:
 
             x_matrix = [pd.DataFrame(x.data, columns=x.levels) for x in terms]
             x_matrix = pd.concat(x_matrix, axis=1)

Mutant 323

--- bambi/models.py
+++ bambi/models.py
@@ -208,7 +208,7 @@
                         for x in list(x_matrix.columns)
                     }
                 ),
-                "sigma_x": x_matrix.std(),
+                "XXsigma_xXX": x_matrix.std(),
                 "mean_x": x_matrix.mean(axis=0),
             }
 

Mutant 328

--- bambi/models.py
+++ bambi/models.py
@@ -216,7 +216,7 @@
             # mat = correlation matrix of X, w/ diagonal replaced by X means
             mat = x_matrix.corr()
             for x_col in list(mat.columns):
-                mat.loc[x_col, x_col] = self.dm_statistics["mean_x"][x_col]
+                mat.loc[x_col, x_col] = None
             self._diagnostics = {
                 # the Variance Inflation Factors (VIF), which is possibly
                 # useful for diagnostics

Mutant 329

--- bambi/models.py
+++ bambi/models.py
@@ -220,7 +220,7 @@
             self._diagnostics = {
                 # the Variance Inflation Factors (VIF), which is possibly
                 # useful for diagnostics
-                "VIF": 1 / (1 - self.dm_statistics["r2_x"]),
+                "XXVIFXX": 1 / (1 - self.dm_statistics["r2_x"]),
                 "corr_mean_X": mat,
             }
 

Mutant 330

--- bambi/models.py
+++ bambi/models.py
@@ -220,7 +220,7 @@
             self._diagnostics = {
                 # the Variance Inflation Factors (VIF), which is possibly
                 # useful for diagnostics
-                "VIF": 1 / (1 - self.dm_statistics["r2_x"]),
+                "VIF": 2 / (1 - self.dm_statistics["r2_x"]),
                 "corr_mean_X": mat,
             }
 

Mutant 331

--- bambi/models.py
+++ bambi/models.py
@@ -220,7 +220,7 @@
             self._diagnostics = {
                 # the Variance Inflation Factors (VIF), which is possibly
                 # useful for diagnostics
-                "VIF": 1 / (1 - self.dm_statistics["r2_x"]),
+                "VIF": 1 * (1 - self.dm_statistics["r2_x"]),
                 "corr_mean_X": mat,
             }
 

Mutant 333

--- bambi/models.py
+++ bambi/models.py
@@ -220,7 +220,7 @@
             self._diagnostics = {
                 # the Variance Inflation Factors (VIF), which is possibly
                 # useful for diagnostics
-                "VIF": 1 / (1 - self.dm_statistics["r2_x"]),
+                "VIF": 1 / (1 + self.dm_statistics["r2_x"]),
                 "corr_mean_X": mat,
             }
 

Mutant 335

--- bambi/models.py
+++ bambi/models.py
@@ -221,7 +221,7 @@
                 # the Variance Inflation Factors (VIF), which is possibly
                 # useful for diagnostics
                 "VIF": 1 / (1 - self.dm_statistics["r2_x"]),
-                "corr_mean_X": mat,
+                "XXcorr_mean_XXX": mat,
             }
 
             # throw informative error if perfect collinearity among fixed fx

Mutant 337

--- bambi/models.py
+++ bambi/models.py
@@ -225,7 +225,7 @@
             }
 
             # throw informative error if perfect collinearity among fixed fx
-            if any(self.dm_statistics["r2_x"] > 0.999):
+            if any(self.dm_statistics["r2_x"] >= 0.999):
                 raise ValueError(
                     "There is perfect collinearity among the fixed effects!\n"
                     "Printing some design matrix statistics:\n"

Mutant 338

--- bambi/models.py
+++ bambi/models.py
@@ -225,7 +225,7 @@
             }
 
             # throw informative error if perfect collinearity among fixed fx
-            if any(self.dm_statistics["r2_x"] > 0.999):
+            if any(self.dm_statistics["r2_x"] > 1.999):
                 raise ValueError(
                     "There is perfect collinearity among the fixed effects!\n"
                     "Printing some design matrix statistics:\n"

Mutant 341

--- bambi/models.py
+++ bambi/models.py
@@ -237,7 +237,7 @@
         # throw informative error message if any categorical predictors have 1
         # category
         num_cats = [x.data.size for x in self.fixed_terms.values()]
-        if any(np.array(num_cats) == 0):
+        if any(np.array(num_cats) == 1):
             raise ValueError("At least one categorical predictor contains only 1 category!")
 
         # only set priors if there is at least one term in the model

Mutant 344

--- bambi/models.py
+++ bambi/models.py
@@ -246,7 +246,7 @@
             if self.taylor is not None:
                 taylor = self.taylor
             else:
-                taylor = 5 if self.family.name == "gaussian" else 1
+                taylor = 5 if self.family.name != "gaussian" else 1
             scaler = PriorScaler(self, taylor=taylor)
             scaler.scale()
 

Mutant 345

--- bambi/models.py
+++ bambi/models.py
@@ -246,7 +246,7 @@
             if self.taylor is not None:
                 taylor = self.taylor
             else:
-                taylor = 5 if self.family.name == "gaussian" else 1
+                taylor = 5 if self.family.name == "XXgaussianXX" else 1
             scaler = PriorScaler(self, taylor=taylor)
             scaler.scale()
 

Mutant 346

--- bambi/models.py
+++ bambi/models.py
@@ -246,7 +246,7 @@
             if self.taylor is not None:
                 taylor = self.taylor
             else:
-                taylor = 5 if self.family.name == "gaussian" else 1
+                taylor = 5 if self.family.name == "gaussian" else 2
             scaler = PriorScaler(self, taylor=taylor)
             scaler.scale()
 

Mutant 349

--- bambi/models.py
+++ bambi/models.py
@@ -252,7 +252,7 @@
 
         # For bernoulli models with n_trials = 1 (most common use case),
         # tell user which event is being modeled
-        if self.family.name == "bernoulli" and np.max(self.y.data) < 1.01:
+        if self.family.name != "bernoulli" and np.max(self.y.data) < 1.01:
             event = next(i for i, x in enumerate(self.y.data.flatten()) if x > 0.99)
             warnings.warn(
                 "Modeling the probability that {}=='{}'".format(

Mutant 350

--- bambi/models.py
+++ bambi/models.py
@@ -252,7 +252,7 @@
 
         # For bernoulli models with n_trials = 1 (most common use case),
         # tell user which event is being modeled
-        if self.family.name == "bernoulli" and np.max(self.y.data) < 1.01:
+        if self.family.name == "XXbernoulliXX" and np.max(self.y.data) < 1.01:
             event = next(i for i, x in enumerate(self.y.data.flatten()) if x > 0.99)
             warnings.warn(
                 "Modeling the probability that {}=='{}'".format(

Mutant 352

--- bambi/models.py
+++ bambi/models.py
@@ -252,7 +252,7 @@
 
         # For bernoulli models with n_trials = 1 (most common use case),
         # tell user which event is being modeled
-        if self.family.name == "bernoulli" and np.max(self.y.data) < 1.01:
+        if self.family.name == "bernoulli" and np.max(self.y.data) < 2.01:
             event = next(i for i, x in enumerate(self.y.data.flatten()) if x > 0.99)
             warnings.warn(
                 "Modeling the probability that {}=='{}'".format(

Mutant 354

--- bambi/models.py
+++ bambi/models.py
@@ -253,7 +253,7 @@
         # For bernoulli models with n_trials = 1 (most common use case),
         # tell user which event is being modeled
         if self.family.name == "bernoulli" and np.max(self.y.data) < 1.01:
-            event = next(i for i, x in enumerate(self.y.data.flatten()) if x > 0.99)
+            event = next(i for i, x in enumerate(self.y.data.flatten()) if x >= 0.99)
             warnings.warn(
                 "Modeling the probability that {}=='{}'".format(
                     self.y.name, str(self.clean_data[self.y.name].iloc[event])

Mutant 358

--- bambi/models.py
+++ bambi/models.py
@@ -262,7 +262,7 @@
 
         self._set_backend(backend)
         self.backend.build(self)
-        self.built = True
+        self.built = False
 
     def fit(
         self,

Mutant 359

--- bambi/models.py
+++ bambi/models.py
@@ -262,7 +262,7 @@
 
         self._set_backend(backend)
         self.backend.build(self)
-        self.built = True
+        self.built = None
 
     def fit(
         self,

Mutant 363

--- bambi/models.py
+++ bambi/models.py
@@ -318,7 +318,7 @@
                 family=family,
                 link=link,
                 categorical=categorical,
-                append=False,
+                append=True,
             )
 
         # Run the BackEnd to fit the model.

Mutant 364

--- bambi/models.py
+++ bambi/models.py
@@ -322,7 +322,7 @@
             )
 
         # Run the BackEnd to fit the model.
-        if backend is None:
+        if backend is not None:
             backend = "pymc" if self._backend_name is None else self._backend_name
 
         if run:

Mutant 365

--- bambi/models.py
+++ bambi/models.py
@@ -323,7 +323,7 @@
 
         # Run the BackEnd to fit the model.
         if backend is None:
-            backend = "pymc" if self._backend_name is None else self._backend_name
+            backend = "XXpymcXX" if self._backend_name is None else self._backend_name
 
         if run:
             if not self.built or backend != self._backend_name:

Mutant 366

--- bambi/models.py
+++ bambi/models.py
@@ -323,7 +323,7 @@
 
         # Run the BackEnd to fit the model.
         if backend is None:
-            backend = "pymc" if self._backend_name is None else self._backend_name
+            backend = "pymc" if self._backend_name is not None else self._backend_name
 
         if run:
             if not self.built or backend != self._backend_name:

Mutant 367

--- bambi/models.py
+++ bambi/models.py
@@ -323,7 +323,7 @@
 
         # Run the BackEnd to fit the model.
         if backend is None:
-            backend = "pymc" if self._backend_name is None else self._backend_name
+            backend = None
 
         if run:
             if not self.built or backend != self._backend_name:

Mutant 368

--- bambi/models.py
+++ bambi/models.py
@@ -326,7 +326,7 @@
             backend = "pymc" if self._backend_name is None else self._backend_name
 
         if run:
-            if not self.built or backend != self._backend_name:
+            if  self.built or backend != self._backend_name:
                 self.build(backend)
             return self.backend.run(**kwargs)
 

Mutant 369

--- bambi/models.py
+++ bambi/models.py
@@ -326,7 +326,7 @@
             backend = "pymc" if self._backend_name is None else self._backend_name
 
         if run:
-            if not self.built or backend != self._backend_name:
+            if not self.built or backend == self._backend_name:
                 self.build(backend)
             return self.backend.run(**kwargs)
 

Mutant 370

--- bambi/models.py
+++ bambi/models.py
@@ -326,7 +326,7 @@
             backend = "pymc" if self._backend_name is None else self._backend_name
 
         if run:
-            if not self.built or backend != self._backend_name:
+            if not self.built and backend != self._backend_name:
                 self.build(backend)
             return self.backend.run(**kwargs)
 

Mutant 376

--- bambi/models.py
+++ bambi/models.py
@@ -391,7 +391,7 @@
 
         # Explicitly convert columns to category if desired--though this
         # can also be done within the formula using C().
-        if categorical is not None:
+        if categorical is  None:
             data = data.copy()
             cats = listify(categorical)
             data[cats] = data[cats].apply(lambda x: x.astype("category"))

Mutant 384

--- bambi/models.py
+++ bambi/models.py
@@ -409,7 +409,7 @@
                 dmatrix(fixed, data=data, NA_action=NA_handler)
 
         # screen random terms
-        if random is not None:
+        if random is  None:
             for term in listify(random):
                 for side in term.split("|"):
                     dmatrix(side, data=data, NA_action=NA_handler)

Mutant 392

--- bambi/models.py
+++ bambi/models.py
@@ -427,7 +427,7 @@
         )
         self.added_terms.append(args)
 
-        self.built = False
+        self.built = True
 
     def _add(
         self, fixed=None, random=None, priors=None, family="gaussian", link=None, categorical=None,

Mutant 394

--- bambi/models.py
+++ bambi/models.py
@@ -430,7 +430,7 @@
         self.built = False
 
     def _add(
-        self, fixed=None, random=None, priors=None, family="gaussian", link=None, categorical=None,
+        self, fixed=None, random=None, priors=None, family="XXgaussianXX", link=None, categorical=None,
     ):
         """Internal version of add(), with the same arguments.
 

Mutant 397

--- bambi/models.py
+++ bambi/models.py
@@ -439,7 +439,7 @@
         # use cleaned data with NAs removed (if user requested)
         data = self.clean_data
         # alter this pandas flag to avoid false positive SettingWithCopyWarnings
-        data._is_copy = False  # pylint: disable=protected-access
+        data._is_copy = None  # pylint: disable=protected-access
 
         # Explicitly convert columns to category if desired--though this
         # can also be done within the formula using C().

Mutant 398

--- bambi/models.py
+++ bambi/models.py
@@ -443,7 +443,7 @@
 
         # Explicitly convert columns to category if desired--though this
         # can also be done within the formula using C().
-        if categorical is not None:
+        if categorical is  None:
             data = data.copy()
             cats = listify(categorical)
             data[cats] = data[cats].apply(lambda x: x.astype("category"))

Mutant 416

--- bambi/models.py
+++ bambi/models.py
@@ -462,7 +462,7 @@
                 if event is not None:
                     # pass in new Y data that has 1 if y=event and 0 otherwise
                     y_data = y_vector[:, y_vector.design_info.column_names.index(event.group(1))]
-                    y_data = pd.DataFrame({event.group(3): y_data})
+                    y_data = pd.DataFrame({event.group(4): y_data})
                     self._add_y(y_label, family=family, link=link, data=y_data)
                 else:
                     # use Y as-is

Mutant 422

--- bambi/models.py
+++ bambi/models.py
@@ -474,7 +474,7 @@
             for _name, _slice in x_matrix.design_info.term_name_slices.items():
                 cols = x_matrix.design_info.column_names[_slice]
                 term_data = pd.DataFrame(np.asfortranarray(x_matrix[:, _slice]), columns=cols)
-                prior = priors.pop(_name, priors.get("fixed", None))
+                prior = priors.pop(_name, priors.get("XXfixedXX", None))
                 self.terms[_name] = Term(_name, term_data, prior=prior)
 
         # Random effects

Mutant 423

--- bambi/models.py
+++ bambi/models.py
@@ -474,7 +474,7 @@
             for _name, _slice in x_matrix.design_info.term_name_slices.items():
                 cols = x_matrix.design_info.column_names[_slice]
                 term_data = pd.DataFrame(np.asfortranarray(x_matrix[:, _slice]), columns=cols)
-                prior = priors.pop(_name, priors.get("fixed", None))
+                prior = None
                 self.terms[_name] = Term(_name, term_data, prior=prior)
 
         # Random effects

Mutant 431

--- bambi/models.py
+++ bambi/models.py
@@ -489,7 +489,7 @@
                 patt = r"^([01]+)*[\s\+]*([^\|]+)*\|(.*)"
 
                 intcpt, pred, grpr = re.search(patt, random_effect).groups()
-                label = "{}|{}".format(pred, grpr) if pred else grpr
+                label = "XX{}|{}XX".format(pred, grpr) if pred else grpr
                 prior = priors.pop(label, priors.get("random", None))
 
                 # Treat all grouping variables as categoricals, regardless of

Mutant 432

--- bambi/models.py
+++ bambi/models.py
@@ -489,7 +489,7 @@
                 patt = r"^([01]+)*[\s\+]*([^\|]+)*\|(.*)"
 
                 intcpt, pred, grpr = re.search(patt, random_effect).groups()
-                label = "{}|{}".format(pred, grpr) if pred else grpr
+                label = None
                 prior = priors.pop(label, priors.get("random", None))
 
                 # Treat all grouping variables as categoricals, regardless of

Mutant 433

--- bambi/models.py
+++ bambi/models.py
@@ -490,7 +490,7 @@
 
                 intcpt, pred, grpr = re.search(patt, random_effect).groups()
                 label = "{}|{}".format(pred, grpr) if pred else grpr
-                prior = priors.pop(label, priors.get("random", None))
+                prior = priors.pop(label, priors.get("XXrandomXX", None))
 
                 # Treat all grouping variables as categoricals, regardless of
                 # their dtype and what the user may have specified in the

Mutant 434

--- bambi/models.py
+++ bambi/models.py
@@ -490,7 +490,7 @@
 
                 intcpt, pred, grpr = re.search(patt, random_effect).groups()
                 label = "{}|{}".format(pred, grpr) if pred else grpr
-                prior = priors.pop(label, priors.get("random", None))
+                prior = None
 
                 # Treat all grouping variables as categoricals, regardless of
                 # their dtype and what the user may have specified in the

Mutant 435

--- bambi/models.py
+++ bambi/models.py
@@ -495,7 +495,7 @@
                 # Treat all grouping variables as categoricals, regardless of
                 # their dtype and what the user may have specified in the
                 # 'categorical' argument.
-                var_names = re.findall(r"(\w+)", grpr)
+                var_names = re.findall(r"XX(\w+)XX", grpr)
                 for var_name in var_names:
                     if var_name in data.columns:
                         data.loc[:, var_name] = data.loc[:, var_name].astype("category")

Mutant 437

--- bambi/models.py
+++ bambi/models.py
@@ -497,7 +497,7 @@
                 # 'categorical' argument.
                 var_names = re.findall(r"(\w+)", grpr)
                 for var_name in var_names:
-                    if var_name in data.columns:
+                    if var_name not in data.columns:
                         data.loc[:, var_name] = data.loc[:, var_name].astype("category")
                         self.clean_data.loc[:, var_name] = data.loc[:, var_name]
 

Mutant 449

--- bambi/models.py
+++ bambi/models.py
@@ -507,7 +507,7 @@
                 grpr_df = dmatrix(f"0+{grpr}", data, return_type="dataframe", NA_action="raise")
 
                 # If there's no predictor, we must be adding random intercepts
-                if not pred and grpr not in self.terms:
+                if not pred or grpr not in self.terms:
                     name = "1|" + grpr
                     pred = np.ones((len(grpr_df), 1))
                     term = RandomTerm(

Mutant 450

--- bambi/models.py
+++ bambi/models.py
@@ -508,7 +508,7 @@
 
                 # If there's no predictor, we must be adding random intercepts
                 if not pred and grpr not in self.terms:
-                    name = "1|" + grpr
+                    name = "XX1|XX" + grpr
                     pred = np.ones((len(grpr_df), 1))
                     term = RandomTerm(
                         name, grpr_df, pred, grpr_df.values, categorical=True, prior=prior

Mutant 453

--- bambi/models.py
+++ bambi/models.py
@@ -509,7 +509,7 @@
                 # If there's no predictor, we must be adding random intercepts
                 if not pred and grpr not in self.terms:
                     name = "1|" + grpr
-                    pred = np.ones((len(grpr_df), 1))
+                    pred = np.ones((len(grpr_df), 2))
                     term = RandomTerm(
                         name, grpr_df, pred, grpr_df.values, categorical=True, prior=prior
                     )

Mutant 454

--- bambi/models.py
+++ bambi/models.py
@@ -509,7 +509,7 @@
                 # If there's no predictor, we must be adding random intercepts
                 if not pred and grpr not in self.terms:
                     name = "1|" + grpr
-                    pred = np.ones((len(grpr_df), 1))
+                    pred = None
                     term = RandomTerm(
                         name, grpr_df, pred, grpr_df.values, categorical=True, prior=prior
                     )

Mutant 455

--- bambi/models.py
+++ bambi/models.py
@@ -511,7 +511,7 @@
                     name = "1|" + grpr
                     pred = np.ones((len(grpr_df), 1))
                     term = RandomTerm(
-                        name, grpr_df, pred, grpr_df.values, categorical=True, prior=prior
+                        name, grpr_df, pred, grpr_df.values, categorical=False, prior=prior
                     )
                     self.terms[name] = term
                 else:

Mutant 456

--- bambi/models.py
+++ bambi/models.py
@@ -513,7 +513,7 @@
                     term = RandomTerm(
                         name, grpr_df, pred, grpr_df.values, categorical=True, prior=prior
                     )
-                    self.terms[name] = term
+                    self.terms[name] = None
                 else:
                     pred_df = dmatrix(
                         f"{intcpt}+{pred}", data, return_type="dataframe", NA_action="raise"

Mutant 466

--- bambi/models.py
+++ bambi/models.py
@@ -528,7 +528,7 @@
                         # Also rename intercepts and skip if already added.
                         # This can happen if user specifies something like
                         # random=['1|school', 'student|school'].
-                        if col == "Intercept":
+                        if col != "Intercept":
                             if grpr in self.terms:
                                 continue
                             label = f"1|{grpr}"

Mutant 467

--- bambi/models.py
+++ bambi/models.py
@@ -528,7 +528,7 @@
                         # Also rename intercepts and skip if already added.
                         # This can happen if user specifies something like
                         # random=['1|school', 'student|school'].
-                        if col == "Intercept":
+                        if col == "XXInterceptXX":
                             if grpr in self.terms:
                                 continue
                             label = f"1|{grpr}"

Mutant 468

--- bambi/models.py
+++ bambi/models.py
@@ -529,7 +529,7 @@
                         # This can happen if user specifies something like
                         # random=['1|school', 'student|school'].
                         if col == "Intercept":
-                            if grpr in self.terms:
+                            if grpr not in self.terms:
                                 continue
                             label = f"1|{grpr}"
                         else:

Mutant 471

--- bambi/models.py
+++ bambi/models.py
@@ -533,7 +533,7 @@
                                 continue
                             label = f"1|{grpr}"
                         else:
-                            label = col + "|" + grpr
+                            label = col + "XX|XX" + grpr
 
                         prior = priors.pop(label, priors.get("random", None))
 

Mutant 474

--- bambi/models.py
+++ bambi/models.py
@@ -535,7 +535,7 @@
                         else:
                             label = col + "|" + grpr
 
-                        prior = priors.pop(label, priors.get("random", None))
+                        prior = priors.pop(label, priors.get("XXrandomXX", None))
 
                         # Categorical or continuous is determined from data
                         ld_vals = lev_data.values

Mutant 475

--- bambi/models.py
+++ bambi/models.py
@@ -535,7 +535,7 @@
                         else:
                             label = col + "|" + grpr
 
-                        prior = priors.pop(label, priors.get("random", None))
+                        prior = None
 
                         # Categorical or continuous is determined from data
                         ld_vals = lev_data.values

Mutant 477

--- bambi/models.py
+++ bambi/models.py
@@ -539,7 +539,7 @@
 
                         # Categorical or continuous is determined from data
                         ld_vals = lev_data.values
-                        if ((ld_vals == 0) | (ld_vals == 1)).all():
+                        if ((ld_vals != 0) | (ld_vals == 1)).all():
                             lev_data = lev_data.astype(int)
                             cat = True
                         else:

Mutant 478

--- bambi/models.py
+++ bambi/models.py
@@ -539,7 +539,7 @@
 
                         # Categorical or continuous is determined from data
                         ld_vals = lev_data.values
-                        if ((ld_vals == 0) | (ld_vals == 1)).all():
+                        if ((ld_vals == 1) | (ld_vals == 1)).all():
                             lev_data = lev_data.astype(int)
                             cat = True
                         else:

Mutant 479

--- bambi/models.py
+++ bambi/models.py
@@ -539,7 +539,7 @@
 
                         # Categorical or continuous is determined from data
                         ld_vals = lev_data.values
-                        if ((ld_vals == 0) | (ld_vals == 1)).all():
+                        if ((ld_vals == 0) & (ld_vals == 1)).all():
                             lev_data = lev_data.astype(int)
                             cat = True
                         else:

Mutant 480

--- bambi/models.py
+++ bambi/models.py
@@ -539,7 +539,7 @@
 
                         # Categorical or continuous is determined from data
                         ld_vals = lev_data.values
-                        if ((ld_vals == 0) | (ld_vals == 1)).all():
+                        if ((ld_vals == 0) | (ld_vals != 1)).all():
                             lev_data = lev_data.astype(int)
                             cat = True
                         else:

Mutant 481

--- bambi/models.py
+++ bambi/models.py
@@ -539,7 +539,7 @@
 
                         # Categorical or continuous is determined from data
                         ld_vals = lev_data.values
-                        if ((ld_vals == 0) | (ld_vals == 1)).all():
+                        if ((ld_vals == 0) | (ld_vals == 2)).all():
                             lev_data = lev_data.astype(int)
                             cat = True
                         else:

Mutant 483

--- bambi/models.py
+++ bambi/models.py
@@ -541,7 +541,7 @@
                         ld_vals = lev_data.values
                         if ((ld_vals == 0) | (ld_vals == 1)).all():
                             lev_data = lev_data.astype(int)
-                            cat = True
+                            cat = False
                         else:
                             cat = False
 

Mutant 484

--- bambi/models.py
+++ bambi/models.py
@@ -541,7 +541,7 @@
                         ld_vals = lev_data.values
                         if ((ld_vals == 0) | (ld_vals == 1)).all():
                             lev_data = lev_data.astype(int)
-                            cat = True
+                            cat = None
                         else:
                             cat = False
 

Mutant 485

--- bambi/models.py
+++ bambi/models.py
@@ -543,7 +543,7 @@
                             lev_data = lev_data.astype(int)
                             cat = True
                         else:
-                            cat = False
+                            cat = True
 
                         pred_data = pred_data[:, None]  # Must be 2D later
                         term = RandomTerm(

Mutant 486

--- bambi/models.py
+++ bambi/models.py
@@ -543,7 +543,7 @@
                             lev_data = lev_data.astype(int)
                             cat = True
                         else:
-                            cat = False
+                            cat = None
 
                         pred_data = pred_data[:, None]  # Must be 2D later
                         term = RandomTerm(

Mutant 489

--- bambi/models.py
+++ bambi/models.py
@@ -558,7 +558,7 @@
                         self.terms[label] = term
 
     # pylint: disable=keyword-arg-before-vararg
-    def _add_y(self, variable, prior=None, family="gaussian", link=None, *args, **kwargs):
+    def _add_y(self, variable, prior=None, family="XXgaussianXX", link=None, *args, **kwargs):
         """Add a dependent (or outcome) variable to the model.
 
         Parameters

Mutant 499

--- bambi/models.py
+++ bambi/models.py
@@ -594,7 +594,7 @@
             prior = self.family.prior
 
         if self.family.name == "gaussian":
-            prior.update(sigma=Prior("HalfStudentT", nu=4, sigma=self.clean_data[variable].std()))
+            prior.update(sigma=Prior("HalfStudentT", nu=5, sigma=self.clean_data[variable].std()))
 
         data = kwargs.pop("data", self.clean_data[variable])
         term = Term(variable, data, prior=prior, *args, **kwargs)

Mutant 504

--- bambi/models.py
+++ bambi/models.py
@@ -599,7 +599,7 @@
         data = kwargs.pop("data", self.clean_data[variable])
         term = Term(variable, data, prior=prior, *args, **kwargs)
         self.y = term
-        self.built = False
+        self.built = True
 
     def _match_derived_terms(self, name):
         """Return all (random) terms whose named are derived from the specified string.

Mutant 505

--- bambi/models.py
+++ bambi/models.py
@@ -599,7 +599,7 @@
         data = kwargs.pop("data", self.clean_data[variable])
         term = Term(variable, data, prior=prior, *args, **kwargs)
         self.y = term
-        self.built = False
+        self.built = None
 
     def _match_derived_terms(self, name):
         """Return all (random) terms whose named are derived from the specified string.

Mutant 506

--- bambi/models.py
+++ bambi/models.py
@@ -628,7 +628,7 @@
         # have been set by some other specification like 'gender|subject').
         return found if found and (len(found) > 1 or found[0].name != intcpt) else None
 
-    def set_priors(self, priors=None, fixed=None, random=None, match_derived_names=True):
+    def set_priors(self, priors=None, fixed=None, random=None, match_derived_names=False):
         """Set priors for one or more existing terms.
 
         Parameters

Mutant 507

--- bambi/models.py
+++ bambi/models.py
@@ -661,7 +661,7 @@
 
         self.built = False
 
-    def _set_priors(self, priors=None, fixed=None, random=None, match_derived_names=True):
+    def _set_priors(self, priors=None, fixed=None, random=None, match_derived_names=False):
         """Internal version of set_priors(), with same arguments.
 
         Runs during Model.build().

Mutant 509

--- bambi/models.py
+++ bambi/models.py
@@ -668,7 +668,7 @@
         """
         targets = {}
 
-        if fixed is not None:
+        if fixed is  None:
             targets.update({name: fixed for name in self.fixed_terms.keys()})
 
         if random is not None:

Mutant 510

--- bambi/models.py
+++ bambi/models.py
@@ -671,7 +671,7 @@
         if fixed is not None:
             targets.update({name: fixed for name in self.fixed_terms.keys()})
 
-        if random is not None:
+        if random is  None:
             targets.update({name: random for name in self.random_terms.keys()})
 
         if priors is not None:

Mutant 512

--- bambi/models.py
+++ bambi/models.py
@@ -700,7 +700,7 @@
         _type : string
             accepted values are: 'intercept, 'fixed', or 'random'.
         """
-        if prior is None and not self.auto_scale:
+        if prior is not None and not self.auto_scale:
             prior = self.default_priors.get(term=_type + "_flat")
 
         if isinstance(prior, Prior):

Mutant 513

--- bambi/models.py
+++ bambi/models.py
@@ -700,7 +700,7 @@
         _type : string
             accepted values are: 'intercept, 'fixed', or 'random'.
         """
-        if prior is None and not self.auto_scale:
+        if prior is None and  self.auto_scale:
             prior = self.default_priors.get(term=_type + "_flat")
 
         if isinstance(prior, Prior):

Mutant 514

--- bambi/models.py
+++ bambi/models.py
@@ -700,7 +700,7 @@
         _type : string
             accepted values are: 'intercept, 'fixed', or 'random'.
         """
-        if prior is None and not self.auto_scale:
+        if prior is None or not self.auto_scale:
             prior = self.default_priors.get(term=_type + "_flat")
 
         if isinstance(prior, Prior):

Mutant 515

--- bambi/models.py
+++ bambi/models.py
@@ -706,7 +706,7 @@
         if isinstance(prior, Prior):
             prior._auto_scale = False  # pylint: disable=protected-access
         else:
-            _scale = prior
+            _scale = None
             prior = self.default_priors.get(term=_type)
             prior.scale = _scale
             if prior.scale is not None:

Mutant 517

--- bambi/models.py
+++ bambi/models.py
@@ -708,7 +708,7 @@
         else:
             _scale = prior
             prior = self.default_priors.get(term=_type)
-            prior.scale = _scale
+            prior.scale = None
             if prior.scale is not None:
                 prior._auto_scale = False  # pylint: disable=protected-access
         return prior

Mutant 518

--- bambi/models.py
+++ bambi/models.py
@@ -709,7 +709,7 @@
             _scale = prior
             prior = self.default_priors.get(term=_type)
             prior.scale = _scale
-            if prior.scale is not None:
+            if prior.scale is  None:
                 prior._auto_scale = False  # pylint: disable=protected-access
         return prior
 

Mutant 524

--- bambi/models.py
+++ bambi/models.py
@@ -792,7 +792,7 @@
         treated as an intercept for prior distribution purposes.
     """
 
-    random = False
+    random = None
 
     def __init__(self, name, data, categorical=False, prior=None, constant=None):
         self.name = name

Mutant 525

--- bambi/models.py
+++ bambi/models.py
@@ -794,7 +794,7 @@
 
     random = False
 
-    def __init__(self, name, data, categorical=False, prior=None, constant=None):
+    def __init__(self, name, data, categorical=True, prior=None, constant=None):
         self.name = name
         self.categorical = categorical
         self._reduced_data = None

Mutant 528

--- bambi/models.py
+++ bambi/models.py
@@ -797,7 +797,7 @@
     def __init__(self, name, data, categorical=False, prior=None, constant=None):
         self.name = name
         self.categorical = categorical
-        self._reduced_data = None
+        self._reduced_data = ""
 
         if isinstance(data, pd.Series):
             data = data.to_frame()

Mutant 535

--- bambi/models.py
+++ bambi/models.py
@@ -815,7 +815,7 @@
         # identify and flag intercept and cell-means terms (i.e., full-rank
         # dummy codes), which receive special priors
         if constant is None:
-            self.constant = np.atleast_2d(data.T).T.sum(1).var() == 0
+            self.constant = np.atleast_2d(data.T).T.sum(1).var() != 0
         else:
             self.constant = constant
 

Mutant 536

--- bambi/models.py
+++ bambi/models.py
@@ -815,7 +815,7 @@
         # identify and flag intercept and cell-means terms (i.e., full-rank
         # dummy codes), which receive special priors
         if constant is None:
-            self.constant = np.atleast_2d(data.T).T.sum(1).var() == 0
+            self.constant = np.atleast_2d(data.T).T.sum(1).var() == 1
         else:
             self.constant = constant
 

Mutant 537

--- bambi/models.py
+++ bambi/models.py
@@ -815,7 +815,7 @@
         # identify and flag intercept and cell-means terms (i.e., full-rank
         # dummy codes), which receive special priors
         if constant is None:
-            self.constant = np.atleast_2d(data.T).T.sum(1).var() == 0
+            self.constant = None
         else:
             self.constant = constant
 

Mutant 539

--- bambi/models.py
+++ bambi/models.py
@@ -819,7 +819,7 @@
         else:
             self.constant = constant
 
-        self.prior = prior
+        self.prior = None
 
 
 class RandomTerm(Term):

Mutant 542

--- bambi/models.py
+++ bambi/models.py
@@ -826,7 +826,7 @@
     random = True
 
     def __init__(
-        self, name, data, predictor, grouper, categorical=False, prior=None, constant=None
+        self, name, data, predictor, grouper, categorical=True, prior=None, constant=None
     ):
 
         super(RandomTerm, self).__init__(name, data, categorical, prior, constant)

Mutant 543

--- bambi/models.py
+++ bambi/models.py
@@ -830,7 +830,7 @@
     ):
 
         super(RandomTerm, self).__init__(name, data, categorical, prior, constant)
-        self.grouper = grouper
+        self.grouper = None
         self.predictor = predictor
         self.group_index = self.invert_dummies(grouper)
 

Mutant 547

--- bambi/models.py
+++ bambi/models.py
@@ -841,7 +841,7 @@
         dummies as a vector of indices into the coefficients.
         """
         vec = np.zeros(len(dummies), dtype=int)
-        for i in range(1, dummies.shape[1]):
+        for i in range(2, dummies.shape[1]):
             vec[dummies[:, i] == 1] = i
         return vec
 

Mutant 549

--- bambi/models.py
+++ bambi/models.py
@@ -842,6 +842,6 @@
         """
         vec = np.zeros(len(dummies), dtype=int)
         for i in range(1, dummies.shape[1]):
-            vec[dummies[:, i] == 1] = i
+            vec[dummies[:, i] != 1] = i
         return vec
 

Mutant 550

--- bambi/models.py
+++ bambi/models.py
@@ -842,6 +842,6 @@
         """
         vec = np.zeros(len(dummies), dtype=int)
         for i in range(1, dummies.shape[1]):
-            vec[dummies[:, i] == 1] = i
+            vec[dummies[:, i] == 2] = i
         return vec