Beispiel #1
0
def test_chooses_method_raises_no_gpu():
    """The choose_method should raise in absence of GPU extension when 'gpu' method is specified."""
    with pytest.raises(ValueError):
        assert core.choose_method(None, method='gpu')

    with pytest.raises(ValueError):
        assert core.choose_method(None, method='GPU')
Beispiel #2
0
def test_choose_method_supplied_method():
    """The choose_method should return user-supplied method in presence of gpu extension."""
    assert core.choose_method(object(), method='CPU') == 'cpu'
    assert core.choose_method(object(), method='cpu') == 'cpu'
    assert core.choose_method(object(), method='GPU') == 'gpu'
    assert core.choose_method(object(), method='gpu') == 'gpu'
Beispiel #3
0
def test_choose_method_not_supplied_w_gpu():
    """The choose_method should return 'gpu' in absence of 'method' kwarg and GPU ext."""
    assert core.choose_method(object()) == 'gpu'
    assert core.choose_method(object(), chunk_size=4, omp_threads=3) == 'gpu'
Beispiel #4
0
def test_choose_method_raises_on_invalid_method():
    """The choose_method should raise ValueError when invalid computation method is supplied."""
    with pytest.raises(ValueError):
        assert core.choose_method(None, method='invalidmethod')
Beispiel #5
0
def test_choose_method_not_supplied_wo_gpu():
    """The choose_method should return 'cpu' in absence of 'method' kwarg and no GPU ext."""
    assert core.choose_method(None) == 'cpu'
    assert core.choose_method(None, omp_threads=4) == 'cpu'