Ejemplo n.º 1
0
 def test_parse_dataframe(self):
     s = Series(np.arange(10.0), name='variable')
     out = parse_dataframe(s, 'y')
     assert_equal(out[1], np.arange(10.0))
     assert_equal(out[0], ['variable'])
     df = DataFrame(s)
     out = parse_dataframe(df, 'y')
     assert_equal(out[1], np.arange(10.0))
     assert_equal(out[0], ['variable'])
     out = parse_dataframe(np.arange(10.0), 'y')
     assert_equal(out[1], np.arange(10.0))
     assert_equal(out[0], ['y'])
Ejemplo n.º 2
0
    def test_parse_dataframe(self):
        s = Series(np.arange(10.0), name='variable')
        out = parse_dataframe(s, 'y')
        assert_equal(out[1], np.arange(10.0))
        assert_equal(out[0], ['variable'])
        df = DataFrame(s)
        out = parse_dataframe(df, 'y')
        assert_equal(out[1], np.arange(10.0))
        assert_equal(out[0], ['variable'])
        out = parse_dataframe(np.arange(10.0), 'y')
        assert_equal(out[1], np.arange(10.0))
        assert_equal(out[0], ['y'])

        out = parse_dataframe(None, 'name')
        assert out[0] == ['name']
        assert isinstance(out[1], np.ndarray)
        assert out[1].shape == (0, )
Ejemplo n.º 3
0
def test_parse_dataframe():
    s = Series(np.arange(10.0), name="variable")
    out = parse_dataframe(s, "y")
    assert_equal(out[1], np.arange(10.0))
    assert_equal(out[0], ["variable"])
    df = DataFrame(s)
    out = parse_dataframe(df, "y")
    assert_equal(out[1], np.arange(10.0))
    assert_equal(out[0], ["variable"])
    out = parse_dataframe(np.arange(10.0), "y")
    assert_equal(out[1], np.arange(10.0))
    assert_equal(out[0], ["y"])

    out = parse_dataframe(None, "name")
    assert out[0] == ["name"]
    assert isinstance(out[1], np.ndarray)
    assert out[1].shape == (0,)
Ejemplo n.º 4
0
    def test_parse_dataframe(self):
        s = Series(np.arange(10.0), name='variable')
        out = parse_dataframe(s, 'y')
        assert_equal(out[1], np.arange(10.0))
        assert_equal(out[0], ['variable'])
        df = DataFrame(s)
        out = parse_dataframe(df, 'y')
        assert_equal(out[1], np.arange(10.0))
        assert_equal(out[0], ['variable'])
        out = parse_dataframe(np.arange(10.0), 'y')
        assert_equal(out[1], np.arange(10.0))
        assert_equal(out[0], ['y'])

        out = parse_dataframe(None, 'name')
        assert out[0] == ['name']
        assert isinstance(out[1], np.ndarray)
        assert out[1].shape == (0,)
Ejemplo n.º 5
0
Archivo: mean.py Proyecto: TonyLv/arch
 def _check_specification(self):
     """Checks the specification for obvious errors """
     if self._x is not None:
         if self._x.ndim != 2 or self._x.shape[0] != self._y.shape[0]:
             raise ValueError(
                 'x must be nobs by n, where nobs is the same as '
                 'the number of elements in y')
         def_names = ['x' + str(i) for i in range(self._x.shape[1])]
         self._x_names, self._x_index = parse_dataframe(self._x, def_names)
         self._x = np.asarray(self._x)
Ejemplo n.º 6
0
Archivo: mean.py Proyecto: esvhd/arch
 def _check_specification(self):
     """Checks the specification for obvious errors """
     if self._x is not None:
         if self._x.ndim != 2 or self._x.shape[0] != self._y.shape[0]:
             raise ValueError(
                 'x must be nobs by n, where nobs is the same as '
                 'the number of elements in y')
         def_names = ['x' + str(i) for i in range(self._x.shape[1])]
         self._x_names, self._x_index = parse_dataframe(self._x, def_names)
         self._x = np.asarray(self._x)
Ejemplo n.º 7
0
 def _check_specification(self) -> None:
     """Checks the specification for obvious errors """
     if self._x is not None:
         if self._x.ndim == 1:
             self._x = self._x[:, None]
         if self._x.ndim != 2 or self._x.shape[0] != self._y.shape[0]:
             raise ValueError(
                 "x must be nobs by n, where nobs is the same as "
                 "the number of elements in y")
         def_names = ["x" + str(i) for i in range(self._x.shape[1])]
         names, self._x_index = parse_dataframe(self._x, def_names)
         self._x_names = [str(name) for name in names]
         self._x = np.asarray(self._x)