Example #1
0
  def test_broadcast(self):
    a = expr.ones((100, 1, 100, 100)).force()
    b = expr.ones((10, 100, 1)).force()
    a, b = broadcast.broadcast((a, b))
    c = expr.add(a, b).force()
    d = expr.sub(a, b).force()

    n = np.ones((100, 10, 100, 100))
    n1 = n + n
    n2 = n - n
    Assert.all_eq(n1, c.glom())
    Assert.all_eq(n2, d.glom())
Example #2
0
    def test_broadcast(self):
        a = expr.ones((100, 1, 100, 100)).force()
        b = expr.ones((10, 100, 1)).force()
        a, b = broadcast.broadcast((a, b))
        c = expr.add(a, b).force()
        d = expr.sub(a, b).force()

        n = np.ones((100, 10, 100, 100))
        n1 = n + n
        n2 = n - n
        Assert.all_eq(n1, c.glom())
        Assert.all_eq(n2, d.glom())
Example #3
0
 def test_sparse_operators(self):
   x = expr.sparse_diagonal(ARRAY_SIZE)
   #print x.glom().todense()
   
   y = x
   print 'test add'
   #z = expr.add(x, y)
   z = expr.add(x, y)
   print z.glom().todense()
   
   print 'test minus'   
   z = expr.sub(x, y)
   print z.glom().todense()
   
   print 'test multiply'
   z = expr.dot(x, x)
   print z.glom().todense()
Example #4
0
 def test_sparse_operators(self):
   x = expr.sparse_diagonal(ARRAY_SIZE)
   #print x.glom().todense()
   
   y = x
   print 'test add'
   #z = expr.add(x, y)
   z = expr.add(x, y)
   print z.glom().todense()
   
   print 'test minus'   
   z = expr.sub(x, y)
   print z.glom().todense()
   
   print 'test multiply'
   z = expr.dot(x, x)
   print z.glom().todense()