예제 #1
0
def test_constant_volume_invalid_latent_prior(proposal):
    """Assert an error is raised if the latent prior is not a truncated \
        Gaussian
    """
    err = "Constant volume requires `latent_prior='truncated_gaussian'`"
    proposal.constant_volume_mode = True
    proposal.latent_prior = 'gaussian'
    with pytest.raises(RuntimeError) as excinfo:
        FlowProposal.configure_constant_volume(proposal)
    assert str(excinfo.value) == err
예제 #2
0
def test_configure_constant_volume(proposal):
    """Test configuration for constant volume mode."""
    proposal.constant_volume_mode = True
    proposal.volume_fraction = 0.95
    proposal.rescaled_dims = 5
    proposal.latent_prior = 'truncated_gaussian'
    proposal.max_radius = 3.0
    proposal.min_radius = 5.0
    proposal.fuzz = 1.5
    with patch('nessai.proposal.flowproposal.compute_radius',
               return_value=4.0) as mock:
        FlowProposal.configure_constant_volume(proposal)
    mock.assert_called_once_with(5, 0.95)
    assert proposal.fixed_radius == 4.0
    assert proposal.min_radius is False
    assert proposal.max_radius is False
    assert proposal.fuzz == 1.0
예제 #3
0
def test_configure_constant_volume_disabled(proposal):
    """Assert nothing happens if constant_volume is False"""
    proposal.constant_volume_mode = False
    with patch('nessai.proposal.flowproposal.compute_radius') as mock:
        FlowProposal.configure_constant_volume(proposal)
    mock.assert_not_called()