|
1 | 1 | import re |
2 | 2 | import numpy as np |
3 | 3 | import pandas as pd |
| 4 | +from pandas.testing import assert_frame_equal, assert_series_equal |
4 | 5 | from pythonwhat.tasks import * |
5 | 6 | from protowhat.Test import Test |
6 | 7 |
|
@@ -115,21 +116,19 @@ def is_equal(x, y): |
115 | 116 | # Types of errors don't matter (this is debatable) |
116 | 117 | return str(x) == str(y) |
117 | 118 | if areinstance(x, y, (np.ndarray, dict, list, tuple)): |
118 | | - if np.array_equal(x, y): |
119 | | - return True |
120 | 119 | np.testing.assert_equal(x, y) |
121 | 120 | return True |
122 | 121 | elif areinstance(x, y, (map, filter)): |
123 | 122 | return np.array_equal(list(x), list(y)) |
124 | 123 | elif areinstance(x, y, (pd.DataFrame,)): |
125 | 124 | if x.equals(y): |
126 | 125 | return True |
127 | | - pd.util.testing.assert_frame_equal(x, y) |
| 126 | + assert_frame_equal(x, y) |
128 | 127 | return True |
129 | 128 | elif areinstance(x, y, (pd.Series,)): |
130 | 129 | if x.equals(y): |
131 | 130 | return True |
132 | | - pd.util.testing.assert_series_equal(x, y) |
| 131 | + assert_series_equal(x, y) |
133 | 132 | return True |
134 | 133 | else: |
135 | 134 | return x == y |
@@ -185,4 +184,4 @@ def test(self): |
185 | 184 | if self.pattern: |
186 | 185 | self.result = re.search(self.search_string, self.string) is not None |
187 | 186 | else: |
188 | | - self.result = self.string.find(self.search_string) is not -1 |
| 187 | + self.result = self.string.find(self.search_string) != -1 |
0 commit comments