def test_decomposition(self):
   dc = wrappers.stl(self.aus_ts, 7)
   dcdf = converters.decomposition(dc)
   self.assertEqual(type(dcdf.index), pandas.core.index.MultiIndex)
   self.assertEqual(dcdf.index[0], (1999, 1))
   self.assertEqual(dcdf.index[-1], (2010, 4))
   self.assertEqual(dcdf.shape, (48, 4))
   self.assertEqual(list(dcdf.columns), 
                    [u'data', u'seasonal', u'trend', u'remainder'])
   self.assertAlmostEqual(dcdf.data[(1999, 1)], 
                           self.aus_ts.rx(1)[0], places=3)
   self.assertAlmostEqual(dcdf.data[(2010, 4)], 
                           self.aus_ts.rx(48)[0], places=3)
   self.assertAlmostEqual(dcdf.seasonal[(1999, 1)], 
                           dc.rx2('time.series').rx(1, 1)[0], places=3)
   self.assertAlmostEqual(dcdf.seasonal[(2010, 4)],
                           dc.rx2('time.series').rx(48, 1)[0], places=3)
   self.assertAlmostEqual(dcdf.trend[(1999, 1)],
                           dc.rx2('time.series').rx(1, 2)[0], places=3)
   self.assertAlmostEqual(dcdf.trend[(2010, 4)], 
                           dc.rx2('time.series').rx(48, 2)[0], places=3)
   self.assertAlmostEqual(dcdf.remainder[(1999, 1)], 
                           dc.rx2('time.series').rx(1, 3)[0], places=3)
   self.assertAlmostEqual(dcdf.remainder[(2010, 4)], 
                           dc.rx2('time.series').rx(48, 3)[0], places=3)
   
   dc = wrappers.decompose(self.aus_ts)
   dcdf = converters.decomposition(dc)
   self.assertEqual(type(dcdf.index), pandas.core.index.MultiIndex)
   self.assertEqual(dcdf.index[0], (1999, 1))
   self.assertEqual(dcdf.index[-1], (2010, 4))
   self.assertEqual(dcdf.shape, (48, 4))
   self.assertEqual(list(dcdf.columns), 
                    [u'data', u'seasonal', u'trend', u'remainder'])
   self.assertAlmostEqual(dcdf.data[(1999, 1)], 
                                    self.aus_ts.rx(1)[0], places=3)
   self.assertAlmostEqual(dcdf.data[(2010, 4)], 
                                    self.aus_ts.rx(48)[0], places=3)
   self.assertAlmostEqual(dcdf.seasonal[(1999, 1)], 
                           dc.rx2('seasonal').rx(1)[0], places=3)
   self.assertAlmostEqual(dcdf.seasonal[(2010, 4)], 
                           dc.rx2('seasonal').rx(48)[0], places=3)
   self.assertAlmostEqual(dcdf.trend[(1999, 3)], 
                           dc.rx2('trend').rx(3)[0], places=3)
   self.assertAlmostEqual(dcdf.trend[(2010, 2)],
                           dc.rx2('trend').rx(46)[0], places=3)
   self.assertTrue(dcdf.trend.isnull()[(1999, 1)])
   self.assertTrue(dcdf.trend.isnull()[(1999, 2)])
   self.assertTrue(dcdf.trend.isnull()[(2010, 3)])
   self.assertTrue(dcdf.trend.isnull()[(2010, 4)])
   self.assertAlmostEqual(dcdf.remainder[(1999, 3)], 
                           dc.rx2('random').rx(3)[0], places=3)
   self.assertAlmostEqual(dcdf.remainder[(2010, 2)], 
                           dc.rx2('random').rx(46)[0], places=3)
   self.assertTrue(dcdf.remainder.isnull()[(1999, 1)])
   self.assertTrue(dcdf.remainder.isnull()[(1999, 2)])
   self.assertTrue(dcdf.remainder.isnull()[(2010, 3)])
   self.assertTrue(dcdf.remainder.isnull()[(2010, 4)])
   self.assertRaises(ValueError, converters.decomposition, self.fc_oil)
 def test_decomposition(self):
   dc = wrappers.stl(self.aus_ts, 7)
   dcdf = converters.decomposition(dc)
   self.assertEqual(type(dcdf.index), pandas.core.index.MultiIndex)
   self.assertEqual(dcdf.index[0], (1999, 1))
   self.assertEqual(dcdf.index[-1], (2010, 4))
   self.assertEqual(dcdf.shape, (48, 4))
   self.assertEqual(list(dcdf.columns), [u'data', u'seasonal', u'trend', u'remainder'])
   self.assertAlmostEqual(dcdf.data[(1999, 1)], 30.0525, places=3)
   self.assertAlmostEqual(dcdf.data[(2010, 4)], 47.9137, places=3)
   self.assertAlmostEqual(dcdf.seasonal[(1999, 1)], 5.5077, places=3)
   self.assertAlmostEqual(dcdf.seasonal[(2010, 4)], 0.7848, places=3)
   self.assertAlmostEqual(dcdf.trend[(1999, 1)], 24.3714, places=3)
   self.assertAlmostEqual(dcdf.trend[(2010, 4)], 47.1525, places=3)
   self.assertAlmostEqual(dcdf.remainder[(1999, 1)], 0.1732, places=3)
   self.assertAlmostEqual(dcdf.remainder[(2010, 4)], -0.0236, places=3)
   
   dc = wrappers.decompose(self.aus_ts)
   dcdf = converters.decomposition(dc)
   self.assertEqual(type(dcdf.index), pandas.core.index.MultiIndex)
   self.assertEqual(dcdf.index[0], (1999, 1))
   self.assertEqual(dcdf.index[-1], (2010, 4))
   self.assertEqual(dcdf.shape, (48, 4))
   self.assertEqual(list(dcdf.columns), [u'data', u'seasonal', u'trend', u'remainder'])
   self.assertAlmostEqual(dcdf.data[(1999, 1)], 30.0525, places=3)
   self.assertAlmostEqual(dcdf.data[(2010, 4)], 47.9137, places=3)
   self.assertAlmostEqual(dcdf.seasonal[(1999, 1)], 8.5906, places=3)
   self.assertAlmostEqual(dcdf.seasonal[(2010, 4)], 1.5042, places=3)
   self.assertAlmostEqual(dcdf.trend[(1999, 3)], 25.7805, places=3)
   self.assertAlmostEqual(dcdf.trend[(2010, 2)], 46.514102, places=3)
   self.assertTrue(dcdf.trend.isnull()[(1999, 1)])
   self.assertTrue(dcdf.trend.isnull()[(1999, 2)])
   self.assertTrue(dcdf.trend.isnull()[(2010, 3)])
   self.assertTrue(dcdf.trend.isnull()[(2010, 4)])
   self.assertAlmostEqual(dcdf.remainder[(1999, 3)], 1.3091, places=3)
   self.assertAlmostEqual(dcdf.remainder[(2010, 2)], -2.9993, places=3)
   self.assertTrue(dcdf.remainder.isnull()[(1999, 1)])
   self.assertTrue(dcdf.remainder.isnull()[(1999, 2)])
   self.assertTrue(dcdf.remainder.isnull()[(2010, 3)])
   self.assertTrue(dcdf.remainder.isnull()[(2010, 4)])
   self.assertRaises(ValueError, converters.decomposition, self.fc_oil)
    def test_decomposition(self):
        dc = wrappers.stl(self.aus_ts, 7)
        dcdf = converters.decomposition(dc)
        self.assertEqual(type(dcdf.index), pandas.core.index.MultiIndex)
        self.assertEqual(dcdf.index[0], (1999, 1))
        self.assertEqual(dcdf.index[-1], (2010, 4))
        self.assertEqual(dcdf.shape, (48, 4))
        self.assertEqual(list(dcdf.columns),
                         [u'data', u'seasonal', u'trend', u'remainder'])
        self.assertAlmostEqual(dcdf.data[(1999, 1)],
                               self.aus_ts.rx(1)[0],
                               places=3)
        self.assertAlmostEqual(dcdf.data[(2010, 4)],
                               self.aus_ts.rx(48)[0],
                               places=3)
        self.assertAlmostEqual(dcdf.seasonal[(1999, 1)],
                               dc.rx2('time.series').rx(1, 1)[0],
                               places=3)
        self.assertAlmostEqual(dcdf.seasonal[(2010, 4)],
                               dc.rx2('time.series').rx(48, 1)[0],
                               places=3)
        self.assertAlmostEqual(dcdf.trend[(1999, 1)],
                               dc.rx2('time.series').rx(1, 2)[0],
                               places=3)
        self.assertAlmostEqual(dcdf.trend[(2010, 4)],
                               dc.rx2('time.series').rx(48, 2)[0],
                               places=3)
        self.assertAlmostEqual(dcdf.remainder[(1999, 1)],
                               dc.rx2('time.series').rx(1, 3)[0],
                               places=3)
        self.assertAlmostEqual(dcdf.remainder[(2010, 4)],
                               dc.rx2('time.series').rx(48, 3)[0],
                               places=3)

        dc = wrappers.decompose(self.aus_ts)
        dcdf = converters.decomposition(dc)
        self.assertEqual(type(dcdf.index), pandas.core.index.MultiIndex)
        self.assertEqual(dcdf.index[0], (1999, 1))
        self.assertEqual(dcdf.index[-1], (2010, 4))
        self.assertEqual(dcdf.shape, (48, 4))
        self.assertEqual(list(dcdf.columns),
                         [u'data', u'seasonal', u'trend', u'remainder'])
        self.assertAlmostEqual(dcdf.data[(1999, 1)],
                               self.aus_ts.rx(1)[0],
                               places=3)
        self.assertAlmostEqual(dcdf.data[(2010, 4)],
                               self.aus_ts.rx(48)[0],
                               places=3)
        self.assertAlmostEqual(dcdf.seasonal[(1999, 1)],
                               dc.rx2('seasonal').rx(1)[0],
                               places=3)
        self.assertAlmostEqual(dcdf.seasonal[(2010, 4)],
                               dc.rx2('seasonal').rx(48)[0],
                               places=3)
        self.assertAlmostEqual(dcdf.trend[(1999, 3)],
                               dc.rx2('trend').rx(3)[0],
                               places=3)
        self.assertAlmostEqual(dcdf.trend[(2010, 2)],
                               dc.rx2('trend').rx(46)[0],
                               places=3)
        self.assertTrue(dcdf.trend.isnull()[(1999, 1)])
        self.assertTrue(dcdf.trend.isnull()[(1999, 2)])
        self.assertTrue(dcdf.trend.isnull()[(2010, 3)])
        self.assertTrue(dcdf.trend.isnull()[(2010, 4)])
        self.assertAlmostEqual(dcdf.remainder[(1999, 3)],
                               dc.rx2('random').rx(3)[0],
                               places=3)
        self.assertAlmostEqual(dcdf.remainder[(2010, 2)],
                               dc.rx2('random').rx(46)[0],
                               places=3)
        self.assertTrue(dcdf.remainder.isnull()[(1999, 1)])
        self.assertTrue(dcdf.remainder.isnull()[(1999, 2)])
        self.assertTrue(dcdf.remainder.isnull()[(2010, 3)])
        self.assertTrue(dcdf.remainder.isnull()[(2010, 4)])
        self.assertRaises(ValueError, converters.decomposition, self.fc_oil)