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)
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)
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
def setUp(self): self.a = k.array(10) for i in range(10): self.a[i] = i
#!/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]
def dims_impl(n,dim): arr = k.array(*([dim]*n)) assert_equals(arr.n_dims(), n) assert_equals(arr.linear_size(), dim**n)