imas-python 2.0.0.post1__tar.gz → 2.0.1__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 (231) hide show
  1. imas_python-2.0.1/.github/CODEOWNERS +10 -0
  2. {imas_python-2.0.0.post1 → imas_python-2.0.1}/PKG-INFO +19 -10
  3. {imas_python-2.0.0.post1 → imas_python-2.0.1}/README.md +11 -4
  4. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/changelog.rst +15 -0
  5. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/courses/advanced/dd_versions.rst +4 -4
  6. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/courses/basic/analyze.rst +17 -0
  7. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/courses/basic/explore.rst +2 -2
  8. imas_python-2.0.1/docs/source/courses/basic/imas_snippets/explore_data_entry.py +11 -0
  9. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/imas_architecture.rst +0 -4
  10. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/installing.rst +23 -0
  11. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/multi-dd.rst +18 -15
  12. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/__init__.py +0 -1
  13. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/_version.py +2 -2
  14. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/backends/imas_core/al_context.py +7 -4
  15. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/backends/imas_core/db_entry_al.py +4 -2
  16. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/backends/imas_core/mdsplus_model.py +10 -2
  17. imas_python-2.0.1/imas/dd_zip.py +109 -0
  18. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/exception.py +6 -17
  19. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/ids_convert.py +170 -58
  20. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_ids_convert.py +89 -22
  21. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_lazy_loading.py +1 -1
  22. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas_python.egg-info/PKG-INFO +19 -10
  23. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas_python.egg-info/SOURCES.txt +2 -10
  24. imas_python-2.0.1/imas_python.egg-info/entry_points.txt +2 -0
  25. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas_python.egg-info/requires.txt +6 -4
  26. {imas_python-2.0.0.post1 → imas_python-2.0.1}/pyproject.toml +8 -8
  27. imas_python-2.0.0.post1/ci/build_dd_zip.sh +0 -30
  28. imas_python-2.0.0.post1/ci/build_docs_and_dist.sh +0 -45
  29. imas_python-2.0.0.post1/ci/linting.sh +0 -35
  30. imas_python-2.0.0.post1/ci/run_benchmark.sh +0 -79
  31. imas_python-2.0.0.post1/ci/run_pytest.sh +0 -46
  32. imas_python-2.0.0.post1/imas/assets/IDSDef.zip +0 -0
  33. imas_python-2.0.0.post1/imas/dd_helpers.py +0 -167
  34. imas_python-2.0.0.post1/imas/dd_zip.py +0 -297
  35. imas_python-2.0.0.post1/imas/test/test_dd_helpers.py +0 -53
  36. imas_python-2.0.0.post1/imas_python.egg-info/entry_points.txt +0 -3
  37. imas_python-2.0.0.post1/imas_python.egg-info/not-zip-safe +0 -1
  38. imas_python-2.0.0.post1/setup.py +0 -140
  39. {imas_python-2.0.0.post1 → imas_python-2.0.1}/.git-blame-ignore-revs +0 -0
  40. {imas_python-2.0.0.post1 → imas_python-2.0.1}/.git_archival.txt +0 -0
  41. {imas_python-2.0.0.post1 → imas_python-2.0.1}/.gitattributes +0 -0
  42. {imas_python-2.0.0.post1 → imas_python-2.0.1}/.github/workflows/linting.yml +0 -0
  43. {imas_python-2.0.0.post1 → imas_python-2.0.1}/.github/workflows/publish.yml +0 -0
  44. {imas_python-2.0.0.post1 → imas_python-2.0.1}/.github/workflows/test_with_pytest.yml +0 -0
  45. {imas_python-2.0.0.post1 → imas_python-2.0.1}/.github/workflows/verify_sphinx_doc.yml +0 -0
  46. {imas_python-2.0.0.post1 → imas_python-2.0.1}/.gitignore +0 -0
  47. {imas_python-2.0.0.post1 → imas_python-2.0.1}/.pylintrc +0 -0
  48. {imas_python-2.0.0.post1 → imas_python-2.0.1}/.readthedocs.yml +0 -0
  49. {imas_python-2.0.0.post1 → imas_python-2.0.1}/CODE_OF_CONDUCT.md +0 -0
  50. {imas_python-2.0.0.post1 → imas_python-2.0.1}/CONTRIBUTING.md +0 -0
  51. {imas_python-2.0.0.post1 → imas_python-2.0.1}/LICENSE.txt +0 -0
  52. {imas_python-2.0.0.post1 → imas_python-2.0.1}/MANIFEST.in +0 -0
  53. {imas_python-2.0.0.post1 → imas_python-2.0.1}/asv.conf.json +0 -0
  54. {imas_python-2.0.0.post1 → imas_python-2.0.1}/benchmarks/__init__.py +0 -0
  55. {imas_python-2.0.0.post1 → imas_python-2.0.1}/benchmarks/core_profiles.py +0 -0
  56. {imas_python-2.0.0.post1 → imas_python-2.0.1}/benchmarks/edge_profiles.py +0 -0
  57. {imas_python-2.0.0.post1 → imas_python-2.0.1}/benchmarks/technical.py +0 -0
  58. {imas_python-2.0.0.post1 → imas_python-2.0.1}/benchmarks/utils.py +0 -0
  59. {imas_python-2.0.0.post1 → imas_python-2.0.1}/conftest.py +0 -0
  60. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/.gitignore +0 -0
  61. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/Makefile +0 -0
  62. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/.gitignore +0 -0
  63. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/_static/imas.css +0 -0
  64. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/_static/imas_200x200.png +0 -0
  65. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/_templates/autosummary/accessor.rst +0 -0
  66. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/_templates/autosummary/accessor_attribute.rst +0 -0
  67. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/_templates/autosummary/accessor_callable.rst +0 -0
  68. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/_templates/autosummary/accessor_method.rst +0 -0
  69. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/_templates/autosummary/base.rst +0 -0
  70. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/_templates/custom-class-template.rst +0 -0
  71. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/_templates/custom-module-template.rst +0 -0
  72. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/_templates/layout.html +0 -0
  73. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/api-hidden.rst +0 -0
  74. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/api.rst +0 -0
  75. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/benchmarking.rst +0 -0
  76. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/ci_config.rst +0 -0
  77. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/cli.rst +0 -0
  78. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/code_style.rst +0 -0
  79. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/conf.py +0 -0
  80. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/configuring.rst +0 -0
  81. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/courses/advanced/explore.rst +0 -0
  82. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/courses/advanced/hashing.rst +0 -0
  83. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/courses/advanced/imas_snippets/alternative_coordinates.py +0 -0
  84. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/courses/advanced/imas_snippets/autoconvert_get.py +0 -0
  85. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/courses/advanced/imas_snippets/autoconvert_put.py +0 -0
  86. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/courses/advanced/imas_snippets/calc_with_units.py +0 -0
  87. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/courses/advanced/imas_snippets/coordinates.py +0 -0
  88. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/courses/advanced/imas_snippets/dd_versions.py +0 -0
  89. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/courses/advanced/imas_snippets/explore_data.py +0 -0
  90. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/courses/advanced/imas_snippets/explore_structures.py +0 -0
  91. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/courses/advanced/imas_snippets/hashing.py +0 -0
  92. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/courses/advanced/imas_snippets/ids_convert.py +0 -0
  93. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/courses/advanced/imas_snippets/ids_to_xarray.py +0 -0
  94. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/courses/advanced/imas_snippets/tensorized_ids_to_xarray.py +0 -0
  95. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/courses/advanced/metadata.rst +0 -0
  96. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/courses/advanced/xarray.rst +0 -0
  97. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/courses/advanced_user_training.rst +0 -0
  98. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/courses/basic/core_profiles_ne_timeslice.png +0 -0
  99. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/courses/basic/core_profiles_te.png +0 -0
  100. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/courses/basic/create.rst +0 -0
  101. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/courses/basic/imas_inspect.png +0 -0
  102. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/courses/basic/imas_snippets/create_core_profiles.py +0 -0
  103. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/courses/basic/imas_snippets/explore_public_ec_launchers.py +0 -0
  104. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/courses/basic/imas_snippets/explore_public_pf_active.py +0 -0
  105. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/courses/basic/imas_snippets/explore_training_data.py +0 -0
  106. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/courses/basic/imas_snippets/find_paths.py +0 -0
  107. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/courses/basic/imas_snippets/iterate_core_profiles.py +0 -0
  108. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/courses/basic/imas_snippets/plot_core_profiles_ne_timeslice.py +0 -0
  109. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/courses/basic/imas_snippets/plot_core_profiles_te.py +0 -0
  110. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/courses/basic/imas_snippets/print_idss.py +0 -0
  111. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/courses/basic/imas_snippets/read_core_profiles_ne_timeslice.py +0 -0
  112. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/courses/basic/imas_snippets/read_equilibrium_time_array.py +0 -0
  113. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/courses/basic/imas_snippets/read_whole_equilibrium.py +0 -0
  114. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/courses/basic/imas_snippets/transform_grid.py +0 -0
  115. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/courses/basic/interactive_tab_core_profiles_toplevel.png +0 -0
  116. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/courses/basic/print_tree_ids_properties.png +0 -0
  117. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/courses/basic/setup.rst +0 -0
  118. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/courses/basic/transform.rst +0 -0
  119. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/courses/basic_user_training.rst +0 -0
  120. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/identifiers.rst +0 -0
  121. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/imas_structure.png +0 -0
  122. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/index.rst +0 -0
  123. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/intro.rst +0 -0
  124. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/lazy_loading.rst +0 -0
  125. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/mdsplus.rst +0 -0
  126. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/metadata.rst +0 -0
  127. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/netcdf/conventions.rst +0 -0
  128. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/netcdf.rst +0 -0
  129. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/release_imas.rst +0 -0
  130. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/resampling.rst +0 -0
  131. {imas_python-2.0.0.post1 → imas_python-2.0.1}/docs/source/validation.rst +0 -0
  132. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/__main__.py +0 -0
  133. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/_to_xarray.py +0 -0
  134. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/_util.py +0 -0
  135. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/assets/IDSDef2MDSpreTree.xsl +0 -0
  136. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/assets/IDS_fake_toplevel.xml +0 -0
  137. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/assets/IDS_minimal.xml +0 -0
  138. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/assets/IDS_minimal_2.xml +0 -0
  139. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/assets/IDS_minimal_struct_array.xml +0 -0
  140. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/assets/IDS_minimal_types.xml +0 -0
  141. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/assets/ITER_134173_106_core_profiles.ids +0 -0
  142. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/assets/ITER_134173_106_equilibrium.ids +0 -0
  143. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/assets/README.md +0 -0
  144. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/assets/core_profiles.ids +0 -0
  145. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/assets/equilibrium.ids +0 -0
  146. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/backends/__init__.py +0 -0
  147. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/backends/db_entry_impl.py +0 -0
  148. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/backends/imas_core/__init__.py +0 -0
  149. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/backends/imas_core/db_entry_helpers.py +0 -0
  150. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/backends/imas_core/imas_interface.py +0 -0
  151. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/backends/imas_core/uda_support.py +0 -0
  152. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/backends/netcdf/__init__.py +0 -0
  153. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/backends/netcdf/db_entry_nc.py +0 -0
  154. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/backends/netcdf/ids2nc.py +0 -0
  155. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/backends/netcdf/ids_tensorizer.py +0 -0
  156. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/backends/netcdf/iterators.py +0 -0
  157. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/backends/netcdf/nc2ids.py +0 -0
  158. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/backends/netcdf/nc_metadata.py +0 -0
  159. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/backends/netcdf/nc_validate.py +0 -0
  160. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/command/cli.py +0 -0
  161. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/command/db_analysis.py +0 -0
  162. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/command/helpers.py +0 -0
  163. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/command/timer.py +0 -0
  164. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/db_entry.py +0 -0
  165. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/ids_base.py +0 -0
  166. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/ids_coordinates.py +0 -0
  167. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/ids_data_type.py +0 -0
  168. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/ids_defs.py +0 -0
  169. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/ids_factory.py +0 -0
  170. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/ids_identifiers.py +0 -0
  171. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/ids_metadata.py +0 -0
  172. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/ids_path.py +0 -0
  173. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/ids_primitive.py +0 -0
  174. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/ids_struct_array.py +0 -0
  175. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/ids_structure.py +0 -0
  176. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/ids_toplevel.py +0 -0
  177. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/setup_logging.py +0 -0
  178. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_all_dd_versions.py +0 -0
  179. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_cli.py +0 -0
  180. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_dbentry.py +0 -0
  181. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_dd_zip.py +0 -0
  182. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_deepcopy.py +0 -0
  183. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_exception.py +0 -0
  184. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_get_sample.py +0 -0
  185. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_hash.py +0 -0
  186. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_helpers.py +0 -0
  187. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_identifiers.py +0 -0
  188. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_ids2nc.py +0 -0
  189. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_ids_ascii_data.py +0 -0
  190. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_ids_coordinates.py +0 -0
  191. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_ids_data_type.py +0 -0
  192. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_ids_factory.py +0 -0
  193. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_ids_metadata.py +0 -0
  194. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_ids_mixin.py +0 -0
  195. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_ids_path.py +0 -0
  196. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_ids_primitive.py +0 -0
  197. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_ids_struct_array.py +0 -0
  198. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_ids_structure.py +0 -0
  199. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_ids_toplevel.py +0 -0
  200. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_ids_validate.py +0 -0
  201. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_latest_dd_autofill.py +0 -0
  202. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_latest_dd_manual.py +0 -0
  203. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_latest_dd_resample.py +0 -0
  204. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_list_occurrences.py +0 -0
  205. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_minimal.py +0 -0
  206. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_minimal_conversion.py +0 -0
  207. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_minimal_io.py +0 -0
  208. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_minimal_struct_array_io.py +0 -0
  209. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_minimal_types.py +0 -0
  210. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_minimal_types_io.py +0 -0
  211. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_minimal_types_io_automatic.py +0 -0
  212. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_nbc_change.py +0 -0
  213. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_nc_autofill.py +0 -0
  214. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_nc_entry.py +0 -0
  215. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_nc_metadata.py +0 -0
  216. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_nc_validation.py +0 -0
  217. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_snippets.py +0 -0
  218. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_static_ids.py +0 -0
  219. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_str_1d.py +0 -0
  220. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_time_slicing.py +0 -0
  221. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_to_xarray.py +0 -0
  222. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_uda_support.py +0 -0
  223. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/test/test_util.py +0 -0
  224. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/training.py +0 -0
  225. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas/util.py +0 -0
  226. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas_python.egg-info/dependency_links.txt +0 -0
  227. {imas_python-2.0.0.post1 → imas_python-2.0.1}/imas_python.egg-info/top_level.txt +0 -0
  228. {imas_python-2.0.0.post1 → imas_python-2.0.1}/setup.cfg +0 -0
  229. {imas_python-2.0.0.post1 → imas_python-2.0.1}/tools/compare_lowlevel_access_patterns.py +0 -0
  230. {imas_python-2.0.0.post1 → imas_python-2.0.1}/tools/extract_test_data.py +0 -0
  231. {imas_python-2.0.0.post1 → imas_python-2.0.1}/tools/get_tagnames.py +0 -0
