def test_OpRawBinaryFileReader(self): # Now read back our test data using an OpRawBinaryFileReader operator op = OpRawBinaryFileReader(graph=Graph()) try: op.FilePath.setValue(self.testDataFilePath) # Read the entire file and verify the contents a = op.Output[:].wait() assert (a == self.testData).all() finally: op.cleanUp()
def _attemptOpenAsRawBinary(self, filePath): fileExtension = os.path.splitext(filePath)[1].lower() fileExtension = fileExtension.lstrip('.') # Remove leading dot # Check for numpy extension if fileExtension not in OpInputDataReader.rawExts: return ([], None) else: try: # Create an internal operator opReader = OpRawBinaryFileReader(parent=self) opReader.FilePath.setValue(filePath) return ([opReader], opReader.Output) except OpRawBinaryFileReader.DatasetReadError as e: raise OpInputDataReader.DatasetReadError(*e.args)