|
| 1 | +""" Base setup """ |
| 2 | + |
| 3 | +import numpy as np |
| 4 | +from pandas.util import testing as tm |
| 5 | +from pandas import DataFrame, MultiIndex |
| 6 | + |
| 7 | + |
| 8 | +class MixIn(object): |
| 9 | + |
| 10 | + def setUp(self): |
| 11 | + self.ts = tm.makeTimeSeries() |
| 12 | + |
| 13 | + self.seriesd = tm.getSeriesData() |
| 14 | + self.tsd = tm.getTimeSeriesData() |
| 15 | + self.frame = DataFrame(self.seriesd) |
| 16 | + self.tsframe = DataFrame(self.tsd) |
| 17 | + |
| 18 | + self.df = DataFrame( |
| 19 | + {'A': ['foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'foo', 'foo'], |
| 20 | + 'B': ['one', 'one', 'two', 'three', 'two', 'two', 'one', 'three'], |
| 21 | + 'C': np.random.randn(8), |
| 22 | + 'D': np.random.randn(8)}) |
| 23 | + |
| 24 | + self.df_mixed_floats = DataFrame( |
| 25 | + {'A': ['foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'foo', 'foo'], |
| 26 | + 'B': ['one', 'one', 'two', 'three', 'two', 'two', 'one', 'three'], |
| 27 | + 'C': np.random.randn(8), |
| 28 | + 'D': np.array( |
| 29 | + np.random.randn(8), dtype='float32')}) |
| 30 | + |
| 31 | + index = MultiIndex(levels=[['foo', 'bar', 'baz', 'qux'], ['one', 'two', |
| 32 | + 'three']], |
| 33 | + labels=[[0, 0, 0, 1, 1, 2, 2, 3, 3, 3], |
| 34 | + [0, 1, 2, 0, 1, 1, 2, 0, 1, 2]], |
| 35 | + names=['first', 'second']) |
| 36 | + self.mframe = DataFrame(np.random.randn(10, 3), index=index, |
| 37 | + columns=['A', 'B', 'C']) |
| 38 | + |
| 39 | + self.three_group = DataFrame( |
| 40 | + {'A': ['foo', 'foo', 'foo', 'foo', 'bar', 'bar', 'bar', 'bar', |
| 41 | + 'foo', 'foo', 'foo'], |
| 42 | + 'B': ['one', 'one', 'one', 'two', 'one', 'one', 'one', 'two', |
| 43 | + 'two', 'two', 'one'], |
| 44 | + 'C': ['dull', 'dull', 'shiny', 'dull', 'dull', 'shiny', 'shiny', |
| 45 | + 'dull', 'shiny', 'shiny', 'shiny'], |
| 46 | + 'D': np.random.randn(11), |
| 47 | + 'E': np.random.randn(11), |
| 48 | + 'F': np.random.randn(11)}) |
| 49 | + |
| 50 | + |
| 51 | +def assert_fp_equal(a, b): |
| 52 | + assert (np.abs(a - b) < 1e-12).all() |
0 commit comments