def test_check_compatible_dense(self):
        argvals = {
            'input_dim_0': np.array([1, 2, 3, 4]),
            'input_dim_1': np.array([5, 6, 7])
        }
        values = np.array([[[1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3]],
                           [[5, 6, 7], [5, 6, 7], [5, 6, 7], [5, 6, 7]]])
        dense_fd = DenseFunctionalData(argvals, values)

        argvals = {'input_dim_0': np.array([1, 2, 3, 4])}
        values = np.array([[1, 2, 3, 4], [5, 6, 7, 9], [3, 4, 5, 7]])
        dense_fd2 = DenseFunctionalData(argvals, values)
        self.assertRaises(ValueError, _check_same_nobs, dense_fd, dense_fd2)
        self.assertRaises(ValueError, _check_same_ndim, dense_fd, dense_fd2)
 def setUp(self):
     argvals = {'input_dim_0': np.array([1, 2, 3, 4])}
     values = np.array([[1, 2, 3, 4],
                        [5, 6, 7, 9],
                        [3, 4, 5, 7],
                        [3, 4, 6, 1],
                        [3, 4, 7, 6]])
     self.dense_fd = DenseFunctionalData(argvals, values)
    def setUp(self):
        argvals = {'input_dim_0': np.array([1, 2, 3, 4]),
                   'input_dim_1': np.array([5, 6, 7])}

        values = np.array([[[1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3]],
                           [[5, 6, 7], [5, 6, 7], [5, 6, 7], [5, 6, 7]],
                           [[3, 4, 5], [3, 4, 5], [3, 4, 5], [3, 4, 5]],
                           [[3, 4, 6], [3, 4, 5], [3, 4, 5], [3, 4, 5]],
                           [[3, 4, 7], [3, 4, 5], [3, 4, 5], [3, 4, 5]]])
        self.dense_fd = DenseFunctionalData(argvals, values)
Beispiel #4
0
def read_csv_dense(data, argvals):
    """Load a csv file into a DenseFunctionalData object.

    Parameters
    ----------
    data: pd.DataFrame
        Input dataframe.
    argvals: np.ndarray
        An array of argvals.

    Returns
    -------
    obj: DenseFunctionalData
        The loaded csv file

    """
    argvals = {'input_dim_0': argvals}
    values = np.array(data)
    return DenseFunctionalData(argvals, values)
Beispiel #5
0
def read_ts_dense(data):
    """Load a ts file into a DenseFunctionalData object.

    Parameters
    ----------
    data: pd.DataFrame
        Input dataframe.

    Returns
    -------
    obj: DenseFunctionalData
        The loaded ts file.

    """
    argvals = data.loc[0, 'dim_0'].index.values
    values = np.zeros((len(data), len(argvals)))
    for idx, row in data.iterrows():
        values[idx, :] = row['dim_0'].values
    return DenseFunctionalData({'input_dim_0': argvals}, values)
    def test_check_same_type(self):
        argvals = {'input_dim_0': np.array([1, 2, 3, 4])}
        values = np.array([[1, 2, 3, 4], [5, 6, 7, 9], [3, 4, 5, 7]])
        dense_fd = DenseFunctionalData(argvals, values)

        argvals = {
            'input_dim_0': {
                0: np.array([1, 2, 3, 4]),
                1: np.array([2, 4]),
                2: np.array([0, 2, 3])
            }
        }
        values = {
            0: np.array([1, 2, 3, 4]),
            1: np.array([5, 6]),
            2: np.array([8, 9, 7])
        }
        irregu_fd = IrregularFunctionalData(argvals, values)
        self.assertRaises(TypeError, _check_same_type, dense_fd, irregu_fd)