예제 #1
0
def basic(n):
    arr = k.array(n)
    assert_equals(arr.n_dims(), 1)
    for i in range(n):
        arr[i] = i * 0.5;
    
    for i in range(n):
        assert_equals(arr[i], i * 0.5)
예제 #2
0
def basic_2d(n):
    arr = k.array(n,n)
    assert_equals(arr.n_dims(), 2)

    for i in range(n):
        for j in range(n):
            arr[i,j] = i*n + j;

    for i in range(n):
        for j in range(n):
            assert_equals(arr[i,j], i*n + j)
예제 #3
0
 def setUp(self):
     n = 10
     a = k.array(n,n)
     counter = 0
     assert_equal(a.n_dims(), 2)
     assert_equal(a.dim(0), n)
     assert_equal(a.dim(1), n)
     for j in range(n):
         for i in range(n):
             a[i,j] = counter
             assert_equal(j*10 + i, counter)
             counter += 1
     self.n = n
     self.a = a
예제 #4
0
 def setUp(self):
     self.a = k.array(10)
     for i in range(10):
         self.a[i] = i
예제 #5
0
파일: abuse.py 프로젝트: JasVixBan/kamasu
#!/usr/bin/python

from resophonic import kamasu
import sys

n = 10

arr = kamasu.array(n)

for i in range(n):
    print arr[i]

for i in range(n):
    arr[i] = i * 0.5;

for i in range(n):
    print arr[i]

    
arr = kamasu.array(n,n)

for i in range(n):
    for j in range(n):
        arr[i,j] = i*n + j;

for i in range(n):
    for j in range(n):
        assert arr[i,j] == i*n + j

subarr = arr[1:n-1, 1:n-1]
예제 #6
0
def dims_impl(n,dim):
    arr = k.array(*([dim]*n))
    assert_equals(arr.n_dims(), n)
    assert_equals(arr.linear_size(), dim**n)