@@ -0,0 +1,10 @@
1
+ # This file allows setting automatically reviewers for pull requests.
2
+ # Each line is a file pattern followed by one or more owners.
3
+ # The last match takes precedence over previous ones.
4
+ # Do not edit unless specifically mandated to do so.
5
+
6
+ # Global/fallback and technical modifications.
7
+ * @maarten-ic @prasad-sawantdesai @olivhoenen
8
+
9
+ # Modifications to CODEOWNERS and action workflows
10
+ .github/ @SimonPinches @olivhoenen
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: imas-python
3
- Version: 2.0.0.post1
3
+ Version: 2.0.1
4
4
  Summary: Pythonic wrappers for the IMAS Access Layer
5
5
  Author: ITER Organization
6
6
  Author-email: Karel Lucas van de Plassche <karelvandeplassche@gmail.com>, Daan van Vugt <dvanvugt@ignitioncomputing.com>, Maarten Sebregts <msebregts@ignitioncomputing.com>, imas-support@iter.org
@@ -205,15 +205,14 @@ Classifier: Topic :: Utilities
205
205
  Requires-Python: >=3.7
206
206
  Description-Content-Type: text/markdown
207
207
  License-File: LICENSE.txt
208
- Requires-Dist: numpy<2,>=1.15.4
208
+ Requires-Dist: numpy>=1.15.4
209
209
  Requires-Dist: rich
