h5rdmtoolbox 2.7.3__tar.gz → 2.7.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/PKG-INFO +3 -3
  2. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/__init__.py +46 -13
  3. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/catalog/core.py +187 -105
  4. h5rdmtoolbox-2.7.4/h5rdmtoolbox/convention/__init__.py +58 -0
  5. h5rdmtoolbox-2.7.4/h5rdmtoolbox/convention/cfg.py +7 -0
  6. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/convention/core.py +313 -157
  7. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/convention/standard_attributes.py +134 -80
  8. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/database/mongo.py +168 -104
  9. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/extensions/magnitude.py +2 -1
  10. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/extensions/normalize.py +4 -2
  11. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/extensions/units.py +8 -3
  12. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/gui/fairify.py +168 -95
  13. h5rdmtoolbox-2.7.4/h5rdmtoolbox/ld/__init__.py +282 -0
  14. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/ld/hdf/attributes.py +4 -4
  15. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/ld/hdf/datasets.py +9 -7
  16. h5rdmtoolbox-2.7.4/h5rdmtoolbox/ld/hdf/file.py +63 -0
  17. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/ld/shacl.py +49 -40
  18. h5rdmtoolbox-2.7.4/h5rdmtoolbox/ld/sparql.py +59 -0
  19. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/ld/user/attributes.py +15 -5
  20. h5rdmtoolbox-2.7.4/h5rdmtoolbox/ld/user/file.py +92 -0
  21. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/ld/user/utils.py +8 -5
  22. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/ld/utils.py +19 -0
  23. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/protocols.py +76 -50
  24. h5rdmtoolbox-2.7.4/h5rdmtoolbox/utils/__init__.py +82 -0
  25. h5rdmtoolbox-2.7.4/h5rdmtoolbox/utils/docstring.py +265 -0
  26. h5rdmtoolbox-2.7.4/h5rdmtoolbox/utils/download.py +341 -0
  27. h5rdmtoolbox-2.7.4/h5rdmtoolbox/utils/file_io.py +272 -0
  28. h5rdmtoolbox-2.7.4/h5rdmtoolbox/utils/hdf5.py +315 -0
  29. h5rdmtoolbox-2.7.4/h5rdmtoolbox/utils/string.py +37 -0
  30. h5rdmtoolbox-2.7.4/h5rdmtoolbox/utils.py +78 -0
  31. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/wrapper/core.py +1039 -573
  32. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/wrapper/h5attr.py +162 -114
  33. h5rdmtoolbox-2.7.4/h5rdmtoolbox/wrapper/h5utils.py +35 -0
  34. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/wrapper/h5yaml.py +17 -15
  35. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/wrapper/jsonld.py +45 -24
  36. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/wrapper/xr2hdf.py +5 -5
  37. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox.egg-info/PKG-INFO +3 -3
  38. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox.egg-info/SOURCES.txt +7 -0
  39. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox.egg-info/requires.txt +2 -2
  40. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/pyproject.toml +6 -5
  41. h5rdmtoolbox-2.7.4/tests/test_extensions.py +203 -0
  42. h5rdmtoolbox-2.7.4/tests/test_repr.py +127 -0
  43. h5rdmtoolbox-2.7.3/h5rdmtoolbox/convention/__init__.py +0 -41
  44. h5rdmtoolbox-2.7.3/h5rdmtoolbox/convention/cfg.py +0 -2
  45. h5rdmtoolbox-2.7.3/h5rdmtoolbox/ld/__init__.py +0 -133
  46. h5rdmtoolbox-2.7.3/h5rdmtoolbox/ld/hdf/file.py +0 -54
  47. h5rdmtoolbox-2.7.3/h5rdmtoolbox/ld/user/file.py +0 -65
  48. h5rdmtoolbox-2.7.3/h5rdmtoolbox/utils.py +0 -777
  49. h5rdmtoolbox-2.7.3/h5rdmtoolbox/wrapper/h5utils.py +0 -32
  50. h5rdmtoolbox-2.7.3/tests/test_extensions.py +0 -148
  51. h5rdmtoolbox-2.7.3/tests/test_repr.py +0 -114
  52. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/LICENSE +0 -0
  53. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/README.md +0 -0
  54. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/_cfg.py +0 -0
  55. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/_repr.py +0 -0
  56. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/_version.py +0 -0
  57. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/catalog/__init__.py +0 -0
  58. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/catalog/_initialization.py +0 -0
  59. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/catalog/abstracts.py +0 -0
  60. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/catalog/profiles.py +0 -0
  61. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/catalog/query_templates.py +0 -0
  62. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/catalog/stores/__init__.py +0 -0
  63. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/catalog/stores/hdf5.py +0 -0
  64. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/catalog/utils.py +0 -0
  65. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/cli.py +0 -0
  66. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/consts.py +0 -0
  67. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/convention/consts.py +0 -0
  68. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/convention/errors.py +0 -0
  69. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/convention/generate.py +0 -0
  70. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/convention/ontology/__init__.py +0 -0
  71. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/convention/ontology/h5ontocls.py +0 -0
  72. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/convention/ontology/hdf_datatypes.py +0 -0
  73. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/convention/references.py +0 -0
  74. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/convention/toolbox_validators.py +0 -0
  75. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/convention/utils.py +0 -0
  76. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/data/def_icon.png +0 -0
  77. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/data/fluid-v1.yml +0 -0
  78. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/data/h5tbx.yaml +0 -0
  79. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/data/id_icon.png +0 -0
  80. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/data/iri_icon.png +0 -0
  81. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/data/ld_icon.png +0 -0
  82. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/data/piv-v1.yml +0 -0
  83. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/data/style.css +0 -0
  84. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/data/tutorial_convention.yaml +0 -0
  85. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/data/tutorial_convention_vfuncs.py +0 -0
  86. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/data/tutorial_standard_name_table.yaml +0 -0
  87. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/data/type_icon.png +0 -0
  88. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/database/__init__.py +0 -0
  89. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/database/hdfdb/__init__.py +0 -0
  90. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/database/hdfdb/filedb.py +0 -0
  91. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/database/hdfdb/objdb.py +0 -0
  92. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/database/hdfdb/query.py +0 -0
  93. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/database/hdfdb/utils.py +0 -0
  94. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/database/interface.py +0 -0
  95. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/database/lazy.py +0 -0
  96. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/errors.py +0 -0
  97. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/extensions/__init__.py +0 -0
  98. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/extensions/onto.py +0 -0
  99. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/extensions/vector.py +0 -0
  100. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/gui/__init__.py +0 -0
  101. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/gui/src/__init__.py +0 -0
  102. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/gui/src/main.py +0 -0
  103. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/identifiers.py +0 -0
  104. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/layout/__init__.py +0 -0
  105. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/layout/core.py +0 -0
  106. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/ld/_types.py +0 -0
  107. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/ld/globals.py +0 -0
  108. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/ld/hdf/__init__.py +0 -0
  109. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/ld/hdf/groups.py +0 -0
  110. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/ld/rdf.py +0 -0
  111. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/ld/user/__init__.py +0 -0
  112. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/ld/user/datasets.py +0 -0
  113. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/ld/user/groups.py +0 -0
  114. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/plotting.py +0 -0
  115. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/protected_attributes.py +0 -0
  116. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/repository/__init__.py +0 -0
  117. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/repository/default_metamapper.py +0 -0
  118. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/repository/interface.py +0 -0
  119. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/repository/utils.py +0 -0
  120. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/repository/zenodo/__init__.py +0 -0
  121. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/repository/zenodo/core.py +0 -0
  122. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/repository/zenodo/metadata.py +0 -0
  123. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/repository/zenodo/tokens.py +0 -0
  124. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/repository/zenodo/utils.py +0 -0
  125. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/tutorial.py +0 -0
  126. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/user.py +0 -0
  127. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/wrapper/__init__.py +0 -0
  128. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/wrapper/accessor.py +0 -0
  129. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/wrapper/accessors/__init__.py +0 -0
  130. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/wrapper/accessors/provenance.py +0 -0
  131. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/wrapper/ds_decoder.py +0 -0
  132. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox/wrapper/h5ext.py +0 -0
  133. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox.egg-info/dependency_links.txt +0 -0
  134. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox.egg-info/entry_points.txt +0 -0
  135. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/h5rdmtoolbox.egg-info/top_level.txt +0 -0
  136. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/setup.cfg +0 -0
  137. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/tests/test_cli.py +0 -0
  138. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/tests/test_config.py +0 -0
  139. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/tests/test_identifiers.py +0 -0
  140. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/tests/test_plotting.py +0 -0
  141. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/tests/test_readme.py +0 -0
  142. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/tests/test_user.py +0 -0
  143. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/tests/test_utils.py +0 -0
  144. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/tests/test_version.py +0 -0
  145. {h5rdmtoolbox-2.7.3 → h5rdmtoolbox-2.7.4}/tests/test_xarray_export.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: h5rdmtoolbox
