コード例 #1
0
def testArgsDictDistance():
    with pytest.raises(Exception) as e:
        getDistance({
            'i': 0,
            'j': 1
        }, {
            'i': 0,
            'j': 1
        }, {
            'i': 0,
            'j': 1
        }, {
            'i': 0,
            'j': 1
        })
コード例 #2
0
def getPeopleWithinThreshold(people, threshold, latitude, longitude):
    """
    Processes people and returns people within threshold distance of input latitude and longitude coordinates

    args:
    people(list[Person]): list of person
    threshold (decimal): threshold distance
    latitude(decimal): Dublin latitude
    longitude(decimal): Dublin longitude

    output:
    invitedPeople (list[Person]): list of person within threshold
    """
    if not isinstance(threshold, Number):
        raise Exception("threshold is invalid")
    invitedPeople = list()
    for being in people:
        dist = mathUtils.getDistance(latitude, longitude, being.latitude,
                                     being.longitude)
        if dist < threshold:
            invitedPeople.append(being)
    return invitedPeople
コード例 #3
0
def testArgsTupleDistance():
    with pytest.raises(Exception) as e:
        getDistance((0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0))
コード例 #4
0
def testArgsBoolDistance():
    with pytest.raises(Exception) as e:
        assert getDistance(True, False, True, False)
コード例 #5
0
def testArgsListDistance():
    with pytest.raises(Exception) as e:
        getDistance([0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0])
コード例 #6
0
def testArgsStringDistance():
    with pytest.raises(Exception) as e:
        getDistance("string", "string", "string", "string")
コード例 #7
0
def testArgsNoneDistance():
    with pytest.raises(Exception) as e:
        getDistance(None, None, None, None)
コード例 #8
0
def testWorkingDistance():
    # checked using online calculator and random coords
    assert math.isclose(getDistance(44.4523, -14.4543, -55.453, 24.2345),
                        Decimal('10782'),
                        rel_tol=0.5) == True