|
6 | 6 | import nose
|
7 | 7 | import numpy as np
|
8 | 8 | import sys
|
9 |
| -from pandas import Series |
| 9 | +from pandas import Series, DataFrame |
10 | 10 | from pandas.util.testing import (
|
11 |
| - assert_almost_equal, assertRaisesRegexp, raise_with_traceback, assert_series_equal, |
| 11 | + assert_almost_equal, assertRaisesRegexp, raise_with_traceback, |
| 12 | + assert_series_equal, assert_frame_equal, |
12 | 13 | RNGContext
|
13 | 14 | )
|
14 | 15 |
|
@@ -174,6 +175,46 @@ def test_less_precise(self):
|
174 | 175 | self.assertRaises(AssertionError, assert_series_equal, s1, s2)
|
175 | 176 | self.assertRaises(AssertionError, assert_series_equal, s1, s2, True)
|
176 | 177 |
|
| 178 | + def test_index_dtype(self): |
| 179 | + df1 = DataFrame.from_records( |
| 180 | + {'a':[1,2],'c':['l1','l2']}, index=['a']) |
| 181 | + df2 = DataFrame.from_records( |
| 182 | + {'a':[1.0,2.0],'c':['l1','l2']}, index=['a']) |
| 183 | + self._assert_not_equal(df1.c, df2.c, check_index_type=True) |
| 184 | + |
| 185 | + def test_multiindex_dtype(self): |
| 186 | + df1 = DataFrame.from_records( |
| 187 | + {'a':[1,2],'b':[2.1,1.5],'c':['l1','l2']}, index=['a','b']) |
| 188 | + df2 = DataFrame.from_records( |
| 189 | + {'a':[1.0,2.0],'b':[2.1,1.5],'c':['l1','l2']}, index=['a','b']) |
| 190 | + self._assert_not_equal(df1.c, df2.c, check_index_type=True) |
| 191 | + |
| 192 | + |
| 193 | +class TestAssertFrameEqual(unittest.TestCase): |
| 194 | + _multiprocess_can_split_ = True |
| 195 | + |
| 196 | + def _assert_equal(self, x, y, **kwargs): |
| 197 | + assert_frame_equal(x,y,**kwargs) |
| 198 | + assert_frame_equal(y,x,**kwargs) |
| 199 | + |
| 200 | + def _assert_not_equal(self, a, b, **kwargs): |
| 201 | + self.assertRaises(AssertionError, assert_frame_equal, a, b, **kwargs) |
| 202 | + self.assertRaises(AssertionError, assert_frame_equal, b, a, **kwargs) |
| 203 | + |
| 204 | + def test_index_dtype(self): |
| 205 | + df1 = DataFrame.from_records( |
| 206 | + {'a':[1,2],'c':['l1','l2']}, index=['a']) |
| 207 | + df2 = DataFrame.from_records( |
| 208 | + {'a':[1.0,2.0],'c':['l1','l2']}, index=['a']) |
| 209 | + self._assert_not_equal(df1, df2, check_index_type=True) |
| 210 | + |
| 211 | + def test_multiindex_dtype(self): |
| 212 | + df1 = DataFrame.from_records( |
| 213 | + {'a':[1,2],'b':[2.1,1.5],'c':['l1','l2']}, index=['a','b']) |
| 214 | + df2 = DataFrame.from_records( |
| 215 | + {'a':[1.0,2.0],'b':[2.1,1.5],'c':['l1','l2']}, index=['a','b']) |
| 216 | + self._assert_not_equal(df1, df2, check_index_type=True) |
| 217 | + |
177 | 218 | class TestRNGContext(unittest.TestCase):
|
178 | 219 |
|
179 | 220 | def test_RNGContext(self):
|
|
0 commit comments