/usr/share/pyshared/igraph/test/rng.py is in python-igraph 0.6.5-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | import random
import unittest
from igraph import *
class FakeRNG(object):
    @staticmethod
    def random():
        return 0.1
    @staticmethod
    def randint(a, b):
        return a
    @staticmethod
    def gauss(mu, sigma):
        return 0.3
class InvalidRNG(object):
    pass
class RandomNumberGeneratorTests(unittest.TestCase):
    def tearDown(self):
        set_random_number_generator(random)
    def testSetRandomNumberGenerator(self):
        set_random_number_generator(FakeRNG)
        graph = Graph.GRG(10, 0.2)
        self.assertEquals(graph.vs["x"], [0.1] * 10)
        self.assertEquals(graph.vs["y"], [0.1] * 10)
        self.assertRaises(AttributeError, set_random_number_generator,
                InvalidRNG)
    def testSeeding(self):
        state = random.getstate()
        g1 = Graph.Erdos_Renyi(n=1000, m=5000)
        random.setstate(state)
        g2 = Graph.Erdos_Renyi(n=1000, m=5000)
        self.failUnless(g1.get_edgelist() == g2.get_edgelist())
def suite():
    random_suite = unittest.makeSuite(RandomNumberGeneratorTests)
    return unittest.TestSuite([random_suite])
def test():
    runner = unittest.TextTestRunner()
    runner.run(suite())
    
if __name__ == "__main__":
    test()
 |