3
- Version: 2.7.3
3
+ Version: 2.7.4
4
4
  Summary: Supporting a FAIR Research Data lifecycle using Python and HDF5.
5
5
  Author-email: Matthias Probst <matth.probst@gmail.com>
6
6
  License-Expression: MIT
@@ -61,7 +61,7 @@ Requires-Dist: pytest>=8.3.3; extra == "test-core"
61
61
  Requires-Dist: pytest-cov>=5.0.0; extra == "test-core"
62
62
  Requires-Dist: pylint; extra == "test-core"
63
63
  Requires-Dist: ssnolib<3.0.0,>=2.2.0.2; extra == "test-core"
64
- Requires-Dist: mongomock==4.1.2; extra == "test-core"
64
+ Requires-Dist: mongomock==4.3.0; extra == "test-core"
65
65
  Requires-Dist: scipy>=1.10.1; extra == "test-core"
66
66
  Requires-Dist: scikit-image>=0.21.0; extra == "test-core"
67
67
  Requires-Dist: scikit-learn; extra == "test-core"
@@ -75,7 +75,7 @@ Requires-Dist: sphinx_design==0.6.1; extra == "docs"
75
75
  Requires-Dist: myst_nb==1.2.0; extra == "docs"
76
76
  Requires-Dist: sphinxcontrib_bibtex==2.6.3; extra == "docs"
