コード例 #1
0
 def test_importing_large_numpy_file_sets_large_format_flag(self):
     current_working_directory = os.getcwd()
     file_path_npy = os.path.join(current_working_directory, "__file.npy")
     numpy.save(file_path_npy, numpy.zeros((4, 4, 4)))
     handler = ImportExportManager.NumPyImportExportHandler(
         "numpy-io-handler", "npy", ["npy"])
     try:
         data_items = handler.read_data_items(None, "npy", file_path_npy)
         self.assertEqual(len(data_items), 1)
         data_item = data_items[0]
         self.assertTrue(data_item.large_format)
     finally:
         os.remove(file_path_npy)
コード例 #2
0
 def test_npy_write_to_then_read_from_temp_file(self):
     document_model = DocumentModel.DocumentModel()
     with contextlib.closing(document_model):
         current_working_directory = os.getcwd()
         file_path_npy = os.path.join(current_working_directory, "__file.npy")
         file_path_json = os.path.join(current_working_directory, "__file.json")
         numpy.save(file_path_npy, numpy.zeros((16, 16)))
         with open(file_path_json, "w") as f:
             json.dump({"version": 1}, f)
         handler = ImportExportManager.NumPyImportExportHandler("numpy-io-handler", "npy", ["npy"])
         try:
             data_items = handler.read_data_items(None, "npy", file_path_npy)
             self.assertEqual(len(data_items), 1)
             data_item = data_items[0]
         finally:
             os.remove(file_path_npy)
             os.remove(file_path_json)
コード例 #3
0
 def test_npy_write_to_then_read_from_temp_file(self):
     with TestContext.create_memory_context() as test_context:
         document_model = test_context.create_document_model()
         current_working_directory = os.getcwd()
         file_path_npy = os.path.join(current_working_directory,
                                      "__file.npy")
         file_path_json = os.path.join(current_working_directory,
                                       "__file.json")
         numpy.save(file_path_npy, numpy.zeros((16, 16)))
         with open(file_path_json, "w") as f:
             json.dump({"version": 1}, f)
         handler = ImportExportManager.NumPyImportExportHandler(
             "numpy-io-handler", "npy", ["npy"])
         try:
             data_items = handler.read_data_items(
                 "npy", pathlib.Path(file_path_npy))
             self.assertEqual(len(data_items), 1)
             data_item = data_items[0]
             for data_item in data_items:
                 data_item.close()
         finally:
             os.remove(file_path_npy)
             os.remove(file_path_json)