예제 #1
0
    def test_fromRandom_1D_dense(self):
        """Test random 1d sparse"""

        ans = Fiber([0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
                    [7, 1, 8, 3, 8, 4, 6, 3, 7, 5])

        attr = [[0], 1, None, [10]]

        f = Fiber.fromRandom([10], [1.0], 9, 10)
        f_attr = self.attributes(f)

        self.assertEqual(f, ans)
        self.assertEqual(f_attr, attr)
예제 #2
0
    def test_fromRandom_1D_sparse(self):
        """Test random 1d sparse"""

        ans = Fiber([3, 6, 8, 9, 12, 16, 19, 20, 28, 30, 32, 38, 40, 43, 46, 47, 48, 49],
                    [8, 9, 6, 3, 5, 4, 1, 4, 6, 4, 1, 6, 2, 6, 5, 9, 2, 5])

        attr = [[0], 1, None, [50]]

        f = Fiber.fromRandom([50], [0.3], 9, 10)
        f_attr = self.attributes(f)

        self.assertEqual(f, ans)
        self.assertEqual(f_attr, attr)
예제 #3
0
    def test_fromRandom_2D_sparse(self):
        """Test random 1d sparse"""

        ans = Fiber([0, 1, 2],
                    [Fiber([2], [4]),
                     Fiber([1], [4]),
                     Fiber([2], [2])])

        attr = [[Fiber, 0], 2, None, [3, 3]]
   
        f = Fiber.fromRandom([3, 3], [1.0, 0.3], 4, 10)
        f_attr = self.attributes(f)

        self.assertEqual(f, ans)
        self.assertEqual(f_attr, attr)