def test_endian_little(self): """`PackedBinariesReader`: floats with little-endianness""" # 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_endian(1) # '<' test that sending an int choice works # 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 test_doubles(self): """`PackedBinariesReader`: doubles""" # Make data and write out dtype = np.dtype('d') 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('d') # Perfrom Read reader.Update() table = reader.GetOutput() # Check output self._check_data(table, arr) return
def SetDataName(self, dataName): PackedBinariesReader.SetDataName(self, dataName)
def SetDataType(self, dtype): PackedBinariesReader.SetDataType(self, dtype)
def SetEndian(self, endian): PackedBinariesReader.SetEndian(self, endian)
def GetTimestepValues(self): """This is critical for registering the timesteps""" return PackedBinariesReader.GetTimestepValues(self)
def SetTimeDelta(self, dt): PackedBinariesReader.SetTimeDelta(self, dt)
def AddFileName(self, fname): PackedBinariesReader.AddFileName(self, fname)
def __init__(self): PackedBinariesReader.__init__(self)
def set_data_name(self, data_name): PackedBinariesReader.set_data_name(self, data_name)
def set_data_type(self, dtype): PackedBinariesReader.set_data_type(self, dtype)
def set_endian(self, endian): PackedBinariesReader.set_endian(self, endian)
def get_time_step_values(self): """This is critical for registering the timesteps""" return PackedBinariesReader.get_time_step_values(self)
def set_time_delta(self, dt): PackedBinariesReader.set_time_delta(self, dt)