def test_assign_scalar_to_two_d_array(self):
     # Set up our data buffers
     src = data_descriptor_from_ctypes(ctypes.c_float(-50), writable=False)
     dst = data_descriptor_from_ctypes((ctypes.c_double * 3 * 4)(), writable=True)
     # Do the assignment
     execute_unary_single(dst, src, datashape.float64, datashape.float32, self.sqr)
     self.assertEqual(dd_as_py(dst), [[-50.0 * -50] * 3] * 4)
 def test_assign_scalar(self):
     # Set up our data buffers
     src = data_descriptor_from_ctypes(ctypes.c_float(1028), writable=False)
     dst = data_descriptor_from_ctypes(ctypes.c_double(-100), writable=True)
     # Do the assignment
     execute_unary_single(dst, src, datashape.float64, datashape.float32, self.sqr)
     self.assertEqual(dd_as_py(dst), 1028.0*1028.0)
 def test_assign_scalar_to_one_d_array(self):
     # Set up our data buffers
     src = data_descriptor_from_ctypes(ctypes.c_int64(1028), writable=False)
     dst = data_descriptor_from_ctypes((ctypes.c_float * 3)(), writable=True)
     # Do the assignment
     execute_unary_single(dst, src, datashape.float32, datashape.int64, self.ck)
     self.assertEqual(dd_as_py(dst), [1028.0] * 3)
 def test_assign_one_d_to_two_d_array(self):
     # Set up our data buffers
     src_data = (ctypes.c_float * 3)()
     for i, val in enumerate([3, 6, 9]):
         src_data[i] = val
     src = data_descriptor_from_ctypes(src_data, writable=False)
     dst = data_descriptor_from_ctypes((ctypes.c_double * 3 * 4)(), writable=True)
     # Do the assignment
     execute_unary_single(dst, src, datashape.float64, datashape.float32, self.sqr)
     self.assertEqual(dd_as_py(dst), [[x*x for x in [3.0, 6.0, 9.0]]] * 4)
 def test_assign_broadcast_outer_two_d_to_two_d_array(self):
     # Set up our data buffers
     src_data = (ctypes.c_int64 * 3 * 1)()
     for i, val_i in enumerate([[3,1,7]]):
         for j, val in enumerate(val_i):
             src_data[i][j] = val
     src = data_descriptor_from_ctypes(src_data, writable=False)
     dst = data_descriptor_from_ctypes((ctypes.c_float * 3 * 4)(), writable=True)
     # Do the assignment
     execute_unary_single(dst, src, datashape.float32, datashape.int64, self.ck)
     self.assertEqual(dd_as_py(dst), [[3,1,7]]*4)
 def test_assign_broadcast_inner_two_d_to_two_d_array(self):
     # Set up our data buffers
     src_data = (ctypes.c_float * 1 * 4)()
     src_list = [[3], [1], [7], [12]]
     for i, val_i in enumerate(src_list):
         for j, val in enumerate(val_i):
             src_data[i][j] = val
     src = data_descriptor_from_ctypes(src_data, writable=False)
     dst = data_descriptor_from_ctypes((ctypes.c_double * 3 * 4)(), writable=True)
     # Do the assignment
     execute_unary_single(dst, src, datashape.float64, datashape.float32, self.sqr)
     self.assertEqual(dd_as_py(dst), [[x*x for x in y] * 3 for y in src_list])