Skip to content

Commit a83ff74

Browse files
committed
Work around pandas.Index.equals change in 0.19.0
Traditionally, `pandas.Index([1, 2]).equals([1, 2])` returned True. In 0.19.0, it returns False, and we have to explicitly upcast the argument to an Index to get the test we want. pandas-dev/pandas#14411
1 parent 6577d26 commit a83ff74

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

patsy/test_build.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ def __getitem__(self, key):
429429
return_type="dataframe")
430430
assert isinstance(int_df, pandas.DataFrame)
431431
assert np.array_equal(int_df, [[1], [1], [1]])
432-
assert int_df.index.equals([10, 20, 30])
432+
assert int_df.index.equals(pandas.Index([10, 20, 30]))
433433

434434
import patsy.build
435435
had_pandas = patsy.build.have_pandas
@@ -448,7 +448,7 @@ def __getitem__(self, key):
448448
dtype=object)},
449449
NA_action="drop",
450450
return_type="dataframe")
451-
assert x_df.index.equals([2])
451+
assert x_df.index.equals(pandas.Index([2]))
452452

453453
def test_data_mismatch():
454454
test_cases_twoway = [

patsy/test_highlevel.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ def test_dmatrix_NA_action():
672672
assert np.array_equal(mat, [[1, 2, 20],
673673
[1, 3, 30]])
674674
if return_type == "dataframe":
675-
assert mat.index.equals([1, 2])
675+
assert mat.index.equals(pandas.Index([1, 2]))
676676
assert_raises(PatsyError, dmatrix, "x + y", data=data,
677677
return_type=return_type,
678678
NA_action="raise")
@@ -681,8 +681,8 @@ def test_dmatrix_NA_action():
681681
assert np.array_equal(lmat, [[20], [30]])
682682
assert np.array_equal(rmat, [[1, 2], [1, 3]])
683683
if return_type == "dataframe":
684-
assert lmat.index.equals([1, 2])
685-
assert rmat.index.equals([1, 2])
684+
assert lmat.index.equals(pandas.Index([1, 2]))
685+
assert rmat.index.equals(pandas.Index([1, 2]))
686686
assert_raises(PatsyError,
687687
dmatrices, "y ~ x", data=data, return_type=return_type,
688688
NA_action="raise")
@@ -693,8 +693,8 @@ def test_dmatrix_NA_action():
693693
assert np.array_equal(lmat, [[20], [30], [40]])
694694
assert np.array_equal(rmat, [[1], [1], [1]])
695695
if return_type == "dataframe":
696-
assert lmat.index.equals([1, 2, 3])
697-
assert rmat.index.equals([1, 2, 3])
696+
assert lmat.index.equals(pandas.Index([1, 2, 3]))
697+
assert rmat.index.equals(pandas.Index([1, 2, 3]))
698698
assert_raises(PatsyError,
699699
dmatrices, "y ~ 1", data=data, return_type=return_type,
700700
NA_action="raise")

0 commit comments

Comments
 (0)