def test_ints(self): """`PackedBinariesReader`: ints""" # Make data and write out dtype = np.dtype('i') arr = np.array(np.random.random(self.n), dtype=dtype) filename = os.path.join(self.test_dir, 'test.bin') arr.tofile(filename) # Set up reader reader = PackedBinariesReader() reader.AddFileName(filename) reader.set_data_type(2) # 'i' test that sending an int choice works # Perfrom Read reader.Update() table = reader.GetOutput() # Check output self._check_data(table, arr) return
def test_endian_big(self): """`PackedBinariesReader`: floats with big-endianness""" # Make data and write out dtype = np.dtype('>f') arr = np.asarray(np.random.random(self.n), dtype=dtype) filename = os.path.join(self.test_dir, 'test.bin') arr.tofile(filename) # Set up reader reader = PackedBinariesReader() reader.AddFileName(filename) reader.set_data_type('f') reader.set_endian('>') # Perfrom Read reader.Update() table = reader.GetOutput() # Check output self._check_data(table, arr) return
def test_floats(self): """`PackedBinariesReader`: floats""" # Make data and write out dtype = np.dtype('f') arr = np.array(np.random.random(self.n), dtype=dtype) filename = os.path.join(self.test_dir, 'test.bin') arr.tofile(filename) # Set up reader reader = PackedBinariesReader() reader.AddFileName(filename) reader.set_data_type('f') reader.set_data_name('Test Data') # Perfrom Read reader.Update() table = reader.GetOutput() # Check output self.assertEqual(table.GetColumnName(0), 'Test Data') self._check_data(table, arr) return
def AddFileName(self, fname): PackedBinariesReader.AddFileName(self, fname)