コード例 #1
0
def test_sum_distances():
    '''
    Tests whether the combinations are summed correctly. 
    '''
    sample_inputs = setup()
    dist_matr = compute_distance_matrix(sample_inputs, 6, 2, local_optimization=True)
    indices = (1,3,2)
    distance = sum_distances(indices, dist_matr)

    expected = 10.47
    assert_allclose(distance, expected, rtol=1e-2)
コード例 #2
0
ファイル: test_morris_util.py プロジェクト: ryants/SALib
def test_sum_distances():
    '''
    Tests whether the combinations are summed correctly. 
    '''
    sample_inputs = setup()
    dist_matr = compute_distance_matrix(sample_inputs,
                                        6,
                                        2,
                                        local_optimization=True)
    indices = (1, 3, 2)
    distance = sum_distances(indices, dist_matr)

    expected = 10.47
    assert_allclose(distance, expected, rtol=1e-2)
コード例 #3
0
ファイル: test_morris_util.py プロジェクト: lidaweicc/SALib
def test_compute_distance_matrix():
    '''
    Tests that a distance matrix is computed correctly

    for an input of six trajectories and two parameters
    '''
    sample_inputs = setup()
    output = compute_distance_matrix(sample_inputs, 6, 2)
    expected = np.zeros((6, 6), dtype=np.float32)
    expected[1, :] = [5.50, 0, 0, 0, 0, 0]
    expected[2, :] = [6.18, 5.31, 0, 0, 0, 0]
    expected[3, :] = [6.89, 6.18, 6.57, 0, 0, 0]
    expected[4, :] = [6.18, 5.31, 5.41, 5.5, 0, 0]
    expected[5, :] = [7.52, 5.99, 5.52, 7.31, 5.77, 0]
    assert_allclose(output, expected, rtol=1e-2)
コード例 #4
0
def test_compute_distance_matrix():
    '''
    Tests that a distance matrix is computed correctly

    for an input of six trajectories and two parameters
    '''
    sample_inputs = setup()
    output = compute_distance_matrix(sample_inputs, 6, 2)
    expected = np.zeros((6, 6), dtype=np.float32)
    expected[1, :] = [5.50, 0, 0, 0, 0, 0]
    expected[2, :] = [6.18, 5.31, 0, 0, 0, 0]
    expected[3, :] = [6.89, 6.18, 6.57, 0, 0, 0]
    expected[4, :] = [6.18, 5.31, 5.41, 5.5, 0, 0]
    expected[5, :] = [7.52, 5.99, 5.52, 7.31, 5.77, 0]
    assert_allclose(output, expected, rtol=1e-2)
コード例 #5
0
def test_compute_distance_matrix_local():
    '''
    Tests that a distance matrix is computed correctly for the local distance optimization.
    The only change is that the local method needs the upper triangle of 
    the distance matrix instead of the lower one.
    
    This is for an input of six trajectories and two parameters
    '''
    sample_inputs = setup()
    output = compute_distance_matrix(sample_inputs, 6, 2, local_optimization=True)
    expected = np.zeros((6, 6), dtype=np.float32)
    expected[0, :] = [0,    5.50, 6.18, 6.89, 6.18, 7.52]
    expected[1, :] = [5.50, 0,    5.31, 6.18, 5.31, 5.99]
    expected[2, :] = [6.18, 5.31, 0,    6.57, 5.41, 5.52]
    expected[3, :] = [6.89, 6.18, 6.57, 0,    5.50, 7.31]
    expected[4, :] = [6.18, 5.31, 5.41, 5.5,  0,    5.77]
    expected[5, :] = [7.52, 5.99, 5.52, 7.31, 5.77, 0   ]
    assert_allclose(output, expected, rtol=1e-2)
コード例 #6
0
ファイル: test_morris_util.py プロジェクト: ryants/SALib
def test_compute_distance_matrix_local():
    '''
    Tests that a distance matrix is computed correctly for the local distance optimization.
    The only change is that the local method needs the upper triangle of 
    the distance matrix instead of the lower one.
    
    This is for an input of six trajectories and two parameters
    '''
    sample_inputs = setup()
    output = compute_distance_matrix(sample_inputs,
                                     6,
                                     2,
                                     local_optimization=True)
    expected = np.zeros((6, 6), dtype=np.float32)
    expected[0, :] = [0, 5.50, 6.18, 6.89, 6.18, 7.52]
    expected[1, :] = [5.50, 0, 5.31, 6.18, 5.31, 5.99]
    expected[2, :] = [6.18, 5.31, 0, 6.57, 5.41, 5.52]
    expected[3, :] = [6.89, 6.18, 6.57, 0, 5.50, 7.31]
    expected[4, :] = [6.18, 5.31, 5.41, 5.5, 0, 5.77]
    expected[5, :] = [7.52, 5.99, 5.52, 7.31, 5.77, 0]
    assert_allclose(output, expected, rtol=1e-2)