コード例 #1
0
def test_make_list_of_ints():
    mylist = [1, 2, 3., 42, -2]
    assert make_list_of_ints(mylist) is mylist
    assert make_list_of_ints(mylist) == mylist
    assert type(make_list_of_ints(mylist)[2]) is int
    pytest.raises(nx.NetworkXError, make_list_of_ints, [1, 2, 3, "kermit"])
    pytest.raises(nx.NetworkXError, make_list_of_ints, [1, 2, 3.1])
コード例 #2
0
 def test_numpy_to_list_of_ints(self):
     a = numpy.array([1, 2, 3], dtype=numpy.int64)
     b = numpy.array([1., 2, 3])
     c = numpy.array([1.1, 2, 3])
     assert type(make_list_of_ints(a)) == list
     assert make_list_of_ints(b) == list(b)
     B = make_list_of_ints(b)
     assert type(B[0]) == int
     pytest.raises(nx.NetworkXError, make_list_of_ints, c)