예제 #1
0
def test_input_threshold_positive():
    """
    Test for error if threshold is negative
    """
    try:
        filter_distances(point=x, data=df, threshold=-5.5)
    except:
        assert True
예제 #2
0
def test_input_threshold_numeric():
    """
    Test for error if input threshold is not a single value
    """
    try:
        filter_distances(point=x, data=df, threshold="five")
    except:
        assert True
예제 #3
0
def test_input_threshold_single():
    """
    Test for error if input threshold is not a single value
    """
    try:
        filter_distances(point=x, data=df, threshold=[1, 2, 3])
    except:
        assert True
예제 #4
0
def test_input_point_list():
    """
    Test for error if point is not a list
    """
    try:
        filter_distances(point=1, data=df, threshold=threshold)
    except:
        assert True
    else:
        assert False
예제 #5
0
def test_input_data_type():
    """
    Test for error if data input is not a DataFrame
    """
    try:
        filter_distances(point=x, data=[1, 2, 3], threshold=threshold)
    except:
        assert True
    else:
        assert False
예제 #6
0
def test_output_ints():
    """
    Test that output contains ints only
    """
    output = filter_distances(point=x, data=df, threshold=threshold)

    assert (all(isinstance(x, int) for x in output))
예제 #7
0
def test_output_positive():
    """
    Test that output contains non-negative ints
    (since they are indices, they cannot be negative)
    """
    output = filter_distances(point=x, data=df, threshold=threshold)

    assert (all(x >= 0 for x in output))
예제 #8
0
def test_output_type():
    """
    Test that output is of type list
    """
    assert (type(filter_distances(point=x, data=df,
                                  threshold=threshold)) == list)