210
210
  Requires-Dist: scipy
211
211
  Requires-Dist: click
212
212
  Requires-Dist: importlib_resources; python_version < "3.9"
213
213
  Requires-Dist: packaging
214
214
  Requires-Dist: xxhash>=2
215
- Requires-Dist: saxonche
216
- Requires-Dist: gitpython
215
+ Requires-Dist: imas_data_dictionaries
217
216
  Provides-Extra: all
218
217
  Requires-Dist: imas-python[docs,test]; extra == "all"
219
218
  Provides-Extra: docs
@@ -227,6 +226,8 @@ Provides-Extra: h5py
227
226
  Requires-Dist: h5py; extra == "h5py"
228
227
  Provides-Extra: xarray
229
228
  Requires-Dist: xarray; extra == "xarray"
229
+ Provides-Extra: saxonche
230
+ Requires-Dist: saxonche; extra == "saxonche"
230
231
  Provides-Extra: test
231
232
  Requires-Dist: pytest>=5.4.1; extra == "test"
232
233
  Requires-Dist: pytest-cov>=0.6; extra == "test"
@@ -236,7 +237,8 @@ Requires-Dist: matplotlib; extra == "test"
236
237
  Requires-Dist: asv==0.6.1; extra == "test"
237
238
  Requires-Dist: virtualenv; extra == "test"
