|
52 | 52 | from sklearn.utils.fixes import CSR_CONTAINERS
|
53 | 53 | from sklearn.utils.validation import check_is_fitted
|
54 | 54 |
|
| 55 | +# Load a shared tests data sets for the tests in this module. Mark them |
| 56 | +# read-only to avoid unintentional in-place modifications that would introduce |
| 57 | +# side-effects between tests. |
55 | 58 | iris = load_iris()
|
| 59 | +iris.data.flags.writeable = False |
| 60 | +iris.target.flags.writeable = False |
| 61 | + |
56 | 62 |
|
57 | 63 | JUNK_FOOD_DOCS = (
|
58 | 64 | "the pizza pizza beer copyright",
|
@@ -499,7 +505,7 @@ def test_predict_methods_with_predict_params(method_name):
|
499 | 505 | @pytest.mark.parametrize("csr_container", CSR_CONTAINERS)
|
500 | 506 | def test_feature_union(csr_container):
|
501 | 507 | # basic sanity check for feature union
|
502 |
| - X = iris.data |
| 508 | + X = iris.data.copy() |
503 | 509 | X -= X.mean(axis=0)
|
504 | 510 | y = iris.target
|
505 | 511 | svd = TruncatedSVD(n_components=2, random_state=0)
|
@@ -1584,7 +1590,7 @@ def fit(self, X, y=None, **fit_params):
|
1584 | 1590 | def test_pipeline_missing_values_leniency():
|
1585 | 1591 | # check that pipeline let the missing values validation to
|
1586 | 1592 | # the underlying transformers and predictors.
|
1587 |
| - X, y = iris.data, iris.target |
| 1593 | + X, y = iris.data.copy(), iris.target.copy() |
1588 | 1594 | mask = np.random.choice([1, 0], X.shape, p=[0.1, 0.9]).astype(bool)
|
1589 | 1595 | X[mask] = np.nan
|
1590 | 1596 | pipe = make_pipeline(SimpleImputer(), LogisticRegression())
|
|
0 commit comments