How to use the pyiron.base.generic.hdfio.FileHDFio function in pyiron

To help you get started, we’ve selected a few pyiron examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pyiron / pyiron / tests / base / generic / test_fileHDFio.py View on Github external
def setUpClass(cls):
        cls.current_dir = os.path.dirname(os.path.abspath(__file__)).replace('\\', '/')
        cls.empty_hdf5 = FileHDFio(file_name=cls.current_dir + '/filehdfio_empty.h5')
        cls.full_hdf5 = FileHDFio(file_name=cls.current_dir + '/filehdfio_full.h5')
        cls.es_hdf5 = FileHDFio(file_name=cls.current_dir + "/../../static/dft/es_hdf.h5")
        with cls.full_hdf5.open('content') as hdf:
            hdf['array'] = np.array([1, 2, 3, 4, 5, 6])
            hdf['array_3d'] = np.array([[1, 2, 3], [4, 5, 6]])
            hdf['traj'] = np.array([[[1, 2, 3], [4, 5, 6]], [[7, 8, 9]]])
            hdf['dict'] = {'key_1': 1, 'key_2': 'hallo'}
            hdf['dict_numpy'] = {'key_1': 1, 'key_2': np.array([1, 2, 3, 4, 5, 6])}
github pyiron / pyiron / tests / atomistics / structure / test_atoms.py View on Github external
def test_to_hdf(self):
        filename = os.path.join(
            os.path.dirname(os.path.abspath(__file__)),
            "../../static/atomistics/test_hdf",
        )
        abs_filename = os.path.abspath(filename)
        hdf_obj = FileHDFio(abs_filename)
        pos, cell = generate_fcc_lattice()
        basis = Atoms(symbols="Al", positions=pos, cell=cell)
        basis.set_repeat([2, 2, 2])
        basis.to_hdf(hdf_obj, "test_structure")
        self.assertTrue(
            np.array_equal(hdf_obj["test_structure/positions"], basis.positions)
        )
        basis_new = Atoms().from_hdf(hdf_obj, "test_structure")
        self.assertEqual(basis, basis_new)
github pyiron / pyiron / tests / dft / waves / test_electronic.py View on Github external
def test_from_hdf(self):
        if sys.version_info[0] >= 3:
            filename = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../static/dft/es_hdf.h5")
            abs_filename = os.path.abspath(filename)
            hdf_obj = FileHDFio(abs_filename)
            es_obj_old = ElectronicStructure()
            es_obj_old.from_hdf_old(hdf_obj, "es_old")
            es_obj_new = ElectronicStructure()
            es_obj_new.from_hdf(hdf=hdf_obj, group_name="es_new")
            self.assertEqual(es_obj_old.efermi, es_obj_new.efermi)
            self.assertEqual(es_obj_old.is_metal, es_obj_new.is_metal)
            self.assertEqual(es_obj_old.vbm, es_obj_new.vbm)
            self.assertEqual(es_obj_old.cbm, es_obj_new.cbm)
            self.assertTrue(np.array_equal(es_obj_new.grand_dos_matrix, es_obj_old.grand_dos_matrix))
github pyiron / pyiron / tests / base / generic / test_fileHDFio.py View on Github external
def setUpClass(cls):
        cls.current_dir = os.path.dirname(os.path.abspath(__file__)).replace('\\', '/')
        cls.empty_hdf5 = FileHDFio(file_name=cls.current_dir + '/filehdfio_empty.h5')
        cls.full_hdf5 = FileHDFio(file_name=cls.current_dir + '/filehdfio_full.h5')
        cls.es_hdf5 = FileHDFio(file_name=cls.current_dir + "/../../static/dft/es_hdf.h5")
        with cls.full_hdf5.open('content') as hdf:
            hdf['array'] = np.array([1, 2, 3, 4, 5, 6])
            hdf['array_3d'] = np.array([[1, 2, 3], [4, 5, 6]])
            hdf['traj'] = np.array([[[1, 2, 3], [4, 5, 6]], [[7, 8, 9]]])
            hdf['dict'] = {'key_1': 1, 'key_2': 'hallo'}
            hdf['dict_numpy'] = {'key_1': 1, 'key_2': np.array([1, 2, 3, 4, 5, 6])}
github pyiron / pyiron / pyiron / table / datamining.py View on Github external
def from_hdf(self):
        file = FileHDFio(file_name=self._project.path + self.name + ".h5", h5_path="/")
        self.add._from_hdf(file)
github pyiron / pyiron / pyiron / table / datamining.py View on Github external
def to_hdf(self):
        file = FileHDFio(file_name=self._project.path + self.name + ".h5", h5_path="/")
        self.add._to_hdf(file)
github pyiron / pyiron / pyiron / table / datamining.py View on Github external
def create_table(self, enforce_update=False, level=3, file=None, job_status_list=None):
        skip_table_update = False
        filter_funct = self.filter_function
        if job_status_list is None:
            job_status_list = ["finished"]
        if self._is_file():
            if file is None:
                file = FileHDFio(
                    file_name=self._project.path + self.name + ".h5", h5_path="/"
                )
            temp_user_function_dict, temp_system_function_dict = self._get_data_from_hdf5(
                hdf=file
            )
            job_stored_ids = self._get_job_ids()
            job_update_lst = [
                self._project.inspect(job_id)
                for job_id in self._get_filtered_job_ids_from_project()
                if job_id not in job_stored_ids
            ]
            job_update_lst = [
                job
                for job in job_update_lst
                if job.status in job_status_list and filter_funct(job)
            ]
github pyiron / pyiron / pyiron / base / generic / hdfio.py View on Github external
def copy(self):
        """
        Copy the Python object which links to the HDF5 file - in contrast to copy_to() which copies the content of the
        HDF5 file to a new location.

        Returns:
            FileHDFio: New FileHDFio object pointing to the same HDF5 file
        """
        new_h5 = FileHDFio(file_name=self.file_name, h5_path=self.h5_path)
        new_h5._filter = self._filter
        return new_h5