imblearn/pipeline.py

Killed 8 out of 37 mutants

Survived

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

Mutant 24

--- imblearn/pipeline.py
+++ imblearn/pipeline.py
@@ -119,7 +119,7 @@
         self._validate_names(names)
 
         # validate estimators
-        transformers = estimators[:-1]
+        transformers = estimators[:+1]
         estimator = estimators[-1]
 
         for t in transformers:

Mutant 25

--- imblearn/pipeline.py
+++ imblearn/pipeline.py
@@ -119,7 +119,7 @@
         self._validate_names(names)
 
         # validate estimators
-        transformers = estimators[:-1]
+        transformers = estimators[:-2]
         estimator = estimators[-1]
 
         for t in transformers:

Mutant 27

--- imblearn/pipeline.py
+++ imblearn/pipeline.py
@@ -120,7 +120,7 @@
 
         # validate estimators
         transformers = estimators[:-1]
-        estimator = estimators[-1]
+        estimator = estimators[+1]
 
         for t in transformers:
             if t is None or t == "passthrough":

Mutant 28

--- imblearn/pipeline.py
+++ imblearn/pipeline.py
@@ -120,7 +120,7 @@
 
         # validate estimators
         transformers = estimators[:-1]
-        estimator = estimators[-1]
+        estimator = estimators[-2]
 
         for t in transformers:
             if t is None or t == "passthrough":

Mutant 29

--- imblearn/pipeline.py
+++ imblearn/pipeline.py
@@ -120,7 +120,7 @@
 
         # validate estimators
         transformers = estimators[:-1]
-        estimator = estimators[-1]
+        estimator = None
 
         for t in transformers:
             if t is None or t == "passthrough":

Mutant 30

--- imblearn/pipeline.py
+++ imblearn/pipeline.py
@@ -123,7 +123,7 @@
         estimator = estimators[-1]
 
         for t in transformers:
