コード例 #1
0
ファイル: test_model.py プロジェクト: passion4energy/lmfit-py
def test_get_reducer(option, expected_array):
    """Tests for ValueError when using an unsupported option."""
    complex_array = np.array([1.0, 1.0+10j, 2.0, 2.0+20j], dtype='complex')
    func = get_reducer(option)
    real_array = func(complex_array)

    assert np.all(np.isreal(real_array))
    assert_allclose(real_array, expected_array)

    # nothing should happen to an array that only contains real data
    assert_allclose(func(real_array), real_array)
コード例 #2
0
ファイル: test_model.py プロジェクト: passion4energy/lmfit-py
def test_get_reducer_invalid_option():
    """Tests for ValueError when using an unsupported option."""
    option = 'unknown'
    msg = r'Invalid option'
    with pytest.raises(ValueError, match=msg):
        get_reducer(option)