238
239
  Requires-Dist: pint; extra == "test"
239
- Requires-Dist: imas-python[h5py,netcdf,xarray]; extra == "test"
240
+ Requires-Dist: imas-python[h5py,netcdf,saxonche,xarray]; extra == "test"
241
+ Dynamic: license-file
240
242
 
241
243
  # IMAS-Python
242
244
 
@@ -248,13 +250,20 @@ Data Model.
248
250
 
249
251
  ## Install
250
252
 
251
- Install steps are described in the documentation generated from `/docs/source/installing.rst`.
253
+ Simply install IMAS-Python with ``pip``:
254
+ ```bash
255
+ pip install imas-python
256
+ ```
257
+ or with optional dependencies for netCDF and xarray support:
258
+ ```bash
259
+ pip install imas-python[netcdf,xarray]
260
+ ```
252
261
 
253
- Documentation is autogenerated from the source using [Sphinx](http://sphinx-doc.org/)
262
+ More details are described in the documentation generated from `/docs/source/installing.rst`.
263
+ The documentation is autogenerated from the source using [Sphinx](http://sphinx-doc.org/)
254
264
  and can be found at the [readthedocs](https://imas-python.readthedocs.io/en/latest/)
255
265
 
256
- The documentation can be manually generated by installing sphinx and running:
257
-
266
+ To generate the documentation yourself, install the ``docs`` optional dependencies and do:
258
267
  ```bash
259
268
  make -C docs html
260
269
  ```
@@ -8,13 +8,20 @@ Data Model.
8
8
 
9
9
  ## Install
10
10
 
11
- Install steps are described in the documentation generated from `/docs/source/installing.rst`.
11
+ Simply install IMAS-Python with ``pip``:
12
+ ```bash
13
+ pip install imas-python
14
+ ```
15
+ or with optional dependencies for netCDF and xarray support:
16
+ ```bash
17
+ pip install imas-python[netcdf,xarray]
18
+ ```
12
19
 
13
- Documentation is autogenerated from the source using [Sphinx](http://sphinx-doc.org/)
20
+ More details are described in the documentation generated from `/docs/source/installing.rst`.
21
+ The documentation is autogenerated from the source using [Sphinx](http://sphinx-doc.org/)
14
22
  and can be found at the [readthedocs](https://imas-python.readthedocs.io/en/latest/)
15
23
 
16
- The documentation can be manually generated by installing sphinx and running:
17
-
24
+ To generate the documentation yourself, install the ``docs`` optional dependencies and do:
18
25
  ```bash
19
26
  make -C docs html
20
27
  ```
@@ -3,6 +3,21 @@
3
3
  Changelog
4
4
  =========
5
5
 
6
+ What's new in IMAS-Python 2.0.1
7
+ -------------------------------
8
+
9
+ Improvements
10
+ ''''''''''''
11
+
12
+ - improve DD3-->DD4 conversion (sign conversion to dodpsi_like)
13
+ - improve conversion of pulse_schedule IDS >= 3.39.0
14
+ - numpy 2 compatibility
15
+ - improve UDA data fetch
16
+ - improve documentation
17
+ - new dependency on `imas-data-dictionaries package <https://pypi.org/project/imas-data-dictionaries/>`__ (remove internal build via saxonche, except for the optional MDSplus models)
18
+ - full compatibility of tests with netCDF<1.7 (no complex numbers)
19
+
20
+
6
21
  What's new in IMAS-Python 2.0.0
7
22
  -------------------------------
8
23
 
@@ -60,7 +60,7 @@ Bundled Data Dictionary definitions
60
60
 
61
61
  IMAS-Python comes bundled [#DDdefs]_ with many versions of the Data Dictionary definitions.
62
62
  You can find out which versions are available by calling
63
- :py:meth:`imas.dd_zip.dd_xml_versions`.
63
+ ``imas.dd_zip.dd_xml_versions``.
64
64
 
65
65
 
66
66
  Converting an IDS between Data Dictionary versions
@@ -290,6 +290,6 @@ build, you can use them like you normally would.
290
290
 
291
291
  .. rubric:: Footnotes
292
292
 
293
- .. [#DDdefs] To be more precise, the Data Dictionary definitions are generated when the
294
- IMAS-Python package is created. See :ref:`this reference <DD background>` for more
295
- details.
293
+ .. [#DDdefs] To be more precise, the Data Dictionary definitions are provided by the
294
+ `IMAS Data Dictionaries <http://pypi.org/project/imas-data-dictionaries/>`__
295
+ package.
@@ -246,3 +246,20 @@ Exercise 5
246
246
  A plot of :math:`T_e` vs :math:`t`.
247
247
 
248
248
  .. seealso:: :ref:`Lazy loading`
249
+
250
+
251
+ Explore the DBEntry and occurrences
252
+ '''''''''''''''''''''''''''''''''''
253
+
254
+ You may not know a priori which types of IDSs are available within an IMAS database entry.
255
+ It can also happen that several IDSs objects of the same type are stored within
256
+ this entry, in that case each IDS is stored as a separate `occurrence`
257
+ (occurrences are identified with an integer value, 0 being the default).
258
+
259
+ In IMAS-Python, the function :meth:`~imas.db_entry.DBEntry.list_all_occurrences()` will
260
+ help you finding which occurrences are available in a given database entry and for a given
261
+ IDS type.
262
+
263
+ The following snippet shows how to list the available IDSs in a given database entry:
264
+
265
+ .. literalinclude:: imas_snippets/explore_data_entry.py
@@ -7,8 +7,8 @@ In this part of the training, we will learn how to use Python to explore data
7
7
  saved in IDSs.
8
8
 
9
9
 
10
- Explore which IDSs are available
11
- --------------------------------
10
+ Explore which IDS structures are available
11
+ ------------------------------------------
12
12
 
13
13
  Most codes will touch multiple IDSs inside a single IMAS data entry. For example
14
14
  a heating code using a magnetic equilibrium from the ``equilibrium`` IDS with a
@@ -0,0 +1,11 @@
1
+ import imas
2
+
3
+ # Open input data entry
4
+ entry = imas.DBEntry("imas:hdf5?path=<...>", "r")
5
+
6
+ # Print the list of available IDSs with their occurrence
7
+ for idsname in imas.IDSFactory().ids_names():
8
+ for occ in entry.list_all_occurrences(idsname):
9
+ print(idsname, occ)
10
+
11
+ entry.close()
@@ -72,11 +72,7 @@ Data Dictionary building and loading
72
72
  The following submodules are responsible for building the Data Dictionary and loading DD
73
73
  definitions at runtime.
74
74
 
75
- - :py:mod:`imas.dd_helpers` handles building the ``IDSDef.zip`` file, containing all
76
- versions of the Data Dictionary since ``3.22.0``.
77
-
78
75
  - :py:mod:`imas.dd_zip` handles loading the Data Dictionary definitions at run time.
79
- These definitions can be loaded from an ``IDSDef.zip`` or from a custom XML file.
80
76
 
81
77
 
82
78
  .. _imas_architecture/IDS_nodes:
@@ -13,6 +13,29 @@ To get started, you can install it from `pypi.org <https://pypi.org/project/imas
13
13
 
14
14
  pip install imas-python
15
15
 
16
+ You can also install optional dependencies (e.g. netCDF and xarray):
17
+
18
+ .. code-block:: bash
19
+
20
+ pip install imas-python[netcdf,xarray]
21
+
22
+
23
+ List of optional dependencies
24
+ -----------------------------
25
+
26
+ - ``netcdf``: enables storing/loading of IDS to/from netCDF files
27
+ - ``xarray``: enables loading IDS (entire IDS or part of it) into an xarray ``dataset``
28
+ - ``h5py``: enables ``analyze-db`` CLI option
29
+ - ``docs``: installs required packages to build the Sphinx documentation
30
+ - ``test``: installs required packages to run the tests with ``pytest`` and ``asv``
31
+ - ``saxonche``: installs saxonche to enable creation of MDSplus models for the selected versions of the IMAS Data Dictionary (only relevant when working with ``imas_core``)
32
+
33
+ .. note::
34
+
35
+ Some tests will be skipped unless you also have ``imas_core`` installed
36
+ (it is not yet available on PyPI, so you will need to install it from sources
37
+ if you have access to them at https://git.iter.org/projects/IMAS/repos/al-core)
38
+
16
39
 
17
40
  Local installation from sources
18
41
  -------------------------------
@@ -146,6 +146,7 @@ explicit conversion mechanisms.
146
146
  Changed definition of open/closed contours, Yes, No
147
147
  Changed definition of ``space/coordinates_type`` in GGD grids, Yes, No
148
148
  Migrate obsolescent ``ids_properties/source`` to ``ids_properties/provenance``, Yes, No
149
+ Convert the multiple time-bases in the ``pulse_schedule`` IDS [#ps3to4]_, Yes, No
149
150
 
150
151
  .. [#rename] Quantities which have been renamed between the two DD versions. For
151
152
  example, the ``ec/beam`` Array of Structures in the ``pulse_schedule`` IDS,
@@ -175,6 +176,15 @@ explicit conversion mechanisms.
175
176
  .. [#ignore_type_change] These type changes are not supported. Quantities in the
176
177
  destination IDS will remain empty.
177
178
 
179
+ .. [#ps3to4] In Data Dictionary 3.39.0 and older, all dynamic quantities in the
180
+ ``pulse_schedule`` IDS had their own time array. In DD 4.0.0 this was
181
+ restructured to one time array per component (for example `ec/time
182
+ <https://imas-data-dictionary.readthedocs.io/en/latest/generated/ids/pulse_schedule.html#pulse_schedule-ec-time>`__).
183
+ This migration constructs a common time base per subgroup, and interpolates
184
+ the dynamic quantities within the group to the new time base. Resampling
185
+ uses `previous neighbour` interpolation for integer quantities, and linear
186
+ interpolation otherwise. See also:
187
+ https://github.com/iterorganization/IMAS-Python/issues/21.
178
188
 
179
189
  .. _`DD background`:
180
190
 
@@ -197,21 +207,14 @@ Automated tests have been provided that check the loading of all of the DD
197
207
  versions tagged in the data-dictionary git repository.
198
208
 
199
209
 
200
- Extending the DD set
201
- ''''''''''''''''''''
210
+ Data Dictionary definitions
211
+ '''''''''''''''''''''''''''
202
212
 
203
- Use the command ``python setup.py build_DD`` to build a new ``IDSDef.zip``. This
204
- fetches all tags from the data dictionary git repository and builds the ``IDSDef.zip``.
213
+ The Data Dictionary definitions used by IMAS-Python are provided by the `IMAS Data
214
+ Dictionaries <http://pypi.org/project/imas-data-dictionaries/>`__ package.
215
+ Please update this package if you need a more recent version of the data dictionary. For
216
+ example, using ``pip``:
205
217
 
206
- IMAS-Python searches for an ``IDSDef.zip`` in the following locations:
218
+ .. code-block:: bash
207
219
 
208
- 1. The environment variable ``$IMAS_DDZIP`` (path to a zip file)
209
- 2. The file ``./IDSDef.zip`` in the current working directory
210
- 3. In the local configuration folder: ``~/.config/imas/IDSDef.zip``, or
211
- ``$XDG_CONFIG_DIR/imas/IDSDef.zip`` (if the environment variable
212
- ``$XDG_CONFIG_DIR`` is set)
213
- 4. The zipfile bundled with the IMAS-Python installation: ``assets/IDSDef.zip``
214
-
215
- All paths are searched in order when loading the definitions of a specific data
216
- dictionary version: the first zip file that contains the definitions of the requested
217
- version is used.
220
+ pip install --upgrade imas-data-dictionaries
@@ -20,7 +20,6 @@ from .ids_identifiers import identifiers
20
20
  # Load the IMAS-Python IMAS AL/DD core
21
21
  from . import (
22
22
  db_entry,
23
- dd_helpers,
24
23
  dd_zip,
25
24
  util,
26
25
  )
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '2.0.0.post1'
21
- __version_tuple__ = version_tuple = (2, 0, 0, 'post1')
20
+ __version__ = version = '2.0.1'
21
+ __version_tuple__ = version_tuple = (2, 0, 1)
@@ -1,7 +1,6 @@
1
1
  # This file is part of IMAS-Python.
2
2
  # You should have received the IMAS-Python LICENSE file with this project.
3
- """Object-oriented interface to the IMAS lowlevel.
4
- """
3
+ """Object-oriented interface to the IMAS lowlevel."""
5
4
 
6
5
  import logging
7
6
  import weakref
@@ -61,17 +60,21 @@ class ALContext:
61
60
  def __exit__(self, exc_type, exc_value, traceback) -> None:
62
61
  ll_interface.end_action(self.ctx)
63
62
 
64
- def global_action(self, path: str, rwmode: int) -> "ALContext":
63
+ def global_action(self, path: str, rwmode: int, datapath: str = "") -> "ALContext":
65
64
  """Begin a new global action for use in a ``with`` context.
66
65
 
67
66
  Args:
68
67
  path: access layer path for this global action: ``<idsname>[/<occurrence>]``
69
68
  rwmode: read-only or read-write operation mode: ``READ_OP``/``WRITE_OP``
69
+ datapath: used by UDA backend to fetch only part of the data.
70
70
 
71
71
  Returns:
72
72
  The created context.
73
73
  """
74
- status, ctx = ll_interface.begin_global_action(self.ctx, path, rwmode)
74
+ args = [self.ctx, path, rwmode]
75
+ if datapath: # AL4 compatibility: datapath arg was added in AL5
76
+ args.append(datapath)
77
+ status, ctx = ll_interface.begin_global_action(*args)
75
78
  if status != 0:
76
79
  raise LowlevelError("global_action", status)
77
80
  return ALContext(ctx)
@@ -257,7 +257,8 @@ class ALDBEntryImpl(DBEntryImpl):
257
257
  if occurrence != 0:
258
258
  ll_path += f"/{occurrence}"
259
259
 
260
- with self._db_ctx.global_action(ll_path, READ_OP) as read_ctx:
260
+ datapath = "ids_properties" if self.backend == "uda" else ""
261
+ with self._db_ctx.global_action(ll_path, READ_OP, datapath) as read_ctx:
261
262
  time_mode_path = "ids_properties/homogeneous_time"
262
263
  time_mode = read_ctx.read_data(time_mode_path, "", INTEGER_DATA, 0)
263
264
  # This is already checked by read_dd_version, but ensure:
@@ -314,7 +315,8 @@ class ALDBEntryImpl(DBEntryImpl):
314
315
  if occurrence != 0:
315
316
  ll_path += f"/{occurrence}"
316
317
 
317
- with self._db_ctx.global_action(ll_path, READ_OP) as read_ctx:
318
+ datapath = "ids_properties" if self.backend == "uda" else ""
319
+ with self._db_ctx.global_action(ll_path, READ_OP, datapath) as read_ctx:
318
320
  time_mode_path = "ids_properties/homogeneous_time"
319
321
  time_mode = read_ctx.read_data(time_mode_path, "", INTEGER_DATA, 0)
320
322
  dd_version_path = "ids_properties/version_put/data_dictionary"
@@ -12,7 +12,6 @@ import tempfile
12
12
  import time
13
13
  import uuid
14
14
  from pathlib import Path
15
- from saxonche import PySaxonProcessor
16
15
  from subprocess import CalledProcessError, check_output
17
16
  from zlib import crc32
18
17
 
@@ -244,11 +243,20 @@ def transform_with_xslt(xslt_processor, source, xslfile, output_file):
244
243
 
245
244
  def create_model_ids_xml(cache_dir_path, fname, version):
246
245
  """Use Saxon/C to compile an ids.xml suitable for creating an MDSplus model."""
246
+ try:
247
+ import saxonche
248
+ except ImportError:
249
+ raise RuntimeError(
250
+ "Building mdsplus models requires the 'saxonche' python package. "
251
+ "Please install this package (for example with 'pip install saxonche') "
252
+ "and try again."
253
+ )
254
+
247
255
  try:
248
256
  with as_file(files("imas") / "assets" / "IDSDef2MDSpreTree.xsl") as xslfile:
249
257
  output_file = Path(cache_dir_path) / "ids.xml"
250
258
 
251
- with PySaxonProcessor(license=False) as proc:
259
+ with saxonche.PySaxonProcessor(license=False) as proc:
252
260
  xslt_processor = proc.new_xslt30_processor()
253
261
  xdm_ddgit = proc.make_string_value(str(version) or fname)
254
262
  xslt_processor.set_parameter("DD_GIT_DESCRIBE", xdm_ddgit)
@@ -0,0 +1,109 @@
1
+ # This file is part of IMAS-Python.
2
+ # You should have received the IMAS-Python LICENSE file with this project.
3
+ """Extract DD versions from the imas-data-dictionaries distribution."""
4
+
5
+ import logging
6
+ import os
7
+ import xml.etree.ElementTree as ET
8
+ from functools import lru_cache
9
+ from pathlib import Path
10
+
11
+ # These methods in imas_data_dictionaries used to be defined here. We import them here
12
+ # for backwards compatibility:
13
+ from imas_data_dictionaries import dd_identifiers # noqa: F401
14
+ from imas_data_dictionaries import get_dd_xml_crc # noqa: F401
15
+ from imas_data_dictionaries import get_identifier_xml # noqa: F401
16
+ from imas_data_dictionaries import dd_xml_versions, get_dd_xml, parse_dd_version
17
+ from packaging.version import InvalidVersion
18
+
19
+ import imas
20
+ from imas.exception import UnknownDDVersion # noqa: F401
21
+
22
+ logger = logging.getLogger(__name__)
23
+
24
+
25
+ # Expected use case is one, maximum two DD versions
26
+ # Cache is bigger than that: in pytest we currently use the following DD versions:
27
+ # - 3.22.0
28
+ # - 3.25.0
29
+ # - 3.28.0
30
+ # - 3.39.0
31
+ # - 4.0.0 (if available)
32
+ # - Environment default
33
+ # - IDS_fake_toplevel.xml
34
+ # - IDS_minimal.xml
35
+ # - IDS_minimal_2.xml
36
+ # - IDS_minimal_struct_array.xml
37
+ # - IDS_minimal_types.xml
38
+ _DD_CACHE_SIZE = 8
39
+
40
+
41
+ def dd_etree(version=None, xml_path=None):
42
+ """Return the DD element tree corresponding to the provided dd_version or xml_file.
43
+
44
+ By default (``dd_version`` and ``dd_xml`` are not supplied), this will attempt
45
+ to get the version from the environment (``IMAS_VERSION``) and use the latest
46
+ available version as fallback.
47
+
48
+ You can also specify a specific DD version to use (e.g. "3.38.1") or point to a
49
+ specific data-dictionary XML file. These options are exclusive.
50
+
51
+ Args:
52
+ version: DD version string, e.g. "3.38.1".
53
+ xml_path: XML file containing data dictionary definition.
54
+ """
55
+ if version and xml_path:
56
+ raise ValueError("version and xml_path cannot be provided both.")
57
+ if not version and not xml_path:
58
+ # Figure out which DD version to use
59
+ if "IMAS_VERSION" in os.environ:
60
+ imas_version = os.environ["IMAS_VERSION"]
61
+ if imas_version in dd_xml_versions():
62
+ # Use bundled DD version when available
63
+ version = imas_version
64
+ elif "IMAS_PREFIX" in os.environ:
65
+ # Try finding the IDSDef.xml in this installation
66
+ imas_prefix = Path(os.environ["IMAS_PREFIX"]).resolve()
67
+ xml_file = imas_prefix / "include" / "IDSDef.xml"
68
+ if xml_file.exists():
69
+ xml_path = str(xml_file)
70
+ if not version and not xml_path:
71
+ logger.warning(
72
+ "Unable to load IMAS version %s, falling back to latest version.",
73
+ imas_version,
74
+ )
75
+ if not version and not xml_path:
76
+ # Use latest available from
77
+ version = latest_dd_version()
78
+ # Do the actual loading in a cached method:
79
+ return _load_etree(version, xml_path)
80
+
81
+
82
+ @lru_cache(_DD_CACHE_SIZE)
83
+ def _load_etree(version, xml_path):
84
+ if xml_path:
85
+ logger.info("Parsing data dictionary from file: %s", xml_path)
86
+ tree = ET.parse(xml_path)
87
+ else:
88
+ xml = get_dd_xml(version)
89
+ logger.info("Parsing data dictionary version %s", version)
90
+ tree = ET.ElementTree(ET.fromstring(xml))
91
+ return tree
92
+
93
+
94
+ def print_supported_version_warning(version):
95
+ try:
96
+ if parse_dd_version(version) < imas.OLDEST_SUPPORTED_VERSION:
97
+ logger.warning(
98
+ "Version %s is below lowest supported version of %s.\
99
+ Proceed at your own risk.",
100
+ version,
101
+ imas.OLDEST_SUPPORTED_VERSION,
102
+ )
103
+ except InvalidVersion:
104
+ logging.warning("Ignoring version parsing error.", exc_info=1)
105
+
106
+
107
+ def latest_dd_version():
108
+ """Find the latest version in data-dictionary/IDSDef.zip"""
109
+ return dd_xml_versions()[-1]
@@ -1,11 +1,14 @@
1
1
  # This file is part of IMAS-Python.
2
2
  # You should have received the IMAS-Python LICENSE file with this project.
3
- """Exception classes used in IMAS-Python.
4
- """
3
+ """Exception classes used in IMAS-Python."""
5
4
 
6
5
  import difflib
7
6
  import logging
8
- from typing import TYPE_CHECKING, List
7
+ from typing import TYPE_CHECKING
8
+
9
+ # This exception from imas_data_dictionaries used to be defined here. We import it here
10
+ # for backwards compatibility:
11
+ from imas_data_dictionaries import UnknownDDVersion # noqa: F401
9
12
 
10
13
  from imas.backends.imas_core import imas_interface as _imas_interface
11
14
 
@@ -23,20 +26,6 @@ else:
23
26
  ALException = None
24
27
 
25
28
 
26
- class UnknownDDVersion(ValueError):
27
- """Error raised when an unknown DD version is specified."""
28
-
29
- def __init__(self, version: str, available: List[str], note: str = "") -> None:
30
- close_matches = difflib.get_close_matches(version, available, n=1)
31
- if close_matches:
32
- suggestions = f"Did you mean {close_matches[0]!r}?"
33
- else:
34
- suggestions = f"Available versions are {', '.join(reversed(available))}"
35
- super().__init__(
36
- f"Data dictionary version {version!r} cannot be found. {suggestions}{note}"
37
- )
38
-
39
-
40
29
  class IDSNameError(ValueError):
41
30
  """Error raised by DBEntry.get(_slice) when providing an invalid IDS name."""
42
31