-            if t is None or t == "passthrough":
+            if t is not None or t == "passthrough":
                 continue
             if not (
                 hasattr(t, "fit")

Mutant 31

--- imblearn/pipeline.py
+++ imblearn/pipeline.py
@@ -123,7 +123,7 @@
         estimator = estimators[-1]
 
         for t in transformers:
-            if t is None or t == "passthrough":
+            if t is None or t != "passthrough":
                 continue
             if not (
                 hasattr(t, "fit")

Mutant 32

--- imblearn/pipeline.py
+++ imblearn/pipeline.py
@@ -123,7 +123,7 @@
         estimator = estimators[-1]
 
         for t in transformers:
-            if t is None or t == "passthrough":
+            if t is None or t == "XXpassthroughXX":
                 continue
             if not (
                 hasattr(t, "fit")

Mutant 33

--- imblearn/pipeline.py
+++ imblearn/pipeline.py
@@ -123,7 +123,7 @@
         estimator = estimators[-1]
 
         for t in transformers:
-            if t is None or t == "passthrough":
+            if t is None and t == "passthrough":
                 continue
             if not (
                 hasattr(t, "fit")

Mutant 34

--- imblearn/pipeline.py
+++ imblearn/pipeline.py
@@ -126,7 +126,7 @@
             if t is None or t == "passthrough":
                 continue
             if not (
-                hasattr(t, "fit")
+                hasattr(t, "XXfitXX")
                 or hasattr(t, "fit_transform")
                 or hasattr(t, "fit_resample")
             ) or not (hasattr(t, "transform") or hasattr(t, "fit_resample")):

Mutant 36

--- imblearn/pipeline.py
+++ imblearn/pipeline.py
@@ -129,7 +129,7 @@
                 hasattr(t, "fit")
                 or hasattr(t, "fit_transform")
                 or hasattr(t, "fit_resample")
-            ) or not (hasattr(t, "transform") or hasattr(t, "fit_resample")):
+            ) or not (hasattr(t, "XXtransformXX") or hasattr(t, "fit_resample")):
                 raise TypeError(
                     "All intermediate steps of the chain should "
                     "be estimators that implement fit and transform or "

Mutant 39

--- imblearn/pipeline.py
+++ imblearn/pipeline.py
@@ -129,7 +129,7 @@
                 hasattr(t, "fit")
                 or hasattr(t, "fit_transform")
                 or hasattr(t, "fit_resample")
-            ) or not (hasattr(t, "transform") or hasattr(t, "fit_resample")):
+            ) and not (hasattr(t, "transform") or hasattr(t, "fit_resample")):
                 raise TypeError(
                     "All intermediate steps of the chain should "
                     "be estimators that implement fit and transform or "

Mutant 40

--- imblearn/pipeline.py
+++ imblearn/pipeline.py
@@ -137,7 +137,7 @@
                     "'%s' (type %s) doesn't)" % (t, type(t))
                 )
 
-            if hasattr(t, "fit_resample") and (
+            if hasattr(t, "XXfit_resampleXX") and (
                 hasattr(t, "fit_transform") or hasattr(t, "transform")
             ):
                 raise TypeError(

Mutant 41

--- imblearn/pipeline.py
+++ imblearn/pipeline.py
@@ -138,7 +138,7 @@
                 )
 
             if hasattr(t, "fit_resample") and (
-                hasattr(t, "fit_transform") or hasattr(t, "transform")
+                hasattr(t, "XXfit_transformXX") or hasattr(t, "transform")
             ):
                 raise TypeError(
                     "All intermediate steps of the chain should "

Mutant 42

--- imblearn/pipeline.py
+++ imblearn/pipeline.py
@@ -138,7 +138,7 @@
                 )
 
             if hasattr(t, "fit_resample") and (
-                hasattr(t, "fit_transform") or hasattr(t, "transform")
+                hasattr(t, "fit_transform") or hasattr(t, "XXtransformXX")
             ):
                 raise TypeError(
                     "All intermediate steps of the chain should "

Mutant 43

--- imblearn/pipeline.py
+++ imblearn/pipeline.py
@@ -138,7 +138,7 @@
                 )
 
             if hasattr(t, "fit_resample") and (
-                hasattr(t, "fit_transform") or hasattr(t, "transform")
+                hasattr(t, "fit_transform") and hasattr(t, "transform")
             ):
                 raise TypeError(
                     "All intermediate steps of the chain should "

Mutant 44

--- imblearn/pipeline.py
+++ imblearn/pipeline.py
@@ -155,7 +155,7 @@
 
         # We allow last estimator to be None as an identity transformation
         if (
-            estimator is not None
+            estimator is  None
             and estimator != "passthrough"
             and not hasattr(estimator, "fit")
         ):

Mutant 45

--- imblearn/pipeline.py
+++ imblearn/pipeline.py
@@ -156,7 +156,7 @@
         # We allow last estimator to be None as an identity transformation
         if (
             estimator is not None
-            and estimator != "passthrough"
+            and estimator == "passthrough"
             and not hasattr(estimator, "fit")
         ):
             raise TypeError(

Mutant 46

--- imblearn/pipeline.py
+++ imblearn/pipeline.py
@@ -156,7 +156,7 @@
         # We allow last estimator to be None as an identity transformation
         if (
             estimator is not None
-            and estimator != "passthrough"
+            and estimator != "XXpassthroughXX"
             and not hasattr(estimator, "fit")
         ):
             raise TypeError(

Mutant 50

--- imblearn/pipeline.py
+++ imblearn/pipeline.py
@@ -166,7 +166,7 @@
             )
 
     def _iter(
-        self, with_final=True, filter_passthrough=True, filter_resample=True
+        self, with_final=False, filter_passthrough=True, filter_resample=True
     ):
         """Generate (idx, (name, trans)) tuples from self.steps.
 

Mutant 51

--- imblearn/pipeline.py
+++ imblearn/pipeline.py
@@ -166,7 +166,7 @@
             )
 
     def _iter(
-        self, with_final=True, filter_passthrough=True, filter_resample=True
+        self, with_final=True, filter_passthrough=False, filter_resample=True
     ):
         """Generate (idx, (name, trans)) tuples from self.steps.
 

Mutant 52

--- imblearn/pipeline.py
+++ imblearn/pipeline.py
@@ -166,7 +166,7 @@
             )
 
     def _iter(
-        self, with_final=True, filter_passthrough=True, filter_resample=True
+        self, with_final=True, filter_passthrough=True, filter_resample=False
     ):
         """Generate (idx, (name, trans)) tuples from self.steps.
 

Mutant 53

--- imblearn/pipeline.py
+++ imblearn/pipeline.py
@@ -358,7 +358,7 @@
             elif hasattr(last_step, "fit_resample"):
                 return last_step.fit_resample(Xt, yt, **fit_params)
 
-    @if_delegate_has_method(delegate="_final_estimator")
+    @if_delegate_has_method(delegate="XX_final_estimatorXX")
     def fit_predict(self, X, y=None, **fit_params):
         """Apply `fit_predict` of last step in pipeline after transforms.
 

Mutant 54

--- imblearn/pipeline.py
+++ imblearn/pipeline.py
@@ -358,7 +358,6 @@
             elif hasattr(last_step, "fit_resample"):
                 return last_step.fit_resample(Xt, yt, **fit_params)
 
-    @if_delegate_has_method(delegate="_final_estimator")
     def fit_predict(self, X, y=None, **fit_params):
         """Apply `fit_predict` of last step in pipeline after transforms.
 

Mutant 55

--- imblearn/pipeline.py
+++ imblearn/pipeline.py
@@ -449,7 +449,7 @@
     Pipeline(steps=[('standardscaler', StandardScaler()),
                     ('gaussiannb', GaussianNB())])
     """
-    memory = kwargs.pop("memory", None)
+    memory = kwargs.pop("XXmemoryXX", None)
     verbose = kwargs.pop('verbose', False)
     if kwargs:
         raise TypeError(

Mutant 56

--- imblearn/pipeline.py
+++ imblearn/pipeline.py
@@ -449,7 +449,7 @@
     Pipeline(steps=[('standardscaler', StandardScaler()),
                     ('gaussiannb', GaussianNB())])
     """
-    memory = kwargs.pop("memory", None)
+    memory = None
     verbose = kwargs.pop('verbose', False)
     if kwargs:
         raise TypeError(

Mutant 57

--- imblearn/pipeline.py
+++ imblearn/pipeline.py
@@ -450,7 +450,7 @@
                     ('gaussiannb', GaussianNB())])
     """
     memory = kwargs.pop("memory", None)
-    verbose = kwargs.pop('verbose', False)
+    verbose = kwargs.pop('XXverboseXX', False)
     if kwargs:
         raise TypeError(
             'Unknown keyword arguments: "{}"'.format(list(kwargs.keys())[0])

Mutant 58

--- imblearn/pipeline.py
+++ imblearn/pipeline.py
@@ -450,7 +450,7 @@
                     ('gaussiannb', GaussianNB())])
     """
     memory = kwargs.pop("memory", None)
-    verbose = kwargs.pop('verbose', False)
+    verbose = kwargs.pop('verbose', True)
     if kwargs:
         raise TypeError(
             'Unknown keyword arguments: "{}"'.format(list(kwargs.keys())[0])

Mutant 59

--- imblearn/pipeline.py
+++ imblearn/pipeline.py
@@ -450,7 +450,7 @@
                     ('gaussiannb', GaussianNB())])
     """
     memory = kwargs.pop("memory", None)
-    verbose = kwargs.pop('verbose', False)
+    verbose = None
     if kwargs:
         raise TypeError(
             'Unknown keyword arguments: "{}"'.format(list(kwargs.keys())[0])