Skip to content

Commit 340ed33

Browse files
authored
Merge pull request #154 from arielrossanigo/python36_in_tox
Python 3.6, numpy 1.14 and some fix in tests
2 parents 50edf89 + e3cfea1 commit 340ed33

File tree

4 files changed

+30
-29
lines changed

4 files changed

+30
-29
lines changed

README.rst

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Normally you'll read the data from a file, but for demonstration purposes we'll
5757

5858
>>> data = pd.DataFrame({'pet': ['cat', 'dog', 'dog', 'fish', 'cat', 'dog', 'cat', 'fish'],
5959
... 'children': [4., 6, 3, 3, 2, 3, 5, 4],
60-
... 'salary': [90, 24, 44, 27, 32, 59, 36, 27]})
60+
... 'salary': [90., 24, 44, 27, 32, 59, 36, 27]})
6161

6262
Transformation Mapping
6363
----------------------
@@ -106,7 +106,7 @@ Now that the transformation is trained, we confirm that it works on new data::
106106

107107
>>> sample = pd.DataFrame({'pet': ['cat'], 'children': [5.]})
108108
>>> np.round(mapper.transform(sample), 2)
109-
array([[ 1. , 0. , 0. , 1.04]])
109+
array([[1. , 0. , 0. , 1.04]])
110110

111111

112112
Output features names
@@ -251,14 +251,14 @@ Only columns that are listed in the DataFrameMapper are kept. To keep a column b
251251
... ('children', None)
252252
... ])
253253
>>> np.round(mapper3.fit_transform(data.copy()))
254-
array([[ 1., 0., 0., 4.],
255-
[ 0., 1., 0., 6.],
256-
[ 0., 1., 0., 3.],
257-
[ 0., 0., 1., 3.],
258-
[ 1., 0., 0., 2.],
259-
[ 0., 1., 0., 3.],
260-
[ 1., 0., 0., 5.],
261-
[ 0., 0., 1., 4.]])
254+
array([[1., 0., 0., 4.],
255+
[0., 1., 0., 6.],
256+
[0., 1., 0., 3.],
257+
[0., 0., 1., 3.],
258+
[1., 0., 0., 2.],
259+
[0., 1., 0., 3.],
260+
[1., 0., 0., 5.],
261+
[0., 0., 1., 4.]])
262262

263263
Applying a default transformer
264264
******************************
@@ -329,11 +329,11 @@ Then the following code could be used to override default imputing strategy:
329329
... 'col3': [0, 0, 0, None, None]
330330
... })
331331
>>> mapper6.fit_transform(data6)
332-
array([[ 1., 1., 0.],
333-
[ 1., 0., 0.],
334-
[ 1., 1., 0.],
335-
[ 2., 1., 0.],
336-
[ 3., 1., 0.]])
332+
array([[1., 1., 0.],
333+
[1., 0., 0.],
334+
[1., 1., 0.],
335+
[2., 1., 0.],
336+
[3., 1., 0.]])
337337

338338

339339
Feature selection and other supervised transformations
@@ -344,14 +344,14 @@ Feature selection and other supervised transformations
344344
>>> from sklearn.feature_selection import SelectKBest, chi2
345345
>>> mapper_fs = DataFrameMapper([(['children','salary'], SelectKBest(chi2, k=1))])
346346
>>> mapper_fs.fit_transform(data[['children','salary']], data['pet'])
347-
array([[ 90.],
348-
[ 24.],
349-
[ 44.],
350-
[ 27.],
351-
[ 32.],
352-
[ 59.],
353-
[ 36.],
354-
[ 27.]])
347+
array([[90.],
348+
[24.],
349+
[44.],
350+
[27.],
351+
[32.],
352+
[59.],
353+
[36.],
354+
[27.]])
355355

356356
Working with sparse features
357357
****************************

tests/test_categorical_imputer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def test_unit(input_type, none_value):
2929

3030
Xt = CategoricalImputer().fit_transform(X)
3131

32-
assert (np.asarray(X) == np.asarray(Xc)).all()
32+
assert pd.core.common.array_equivalent(np.asarray(X), np.asarray(Xc))
3333
assert isinstance(Xt, np.ndarray)
3434
assert (Xt == ['a', 'b', 'b', 'b']).all()
3535

@@ -151,7 +151,7 @@ def test_custom_replacement(replacement_value, input_type):
151151
replacement=replacement_value
152152
).fit_transform(X)
153153

154-
assert (np.asarray(X) == np.asarray(Xc)).all()
154+
assert pd.core.common.array_equivalent(np.asarray(X), np.asarray(Xc))
155155
assert isinstance(Xt, np.ndarray)
156156
assert (Xt == ['a', replacement_value, 'b', 'b']).all()
157157

tests/test_dataframe_mapper.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,8 @@ def test_list_transformers():
625625
Specifying a list of transformers applies them sequentially to the
626626
selected column.
627627
"""
628-
dataframe = pd.DataFrame({"a": [1, np.nan, 3], "b": [1, 5, 7]})
628+
dataframe = pd.DataFrame({"a": [1, np.nan, 3], "b": [1, 5, 7]},
629+
dtype=np.float64)
629630

630631
mapper = DataFrameMapper([
631632
(["a"], [Imputer(), StandardScaler()]),

tox.ini

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[tox]
2-
envlist = {py27,py35}-sklearn{17,18}
2+
envlist = {py27,py36}-sklearn{17,18}
33

44
[testenv]
55
deps =
66
pytest==3.2.1
7-
setuptools==16.0
7+
setuptools==39.0
88
wheel==0.24.0
99
flake8==2.4.1
10-
numpy==1.11.3
10+
numpy==1.14.3
1111
scipy==0.18.1
1212
pandas==0.19.2
1313
sklearn17: scikit-learn==0.17.1

0 commit comments

Comments
 (0)