Ejemplo n.º 1
0
def test_boundary_inversion_invalid_type(reparam):
    """Assert an error is raised in the type is invalid"""
    with pytest.raises(TypeError) as excinfo:
        RescaleToBounds.__init__(
            reparam,
            parameters='x',
            prior_bounds=[0, 1],
            boundary_inversion='Yes',
        )
    assert 'boundary_inversion must be a list, dict or bool' \
        in str(excinfo.value)
Ejemplo n.º 2
0
def test_rescale_bounds_config(reparam, input, expected_value):
    """Assert the rescale bounds are set correctly."""
    RescaleToBounds.__init__(
        reparam,
        parameters=['x', 'y'],
        prior_bounds={
            'x': [-1, 1],
            'y': [0, 1]
        },
        rescale_bounds=input,
    )
    assert reparam.rescale_bounds == expected_value
Ejemplo n.º 3
0
def test_boundary_inversion_config(reparam, input, expected_value):
    """Assert the boundary inversion dict is set correctly"""
    RescaleToBounds.__init__(
        reparam,
        parameters=['x', 'y'],
        prior_bounds={
            'x': [0, 1],
            'y': [0, 1]
        },
        boundary_inversion=input,
    )
    assert reparam.boundary_inversion == expected_value
Ejemplo n.º 4
0
def test_rescale_bounds_incorrect_type(reparam):
    """Assert an error is raised if the rescale_bounds is an invalid type."""
    with pytest.raises(TypeError) as excinfo:
        RescaleToBounds.__init__(
            reparam,
            parameters=['x', 'y'],
            prior_bounds={
                'x': [-1, 1],
                'y': [0, 1]
            },
            rescale_bounds=1,
        )
    assert 'must be an instance of list or dict' in str(excinfo.value)
Ejemplo n.º 5
0
def test_rescale_bounds_dict_missing_params(reparam):
    """Assert an error is raised if the rescale_bounds dict is missing a
    parameter.
    """
    with pytest.raises(RuntimeError) as excinfo:
        RescaleToBounds.__init__(reparam,
                                 parameters=['x', 'y'],
                                 prior_bounds={
                                     'x': [-1, 1],
                                     'y': [0, 1]
                                 },
                                 rescale_bounds={'x': [0, 1]})
    assert 'Missing rescale bounds for parameters' in str(excinfo.value)
Ejemplo n.º 6
0
def test_detect_edges_without_inversion(reparam):
    """Assert detect edges cannot be used with boundary inversion"""
    with pytest.raises(RuntimeError) as excinfo:
        RescaleToBounds.__init__(
            reparam,
            parameters=['x', 'y'],
            prior_bounds={
                'x': [-1, 1],
                'y': [0, 1]
            },
            detect_edges=True,
        )
    assert 'Must enable boundary inversion to use detect edges' \
        in str(excinfo.value)
Ejemplo n.º 7
0
def test_set_offets(reparam):
    """Assert the offset are set correctly"""
    reparam.pre_rescaling = lambda x: (x / 2, 0.0)

    RescaleToBounds.__init__(
        reparam,
        parameters=['x', 'y'],
        prior_bounds={
            'x': [8, 32],
            'y': [2, 4]
        },
        offset=True,
    )

    assert reparam.offsets == {'x': 10.0, 'y': 1.5}