コード例 #1
0
def test_sample_data_sample(X_df, y_series):
    with patch('probatus.metric_volatility.utils.check_sampling_input'
               ) as mock_sampling_input:
        X_out, y_out = sample_data(X_df,
                                   y_series,
                                   sampling_type='subsample',
                                   sampling_fraction=1)
        mock_sampling_input.assert_called_once()
    pd.testing.assert_frame_equal(X_out, X_df)
    pd.testing.assert_series_equal(y_out, y_series)
コード例 #2
0
def test_sample_data_bootstrap(X_df, y_series):
    with patch('probatus.metric_volatility.utils.check_sampling_input'
               ) as mock_sampling_input:
        X_out, y_out = sample_data(X_df,
                                   y_series,
                                   sampling_type='bootstrap',
                                   sampling_fraction=0.8)
        mock_sampling_input.assert_called_once()
    assert X_out.shape == (4, 2)
    assert y_out.shape == (4, )
コード例 #3
0
def test_sample_data_no_sampling(X_df, y_series):
    """
    Test.
    """
    with patch("probatus.metric_volatility.utils.check_sampling_input"
               ) as mock_sampling_input:
        X_out, y_out = sample_data(X_df,
                                   y_series,
                                   sampling_type=None,
                                   sampling_fraction=1)
        mock_sampling_input.assert_called_once()
    pd.testing.assert_frame_equal(X_out, X_df)
    pd.testing.assert_series_equal(y_out, y_series)