From eb07e02489105e90fdd558b0caf9d9dd324087d0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Aug 2024 04:46:27 +0000 Subject: [PATCH 1/7] Bump h5io-browser from 0.0.17 to 0.0.18 Bumps [h5io-browser](https://github.com/h5io/h5io_browser) from 0.0.17 to 0.0.18. - [Release notes](https://github.com/h5io/h5io_browser/releases) - [Commits](https://github.com/h5io/h5io_browser/compare/h5io_browser-0.0.17...h5io_browser-0.0.18) --- updated-dependencies: - dependency-name: h5io-browser dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 7e59b7349..eaec67183 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,7 +26,7 @@ classifiers = [ dependencies = [ "cloudpickle==3.0.0", "executorlib==0.0.1", - "h5io_browser==0.0.17", + "h5io_browser==0.0.18", "h5py==3.11.0", "numpy==2.0.1", "monty==2024.7.30", From 9b60b2279ffdd681ff3bc1d20d1f44e5e5df86a0 Mon Sep 17 00:00:00 2001 From: Jan Janssen Date: Mon, 19 Aug 2024 06:55:23 +0200 Subject: [PATCH 2/7] Update environment.yml --- .ci_support/environment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci_support/environment.yml b/.ci_support/environment.yml index 95b476c8c..190da088b 100644 --- a/.ci_support/environment.yml +++ b/.ci_support/environment.yml @@ -7,7 +7,7 @@ dependencies: - conda_subprocess =0.0.4 - cloudpickle =3.0.0 - gitpython =3.1.43 -- h5io_browser =0.0.17 +- h5io_browser =0.0.18 - h5py =3.11.0 - jinja2 =3.1.4 - monty =2024.7.30 From 477ccc9c5a0876ef18d8067d3ebdf72785b8eed3 Mon Sep 17 00:00:00 2001 From: Jan Janssen Date: Mon, 19 Aug 2024 06:55:36 +0200 Subject: [PATCH 3/7] Update environment-docs.yml --- .ci_support/environment-docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci_support/environment-docs.yml b/.ci_support/environment-docs.yml index b705655c3..8a0845112 100644 --- a/.ci_support/environment-docs.yml +++ b/.ci_support/environment-docs.yml @@ -9,7 +9,7 @@ dependencies: - conda_subprocess =0.0.4 - cloudpickle =3.0.0 - gitpython =3.1.43 -- h5io_browser =0.0.17 +- h5io_browser =0.0.18 - h5py =3.11.0 - jinja2 =3.1.4 - monty =2024.7.30 From a314ccd81784a084c593d77aad9fd50a10c98e8d Mon Sep 17 00:00:00 2001 From: Jan Janssen Date: Mon, 19 Aug 2024 06:55:48 +0200 Subject: [PATCH 4/7] Update environment-mini.yml --- .ci_support/environment-mini.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci_support/environment-mini.yml b/.ci_support/environment-mini.yml index ab75297f0..1144eb84f 100644 --- a/.ci_support/environment-mini.yml +++ b/.ci_support/environment-mini.yml @@ -2,7 +2,7 @@ channels: - conda-forge dependencies: - cloudpickle =3.0.0 -- h5io_browser =0.0.17 +- h5io_browser =0.0.18 - h5py =3.11.0 - monty =2024.7.30 - numpy =2.0.1 From 894e44f5b0b995af6d340950399e6d508fe4bc06 Mon Sep 17 00:00:00 2001 From: Jan Janssen Date: Mon, 19 Aug 2024 06:56:09 +0200 Subject: [PATCH 5/7] Update environment.yml --- binder/environment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/binder/environment.yml b/binder/environment.yml index a17aa7205..bde3a56f6 100644 --- a/binder/environment.yml +++ b/binder/environment.yml @@ -6,7 +6,7 @@ dependencies: - conda_subprocess =0.0.4 - cloudpickle =3.0.0 - gitpython =3.1.43 -- h5io_browser =0.0.17 +- h5io_browser =0.0.18 - h5py =3.11.0 - jinja2 =3.1.4 - monty =2024.7.30 From 7386f8b6a36061d04316b6b98608172c5b214c94 Mon Sep 17 00:00:00 2001 From: Jan Janssen Date: Mon, 19 Aug 2024 09:01:51 +0200 Subject: [PATCH 6/7] fix test for partial read --- tests/unit/storage/test_helper_functions.py | 103 ++++++++++---------- 1 file changed, 49 insertions(+), 54 deletions(-) diff --git a/tests/unit/storage/test_helper_functions.py b/tests/unit/storage/test_helper_functions.py index e266bc90b..81cbf0d2d 100644 --- a/tests/unit/storage/test_helper_functions.py +++ b/tests/unit/storage/test_helper_functions.py @@ -1,5 +1,6 @@ import os import posixpath +import numpy as np import h5py from unittest import TestCase from pyiron_base.storage.hdfio import _list_groups_and_nodes @@ -23,58 +24,55 @@ class TestWriteHdfIO(TestCase): def setUp(self): self.file_name = "test_write_hdf5.h5" self.h5_path = "data_hierarchical" - self.data_hierarchical = {"a": [1, 2], "b": 3, "c": {"d": 4, "e": {"f": 5}}} - _write_hdf( - hdf_filehandle=self.file_name, - data=self.data_hierarchical, - h5_path=self.h5_path, + self.data_hierarchical = {"a": np.array([1, 2]), "b": 3, "c": {"d": np.array([4, 5]), "e": np.array([6, 7])}} + write_dict_to_hdf( + file_name=self.file_name, + data_dict={ + posixpath.join(self.h5_path, "a"): self.data_hierarchical["a"], + posixpath.join(self.h5_path, "b"): self.data_hierarchical["b"], + posixpath.join(self.h5_path, "c", "d"): self.data_hierarchical["c"]["d"], + posixpath.join(self.h5_path, "c", "e"): self.data_hierarchical["c"]["e"], + }, ) def tearDown(self): os.remove(self.file_name) - def test_read_hierarchical(self): - self.assertEqual( - self.data_hierarchical, - _read_hdf(hdf_filehandle=self.file_name, h5_path=self.h5_path), - ) - def test_read_dict_hierarchical(self): - self.assertEqual( - {"key_b": 3}, - read_nested_dict_from_hdf(file_name=self.file_name, h5_path=self.h5_path), + output = read_nested_dict_from_hdf(file_name=self.file_name, h5_path=self.h5_path) + self.assertTrue( + np.all(np.equal(output["a"], np.array([1, 2]))), ) - self.assertEqual( - {"key_a": {"idx_0": 1, "idx_1": 2}, "key_b": 3, "key_c": {"key_d": 4}}, - read_nested_dict_from_hdf( - file_name=self.file_name, - h5_path=self.h5_path, - group_paths=["key_a", "key_c"], - ), + self.assertEqual(output["b"], 3) + output = read_nested_dict_from_hdf( + file_name=self.file_name, + h5_path=self.h5_path, + group_paths=["c"], ) - self.assertEqual( - { - "key_a": {"idx_0": 1, "idx_1": 2}, - "key_b": 3, - "key_c": {"key_d": 4, "key_e": {"key_f": 5}}, - }, - read_nested_dict_from_hdf( - file_name=self.file_name, - h5_path=self.h5_path, - group_paths=["key_a", "key_c", "key_c/key_e"], - ), + self.assertTrue( + np.all(np.equal(output["a"], np.array([1, 2]))), ) - self.assertEqual( - { - "key_a": {"idx_0": 1, "idx_1": 2}, - "key_b": 3, - "key_c": {"key_d": 4, "key_e": {"key_f": 5}}, - }, - read_nested_dict_from_hdf( - file_name=self.file_name, - h5_path=self.h5_path, - recursive=True, - ), + self.assertEqual(output["b"], 3) + self.assertTrue( + np.all(np.equal(output["c"]["d"], np.array([4, 5]))), + ) + self.assertTrue( + np.all(np.equal(output["c"]["e"], np.array([6, 7]))), + ) + output = read_nested_dict_from_hdf( + file_name=self.file_name, + h5_path=self.h5_path, + recursive=True, + ) + self.assertTrue( + np.all(np.equal(output["a"], np.array([1, 2]))), + ) + self.assertEqual(output["b"], 3) + self.assertTrue( + np.all(np.equal(output["c"]["d"], np.array([4, 5]))), + ) + self.assertTrue( + np.all(np.equal(output["c"]["e"], np.array([6, 7]))), ) def test_write_overwrite_error(self): @@ -90,23 +88,20 @@ def test_hdf5_structure(self): self.assertEqual( get_hdf5_raw_content(file_name=self.file_name), [ - {"data_hierarchical": {"TITLE": "dict"}}, - {"data_hierarchical/key_a": {"TITLE": "list"}}, - {"data_hierarchical/key_a/idx_0": {"TITLE": "int"}}, - {"data_hierarchical/key_a/idx_1": {"TITLE": "int"}}, - {"data_hierarchical/key_b": {"TITLE": "int"}}, - {"data_hierarchical/key_c": {"TITLE": "dict"}}, - {"data_hierarchical/key_c/key_d": {"TITLE": "int"}}, - {"data_hierarchical/key_c/key_e": {"TITLE": "dict"}}, - {"data_hierarchical/key_c/key_e/key_f": {"TITLE": "int"}}, + {"data_hierarchical": {}}, + {"data_hierarchical/a": {"TITLE": "ndarray"}}, + {"data_hierarchical/b": {"TITLE": "int"}}, + {"data_hierarchical/c": {}}, + {"data_hierarchical/c/d": {"TITLE": "ndarray"}}, + {"data_hierarchical/c/e": {"TITLE": "ndarray"}}, ], ) def test_list_groups(self): with h5py.File(self.file_name, "r") as f: groups, nodes = _list_groups_and_nodes(hdf=f, h5_path="data_hierarchical") - self.assertEqual(list(sorted(groups)), ["key_a", "key_c"]) - self.assertEqual(nodes, ["key_b"]) + self.assertEqual(list(sorted(groups)), ["c"]) + self.assertEqual(list(sorted(nodes)), ["a", "b"]) class TestWriteDictHdfIO(TestCase): From 67c2a5923acb049acb42c992512725c466a34b41 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 19 Aug 2024 07:03:52 +0000 Subject: [PATCH 7/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/unit/storage/test_helper_functions.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tests/unit/storage/test_helper_functions.py b/tests/unit/storage/test_helper_functions.py index 81cbf0d2d..f3141ddf5 100644 --- a/tests/unit/storage/test_helper_functions.py +++ b/tests/unit/storage/test_helper_functions.py @@ -24,14 +24,22 @@ class TestWriteHdfIO(TestCase): def setUp(self): self.file_name = "test_write_hdf5.h5" self.h5_path = "data_hierarchical" - self.data_hierarchical = {"a": np.array([1, 2]), "b": 3, "c": {"d": np.array([4, 5]), "e": np.array([6, 7])}} + self.data_hierarchical = { + "a": np.array([1, 2]), + "b": 3, + "c": {"d": np.array([4, 5]), "e": np.array([6, 7])}, + } write_dict_to_hdf( file_name=self.file_name, data_dict={ posixpath.join(self.h5_path, "a"): self.data_hierarchical["a"], posixpath.join(self.h5_path, "b"): self.data_hierarchical["b"], - posixpath.join(self.h5_path, "c", "d"): self.data_hierarchical["c"]["d"], - posixpath.join(self.h5_path, "c", "e"): self.data_hierarchical["c"]["e"], + posixpath.join(self.h5_path, "c", "d"): self.data_hierarchical["c"][ + "d" + ], + posixpath.join(self.h5_path, "c", "e"): self.data_hierarchical["c"][ + "e" + ], }, ) @@ -39,7 +47,9 @@ def tearDown(self): os.remove(self.file_name) def test_read_dict_hierarchical(self): - output = read_nested_dict_from_hdf(file_name=self.file_name, h5_path=self.h5_path) + output = read_nested_dict_from_hdf( + file_name=self.file_name, h5_path=self.h5_path + ) self.assertTrue( np.all(np.equal(output["a"], np.array([1, 2]))), )