Exemplo n.º 1
0
    def testChaining(self):
        A = SDR([10, 10])
        B = Reshape(A, [100])
        C = Reshape(B, [4, 25])
        D = B.reshape([1, 100])  # Test convenience method.

        A.dense.fill(1)
        A.dense = A.dense
        assert (len(C.sparse) == A.size)
        assert (len(D.sparse) == A.size)
        del B
Exemplo n.º 2
0
    def testChaining(self):
        A = SDR([10, 10])
        B = Reshape(A, [100])
        C = Reshape(B, [4, 25])
        D = Reshape(B, [1, 100])

        A.dense.fill(1)
        A.dense = A.dense
        assert (len(C.sparse) == A.size)
        assert (len(D.sparse) == A.size)
        del B
Exemplo n.º 3
0
 def testExampleUsage(self):
     assert (issubclass(Reshape, SDR))
     # Convert SDR dimensions from (4 x 4) to (8 x 2)
     A = SDR([4, 4])
     B = Reshape(A, [8, 2])
     A.coordinates = ([1, 1, 2], [0, 1, 2])
     assert ((np.array(B.coordinates) == ([2, 2, 5], [0, 1, 0])).all())
Exemplo n.º 4
0
 def testLostSDR(self):
     # You need to keep a reference to the SDR, since SDR class does not use smart pointers.
     B = Reshape(SDR((1000, )), [1000])
     with self.assertRaises(RuntimeError):
         B.dense