def check_numpy_structured_array_empty(self, dimensions): # Makes a random structured ndarray of the given type, writes it # and reads it back, and then compares it. shape = random_numpy_shape(dimensions, \ max_structured_ndarray_axis_length) data = random_structured_numpy_array(shape, (1, 0)) out = self.write_readback(data, random_name(), self.options) self.assert_equal(out, data)
def test_numpy_recarray_unicode_fields(self): # Makes a random 1d structured ndarray with non-ascii characters # in its fields, converts it to a recarray, writes it and reads # it back, and then compares it. shape = random_numpy_shape(1, \ max_structured_ndarray_axis_length) data = random_structured_numpy_array(shape, nonascii_fields=True) out = self.write_readback(data, random_name(), self.options) self.assert_equal(out, data)
def check_numpy_recarray(self, dimensions): # Makes a random structured ndarray of the given type, converts # it to a recarray, writes it and reads it back, and then # compares it. shape = random_numpy_shape(dimensions, \ max_structured_ndarray_axis_length) data = random_structured_numpy_array(shape).view(np.recarray).copy() out = self.write_readback(data, random_name(), self.options) self.assert_equal(out, data)
def check_numpy_recarray_field_special_char(self, ch, leading=False): # Makes a random 1d structured ndarray with the character # in one field, converts it to a recarray, writes it and reads # it back, and then compares it. field_names = [random_str_ascii(max_dict_key_length) for i in range(2)] if leading: field_names[1] = ch + field_names[1] else: field_names[1] = field_names[1][0] + ch + field_names[1][1:] shape = random_numpy_shape(1, \ max_structured_ndarray_axis_length) data = random_structured_numpy_array(shape, names=field_names).view( np.recarray).copy() out = self.write_readback(data, random_name(), self.options) self.assert_equal(out, data)
to_julia['object'] = random_numpy_scalar('object', \ object_element_dtypes=dtypes_to_do) to_julia['object_array_2'] = random_numpy( \ random_numpy_shape(2, 6, min_length=2), \ 'object', object_element_dtypes=dtypes_to_do) to_julia['object_array_3'] = random_numpy( \ random_numpy_shape(3, 6, min_length=2), \ 'object', object_element_dtypes=dtypes_to_do) # Julia MAT doesn't seem to read and then write back empty object # types. #to_julia['object_empty'] = np.array([], dtype='object') to_julia['struct'] = random_structured_numpy_array((1,), \ nondigits_fields=True) to_julia['struct_empty'] = random_structured_numpy_array(tuple(), \ nondigits_fields=True) # Something goes wrong with 2 dimensional structure arrays that warrants # further investigation. #to_julia['struct_array_2'] = random_structured_numpy_array((3, 5), \ # nondigits_fields=True) from_julia_v7_to_v7p3 = dict() from_julia_v7p3_to_v7p3 = dict() def julia_command(julia_file, fin, fout): subprocess.check_call(['julia', julia_file, fin, fout],