def numpy_to_carray(self, numpy_arr, arr_len, data_type): """ This method converts the numpy array to a carray Input: Numpy array, array length and data type (to differentiate between float and int) Output: Carray """ #check the datatype if data_type == 1: #create a new carray new_carr = skimsquery.new_floatArray(arr_len) i = 0 #run a loop to assign the values in the numpy array to the carray for each in numpy_arr: skimsquery.floatArray_setitem(new_carr, i, float(each)) i = i + 1 else: #create a new carray new_carr = skimsquery.new_intArray(arr_len) i = 0 #run a loop to assign the values in the numpy array to the carray for each in numpy_arr: skimsquery.intArray_setitem(new_carr, i, int(each)) i = i + 1 #return the carray return new_carr
def create_carray(self, num): """ This method is used to create the origin and destination carrays. Input: Origin and destination numpy arrays Output: Origin and destination carrays """ #print 'testing carray creation' p = skimsquery.new_intArray(num) skimsquery.create_array(p, num) skimsquery.print_array(p, num) return p