Exemplo n.º 1
0
def test_add_registries():
    registries1 = new_registry_list()
    registries2 = new_registry_list()
    summed_registries = registries1 + registries2
    assert len([r for r in summed_registries.registries]) == (
        len([r for r in registries1.registries]) +
        len([r for r in registries2.registries])
    )
Exemplo n.º 2
0
 def obj_registry_with_none_with_defaults(request):
     return {
         "registries":
         new_registry_list(get_fixture_val(request.param[0], request)),
         "dumpable_object":
         get_fixture_val(request.param[1], request)
     }
Exemplo n.º 3
0
 def test_require_group_exist(self, h5py_file_with_group):
     group = h5py_file_with_group["example"]
     h5preserve_group = H5PreserveGroup(
         h5py_file_with_group, new_registry_list()
     )
     h5preserve_subgroup = h5preserve_group.require_group("example")
     assert h5preserve_subgroup.h5py_group == group
Exemplo n.º 4
0
 def test_h5py_external_link(self, h5py_file_with_group):
     external = ExternalLink("external.hdf5", "example")
     registries = new_registry_list()
     registries.to_file(h5py_file_with_group, "alias", external)
     assert h5py_file_with_group.get("alias",
                                     getlink=True).path == "example"
     assert h5py_file_with_group.get(
         "alias", getlink=True).filename == "external.hdf5"
Exemplo n.º 5
0
 def test_roundtrip(self, h5py_file):
     assert h5py_file == H5PreserveFile(h5py_file,
                                        new_registry_list()).h5py_file
Exemplo n.º 6
0
 def test_create_group(self, h5py_file_with_group):
     group = h5py_file_with_group["example"]
     h5preserve_group = H5PreserveGroup(group, new_registry_list())
     h5preserve_subgroup = h5preserve_group.create_group("subexample")
     assert h5preserve_subgroup.h5py_group == group["subexample"]
Exemplo n.º 7
0
 def test_roundtrip(self, h5py_file_with_group):
     group = h5py_file_with_group["example"]
     assert group == H5PreserveGroup(
         group, new_registry_list()
     ).h5py_group
Exemplo n.º 8
0
 def test_h5py_external_link(self, h5py_file_with_group):
     external = ExternalLink("external.hdf5", "example")
     registries = new_registry_list()
     registries.to_file(h5py_file_with_group, "alias", external)
     assert h5py_file_with_group.get("alias", getlink=True).path == "example"
     assert h5py_file_with_group.get("alias", getlink=True).filename == "external.hdf5"
Exemplo n.º 9
0
 def test_h5py_soft_link(self, h5py_file_with_group):
     soft_link = SoftLink("example")
     registries = new_registry_list()
     registries.to_file(h5py_file_with_group, "alias", soft_link)
     assert h5py_file_with_group.get("alias", getlink=True).path == "example"
Exemplo n.º 10
0
 def obj_registry_with_none_with_defaults(request):
     return {
         "registries": new_registry_list(request.param[0]),
         "dumpable_object": request.param[1]
     }
Exemplo n.º 11
0
 def obj_registry_with_none_with_defaults(request):
     return {
         "registries": new_registry_list(request.param[0]),
         "dumpable_object": request.param[1]
     }
Exemplo n.º 12
0
 def test_roundtrip(self, h5py_file):
     assert h5py_file == H5PreserveFile(
         h5py_file, new_registry_list()
     ).h5py_file
Exemplo n.º 13
0
"""
Defines common data structures and how they are to be written to files
"""

from h5preserve import new_registry_list

from . import _dumpers  # noqa
from . import _loaders  # noqa
from ._containers import (  # noqa
    Solution, SolutionInput, ConfigInput, Run, InitialConditions,
)
from ._old_dict_loading import (dict_as_group_registry as
                                _dict_as_group_registry)
from ._utils import ds_registry as _ds_registry, get_fields

registries = new_registry_list(_ds_registry, _dict_as_group_registry)

CONFIG_FIELDS = get_fields(ConfigInput)
Exemplo n.º 14
0
 def test_h5py_soft_link(self, h5py_file_with_group):
     soft_link = SoftLink("example")
     registries = new_registry_list()
     registries.to_file(h5py_file_with_group, "alias", soft_link)
     assert h5py_file_with_group.get("alias",
                                     getlink=True).path == "example"