Beispiel #1
0
    def setUp(self):
        major_axis = Index([1, 2, 3, 4])
        minor_axis = Index([1, 2])

        major_labels = np.array([0, 0, 1, 2, 3, 3])
        minor_labels = np.array([0, 1, 0, 1, 0, 1])

        self.index = LongPanelIndex(major_axis, minor_axis,
                                    major_labels, minor_labels)

        major_labels = np.array([0, 0, 1, 1, 1, 2, 2, 3, 3])
        minor_labels = np.array([0, 1, 0, 1, 1, 0, 1, 0, 1])

        self.incon = LongPanelIndex(major_axis, minor_axis,
                                    major_labels, minor_labels)
Beispiel #2
0
    def test_consistency(self):
        self.assert_(self.index.consistent)
        self.assert_(not self.incon.consistent)

        # need to construct an overflow
        major_axis = range(70000)
        minor_axis = range(10)

        major_labels = np.arange(70000)
        minor_labels = np.repeat(range(10), 7000)

        index = LongPanelIndex(major_axis, minor_axis,
                               major_labels, minor_labels)

        self.assert_(index.consistent)
Beispiel #3
0
class TestLongPanelIndex(unittest.TestCase):

    def setUp(self):
        major_axis = Index([1, 2, 3, 4])
        minor_axis = Index([1, 2])

        major_labels = np.array([0, 0, 1, 2, 3, 3])
        minor_labels = np.array([0, 1, 0, 1, 0, 1])

        self.index = LongPanelIndex(major_axis, minor_axis,
                                    major_labels, minor_labels)

        major_labels = np.array([0, 0, 1, 1, 1, 2, 2, 3, 3])
        minor_labels = np.array([0, 1, 0, 1, 1, 0, 1, 0, 1])

        self.incon = LongPanelIndex(major_axis, minor_axis,
                                    major_labels, minor_labels)

    def test_consistency(self):
        self.assert_(self.index.consistent)
        self.assert_(not self.incon.consistent)

        # need to construct an overflow
        major_axis = range(70000)
        minor_axis = range(10)

        major_labels = np.arange(70000)
        minor_labels = np.repeat(range(10), 7000)

        index = LongPanelIndex(major_axis, minor_axis,
                               major_labels, minor_labels)

        self.assert_(index.consistent)

    def test_truncate(self):
        result = self.index.truncate(before=1)
        self.assert_(0 not in result.major_axis)
        self.assert_(1 in result.major_axis)

        result = self.index.truncate(after=1)
        self.assert_(2 not in result.major_axis)
        self.assert_(1 in result.major_axis)

        result = self.index.truncate(before=1, after=2)
        self.assertEqual(len(result.major_axis), 2)

    def test_getMajorBounds(self):
        pass

    def test_getAxisBounds(self):
        pass

    def test_getLabelBounds(self):
        pass

    def test_bounds(self):
        pass

    def test_makeMask(self):
        mask =  self.index.mask
        expected = np.array([True, True,
                             True, False,
                             False, True,
                             True, True], dtype=bool)
        self.assert_(np.array_equal(mask, expected))

    def test_dims(self):
        pass