77
77
  Provides-Extra: complete
78
- Requires-Dist: h5rdmtoolbox[catalog,csv,database,gui,layout_validation,snt,test]; extra == "complete"
78
+ Requires-Dist: h5rdmtoolbox[gui,test]; extra == "complete"
79
79
  Provides-Extra: complete-with-docs
80
80
  Requires-Dist: h5rdmtoolbox[complete,docs]; extra == "complete-with-docs"
81
81
  Dynamic: license-file
@@ -2,7 +2,6 @@
2
2
 
3
3
  import logging
4
4
  import pathlib
5
- import warnings
6
5
  from logging.handlers import RotatingFileHandler
7
6
  from typing import Optional, Dict
8
7
 
@@ -136,13 +135,24 @@ def get_ld(
136
135
  context: Optional[Dict] = None
137
136
  ) -> rdflib.Graph:
138
137
  """Return the HDF file content as a rdflib.Graph object."""
139
- from h5rdmtoolbox.ld import get_ld
140
- return get_ld(hdf_filename,
141
- structural=structural,
142
- contextual=contextual,
143
- skipND=skipND,
144
- file_uri=file_uri,
145
- context=context)
138
+ from . import ld
139
+ return ld.get_ld(
140
+ hdf_filename,
141
+ structural=structural,
142
+ contextual=contextual,
143
+ skipND=skipND,
144
+ file_uri=file_uri,
145
+ context=context,
146
+ )
147
+
148
+
149
+ def _optimize_ld_context(graph: rdflib.Graph, context: Optional[Dict]) -> Dict:
150
+ from .ld import optimize_context
151
+ return optimize_context(graph, context or {})
152
+
153
+
154
+ def _resolve_serialize_format(fmt: str, kwargs: Dict) -> str:
155
+ return kwargs.pop("format", fmt)
146
156
 
147
157
 
148
158
  def dump_jsonld(
@@ -155,19 +165,16 @@ def dump_jsonld(
155
165
  file_uri: Optional[str] = None
156
166
  ):
157
167
  """Return the file content as a JSON-LD string."""
158
- from .ld import optimize_context
159
- context = context or {}
160
168
  graph = get_ld(hdf_filename,
161
169
  structural=structural,
162
170
  contextual=contextual,
163
171
  file_uri=file_uri,
164
172
  skipND=skipND)
165
- context = optimize_context(graph, context)
166
173
  return graph.serialize(
167
174
  format="json-ld",
168
175
  indent=indent,
169
176
  auto_compact=True,
170
- context=context
177
+ context=_optimize_ld_context(graph, context)
171
178
  )
172
179
 
173
180
 
@@ -286,7 +293,7 @@ def serialize(hdf_filename,
286
293
  rdf_mappings: Dict[str, RDFMappingEntry] = None,
287
294
  **kwargs):
288
295
  """Alternative to json-ld but allows multiple serialization options"""
289
- fmt = kwargs.pop("format", fmt)
296
+ fmt = _resolve_serialize_format(fmt, kwargs)
290
297
  with File(hdf_filename) as h5:
291
298
  return h5.serialize(fmt=fmt,
292
299
  skipND=skipND,
@@ -296,6 +303,32 @@ def serialize(hdf_filename,
296
303
  rdf_mappings=rdf_mappings)
297
304
 
298
305
 
306
+ def sparql(
307
+ hdf_filename: Union[str, pathlib.Path],
308
+ query: str,
309
+ structural: bool = True,
310
+ contextual: bool = True,
311
+ skipND: int = 1,
312
+ file_uri: Optional[Union[str, Dict[str, str]]] = None,
313
+ rdf_mappings: Dict[str, RDFMappingEntry] = None,
314
+ as_dataframe: bool = False,
315
+ **kwargs
316
+ ) -> rdflib.query.Result:
317
+ """Run a SPARQL query on the HDF5 file content. Returns a rdflib.query.Result object."""
318
+ from .ld import sparql
319
+ return sparql(
320
+ source=hdf_filename,
321
+ query=query,
322
+ structural=structural,
323
+ contextual=contextual,
324
+ skipND=skipND,
325
+ file_uri=file_uri,
326
+ rdf_mappings=rdf_mappings,
327
+ as_dataframe=as_dataframe,
328
+ **kwargs
329
+ )
330
+
331
+
299
332
  def build_pyvis_graph(hdf_filename, output_filename="kg-graph.html", notebook=False,
300
333
  structural: bool = True,
301
334
  contextual: bool = True,