Example #1
0
def test_get_set_aggregator(agg_func):
    """Test getter and setter for Aggregator.func"""
    agg_func_name, _ = agg_func
    agg = Aggregator(agg_func_name)
    assert agg.func == agg_func_name
    agg.func = "sum"
    assert agg.func == "sum"
Example #2
0
def test_aggregator_1d(agg_func):
    """Test Aggregator.aggregate_1d function."""
    agg_func_name, npy_func = agg_func

    agg = Aggregator(agg_func_name)

    data = np.random.rand(10)

    np.testing.assert_allclose(agg.aggregate_1d(data), npy_func(data))
Example #3
0
def test_get_set_aggregator(agg_func):
    """Test getter and setter for Aggregator.func"""
    agg_func_name, _ = agg_func
    agg = Aggregator(agg_func_name)
    if isinstance(agg_func_name, dict):
        assert agg.func == agg_func_name["func"]
    else:
        assert agg.func == agg_func_name
    agg.func = "sum"
    assert agg.func == "sum"
Example #4
0
def test_aggregator_2d(agg_func, axis):
    """Test Aggregator.aggregate_2d function."""
    agg_func_name, npy_func = agg_func

    agg = Aggregator(agg_func_name)

    data = np.random.rand(100, 10)

    result = agg.aggregate_2d(data, axis=axis)
    assert len(result) == data.shape[1 - axis]
    np.testing.assert_allclose(result, npy_func(data, axis=axis))