readcon-db 0.2.4__tar.gz → 0.2.5__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 (206) hide show
  1. {readcon_db-0.2.4 → readcon_db-0.2.5}/.github/workflows/ci.yml +27 -0
  2. {readcon_db-0.2.4 → readcon_db-0.2.5}/CHANGELOG.md +20 -0
  3. {readcon_db-0.2.4 → readcon_db-0.2.5}/CITATION.cff +2 -2
  4. {readcon_db-0.2.4 → readcon_db-0.2.5}/Cargo.lock +1 -1
  5. {readcon_db-0.2.4 → readcon_db-0.2.5}/Cargo.toml +1 -1
  6. {readcon_db-0.2.4 → readcon_db-0.2.5}/PKG-INFO +4 -3
  7. {readcon_db-0.2.4 → readcon_db-0.2.5}/README.md +1 -1
  8. readcon_db-0.2.5/changelog.d/python-archive-reader.feature.md +1 -0
  9. readcon_db-0.2.5/changelog.d/python-readcon-dependency.feature.md +1 -0
  10. readcon_db-0.2.5/changelog.d/rkrdb-extend-trajectory-str.feature.md +1 -0
  11. readcon_db-0.2.5/changelog.d/v31-clock-units.bugfix.md +1 -0
  12. {readcon_db-0.2.4 → readcon_db-0.2.5}/docs/orgmode/reference/python.org +50 -0
  13. {readcon_db-0.2.4 → readcon_db-0.2.5}/fortran/ReadConDb/fpm.toml +1 -1
  14. {readcon_db-0.2.4 → readcon_db-0.2.5}/include/readcon-db.h +11 -0
  15. {readcon_db-0.2.4 → readcon_db-0.2.5}/pixi.toml +1 -1
  16. {readcon_db-0.2.4 → readcon_db-0.2.5}/pyproject.toml +5 -1
  17. {readcon_db-0.2.4 → readcon_db-0.2.5}/python/pyproject.toml +5 -1
  18. readcon_db-0.2.5/python/tests/test_archive_reader.py +321 -0
  19. readcon_db-0.2.5/python/tests/test_ingest_memory.py +273 -0
  20. {readcon_db-0.2.4 → readcon_db-0.2.5}/src/catalog.rs +38 -24
  21. {readcon_db-0.2.4 → readcon_db-0.2.5}/src/corpus.rs +2 -2
  22. {readcon_db-0.2.4 → readcon_db-0.2.5}/src/ffi.rs +81 -0
  23. {readcon_db-0.2.4 → readcon_db-0.2.5}/src/lib.rs +2 -0
  24. {readcon_db-0.2.4 → readcon_db-0.2.5}/src/python.rs +163 -9
  25. readcon_db-0.2.5/src/python_archive.rs +715 -0
  26. {readcon_db-0.2.4 → readcon_db-0.2.5}/src/units_canon.rs +332 -9
  27. readcon_db-0.2.4/python/tests/test_ingest_memory.py +0 -51
  28. {readcon_db-0.2.4 → readcon_db-0.2.5}/.github/workflows/c_lib_tarball.yml +0 -0
  29. {readcon_db-0.2.4 → readcon_db-0.2.5}/.github/workflows/ci_cxx.yml +0 -0
  30. {readcon_db-0.2.4 → readcon_db-0.2.5}/.github/workflows/ci_docs.yml +0 -0
  31. {readcon_db-0.2.4 → readcon_db-0.2.5}/.github/workflows/ci_mpi.yml +0 -0
  32. {readcon_db-0.2.4 → readcon_db-0.2.5}/.github/workflows/ci_prek.yml +0 -0
  33. {readcon_db-0.2.4 → readcon_db-0.2.5}/.github/workflows/crates_publish.yml +0 -0
  34. {readcon_db-0.2.4 → readcon_db-0.2.5}/.github/workflows/cxx_tarball.yml +0 -0
  35. {readcon_db-0.2.4 → readcon_db-0.2.5}/.github/workflows/lint.yml +0 -0
  36. {readcon_db-0.2.4 → readcon_db-0.2.5}/.github/workflows/pages.yml +0 -0
  37. {readcon_db-0.2.4 → readcon_db-0.2.5}/.github/workflows/python-wheels.yml +0 -0
  38. {readcon_db-0.2.4 → readcon_db-0.2.5}/.gitignore +0 -0
  39. {readcon_db-0.2.4 → readcon_db-0.2.5}/CMakeLists.txt +0 -0
  40. {readcon_db-0.2.4 → readcon_db-0.2.5}/CODE_OF_CONDUCT.md +0 -0
  41. {readcon_db-0.2.4 → readcon_db-0.2.5}/CONTRIBUTING.md +0 -0
  42. {readcon_db-0.2.4 → readcon_db-0.2.5}/LICENSE +0 -0
  43. {readcon_db-0.2.4 → readcon_db-0.2.5}/SECURITY.md +0 -0
  44. {readcon_db-0.2.4 → readcon_db-0.2.5}/assets/logo/BRAND.md +0 -0
  45. {readcon_db-0.2.4 → readcon_db-0.2.5}/assets/logo/readcon-db-logo-512.png +0 -0
  46. {readcon_db-0.2.4 → readcon_db-0.2.5}/assets/logo/readcon-db-logo-raster.jpg +0 -0
  47. {readcon_db-0.2.4 → readcon_db-0.2.5}/assets/logo/readcon-db-logo.svg +0 -0
  48. {readcon_db-0.2.4 → readcon_db-0.2.5}/assets/logo/readcon-db-wordmark.svg +0 -0
  49. {readcon_db-0.2.4 → readcon_db-0.2.5}/bench/gen_con.py +0 -0
  50. {readcon_db-0.2.4 → readcon_db-0.2.5}/bench/mpi_bench.sh +0 -0
  51. {readcon_db-0.2.4 → readcon_db-0.2.5}/bench/vary_con.py +0 -0
  52. {readcon_db-0.2.4 → readcon_db-0.2.5}/cmake/readcon-db-config-version.in.cmake +0 -0
  53. {readcon_db-0.2.4 → readcon_db-0.2.5}/cmake/readcon-db-config.in.cmake +0 -0
  54. {readcon_db-0.2.4 → readcon_db-0.2.5}/cmake/readcon-db.pc.in +0 -0
  55. {readcon_db-0.2.4 → readcon_db-0.2.5}/cmake/tempdir.cmake +0 -0
  56. {readcon_db-0.2.4 → readcon_db-0.2.5}/cog.toml +0 -0
  57. {readcon_db-0.2.4 → readcon_db-0.2.5}/docs/Makefile +0 -0
  58. {readcon_db-0.2.4 → readcon_db-0.2.5}/docs/_static/logo.svg +0 -0
  59. {readcon_db-0.2.4 → readcon_db-0.2.5}/docs/orgmode/changelog.org +0 -0
  60. {readcon_db-0.2.4 → readcon_db-0.2.5}/docs/orgmode/contributing/index.org +0 -0
  61. {readcon_db-0.2.4 → readcon_db-0.2.5}/docs/orgmode/cooked-soa.org +0 -0
  62. {readcon_db-0.2.4 → readcon_db-0.2.5}/docs/orgmode/explanation/architecture.org +0 -0
  63. {readcon_db-0.2.4 → readcon_db-0.2.5}/docs/orgmode/explanation/design.org +0 -0
  64. {readcon_db-0.2.4 → readcon_db-0.2.5}/docs/orgmode/explanation/faq.org +0 -0
  65. {readcon_db-0.2.4 → readcon_db-0.2.5}/docs/orgmode/explanation/overview.org +0 -0
  66. {readcon_db-0.2.4 → readcon_db-0.2.5}/docs/orgmode/howto/atom-order.org +0 -0
  67. {readcon_db-0.2.4 → readcon_db-0.2.5}/docs/orgmode/howto/campaign.org +0 -0
  68. {readcon_db-0.2.4 → readcon_db-0.2.5}/docs/orgmode/howto/howto.org +0 -0
  69. {readcon_db-0.2.4 → readcon_db-0.2.5}/docs/orgmode/howto/install.org +0 -0
  70. {readcon_db-0.2.4 → readcon_db-0.2.5}/docs/orgmode/howto/migration.org +0 -0
  71. {readcon_db-0.2.4 → readcon_db-0.2.5}/docs/orgmode/howto/mpi.org +0 -0
  72. {readcon_db-0.2.4 → readcon_db-0.2.5}/docs/orgmode/howto/streaming.org +0 -0
  73. {readcon_db-0.2.4 → readcon_db-0.2.5}/docs/orgmode/howto/topology.org +0 -0
  74. {readcon_db-0.2.4 → readcon_db-0.2.5}/docs/orgmode/howto/workflows.org +0 -0
  75. {readcon_db-0.2.4 → readcon_db-0.2.5}/docs/orgmode/index.org +0 -0
  76. {readcon_db-0.2.4 → readcon_db-0.2.5}/docs/orgmode/readme.org +0 -0
  77. {readcon_db-0.2.4 → readcon_db-0.2.5}/docs/orgmode/reference/c.org +0 -0
  78. {readcon_db-0.2.4 → readcon_db-0.2.5}/docs/orgmode/reference/citation.org +0 -0
  79. {readcon_db-0.2.4 → readcon_db-0.2.5}/docs/orgmode/reference/fortran.org +0 -0
  80. {readcon_db-0.2.4 → readcon_db-0.2.5}/docs/orgmode/reference/python-api.org +0 -0
  81. {readcon_db-0.2.4 → readcon_db-0.2.5}/docs/orgmode/reference/rust.org +0 -0
  82. {readcon_db-0.2.4 → readcon_db-0.2.5}/docs/orgmode/tutorials/getting-started.org +0 -0
  83. {readcon_db-0.2.4 → readcon_db-0.2.5}/docs/orgmode/tutorials/tutorial-run.log +0 -0
  84. {readcon_db-0.2.4 → readcon_db-0.2.5}/docs/orgmode/tutorials/tutorial-run.sh +0 -0
  85. {readcon_db-0.2.4 → readcon_db-0.2.5}/docs/orgmode/tutorials/tutorial.org +0 -0
  86. {readcon_db-0.2.4 → readcon_db-0.2.5}/docs/requirements.txt +0 -0
  87. {readcon_db-0.2.4 → readcon_db-0.2.5}/docs/source/_static/custom.css +0 -0
  88. {readcon_db-0.2.4 → readcon_db-0.2.5}/docs/source/_static/favicon.svg +0 -0
  89. {readcon_db-0.2.4 → readcon_db-0.2.5}/docs/source/_static/logo-nav-dark.svg +0 -0
  90. {readcon_db-0.2.4 → readcon_db-0.2.5}/docs/source/_static/logo-nav-light.svg +0 -0
  91. {readcon_db-0.2.4 → readcon_db-0.2.5}/docs/source/_static/logo.svg +0 -0
  92. {readcon_db-0.2.4 → readcon_db-0.2.5}/docs/source/_static/mark.svg +0 -0
  93. {readcon_db-0.2.4 → readcon_db-0.2.5}/docs/source/_templates/partials/extra-foot.html +0 -0
  94. {readcon_db-0.2.4 → readcon_db-0.2.5}/docs/source/_templates/partials/extra-head.html +0 -0
  95. {readcon_db-0.2.4 → readcon_db-0.2.5}/docs/source/_templates/partials/site-foot.html +0 -0
  96. {readcon_db-0.2.4 → readcon_db-0.2.5}/docs/source/_templates/partials/webfonts.html +0 -0
  97. {readcon_db-0.2.4 → readcon_db-0.2.5}/docs/source/conf.py +0 -0
  98. {readcon_db-0.2.4 → readcon_db-0.2.5}/examples/bench_corpus_ops.rs +0 -0
  99. {readcon_db-0.2.4 → readcon_db-0.2.5}/examples/bench_vs_ase_prep.py +0 -0
  100. {readcon_db-0.2.4 → readcon_db-0.2.5}/examples/benchmarks/ase_db_bench.json +0 -0
  101. {readcon_db-0.2.4 → readcon_db-0.2.5}/examples/benchmarks/ase_fair_campaign_1.json +0 -0
  102. {readcon_db-0.2.4 → readcon_db-0.2.5}/examples/benchmarks/bench_ase_db.py +0 -0
  103. {readcon_db-0.2.4 → readcon_db-0.2.5}/examples/benchmarks/db_vs_ase_table.md +0 -0
  104. {readcon_db-0.2.4 → readcon_db-0.2.5}/examples/benchmarks/fair_campaign.py +0 -0
  105. {readcon_db-0.2.4 → readcon_db-0.2.5}/examples/benchmarks/fair_db_vs_ase_table.md +0 -0
  106. {readcon_db-0.2.4 → readcon_db-0.2.5}/examples/benchmarks/readcon_db_bench.json +0 -0
  107. {readcon_db-0.2.4 → readcon_db-0.2.5}/examples/benchmarks/results_merged.json +0 -0
  108. {readcon_db-0.2.4 → readcon_db-0.2.5}/examples/benchmarks/test_fair_select_parity.py +0 -0
  109. {readcon_db-0.2.4 → readcon_db-0.2.5}/examples/ingest_select.rs +0 -0
  110. {readcon_db-0.2.4 → readcon_db-0.2.5}/examples/mpi_bcast_frame.c +0 -0
  111. {readcon_db-0.2.4 → readcon_db-0.2.5}/examples/mpi_bcast_frame.f90 +0 -0
  112. {readcon_db-0.2.4 → readcon_db-0.2.5}/examples/mpi_bcast_frame.py +0 -0
  113. {readcon_db-0.2.4 → readcon_db-0.2.5}/examples/mpi_ingest_check.rs +0 -0
  114. {readcon_db-0.2.4 → readcon_db-0.2.5}/examples/mpi_read_check.rs +0 -0
  115. {readcon_db-0.2.4 → readcon_db-0.2.5}/examples/shard_gate.rs +0 -0
  116. {readcon_db-0.2.4 → readcon_db-0.2.5}/examples/workflows/metatrain_from_con.md +0 -0
  117. {readcon_db-0.2.4 → readcon_db-0.2.5}/examples/workflows/options.metatrain.snippet.yaml +0 -0
  118. {readcon_db-0.2.4 → readcon_db-0.2.5}/fortran/README.md +0 -0
  119. {readcon_db-0.2.4 → readcon_db-0.2.5}/fortran/ReadConDb/src/readcon_db.f90 +0 -0
  120. {readcon_db-0.2.4 → readcon_db-0.2.5}/include/readcon-db-mpi.h +0 -0
  121. {readcon_db-0.2.4 → readcon_db-0.2.5}/lychee.toml +0 -0
  122. {readcon_db-0.2.4 → readcon_db-0.2.5}/meson.build +0 -0
  123. {readcon_db-0.2.4 → readcon_db-0.2.5}/meson_options.txt +0 -0
  124. {readcon_db-0.2.4 → readcon_db-0.2.5}/packaging/wrapdb/README.md +0 -0
  125. {readcon_db-0.2.4 → readcon_db-0.2.5}/packaging/wrapdb/readcon-db.wrap.in +0 -0
  126. {readcon_db-0.2.4 → readcon_db-0.2.5}/paper/cpc/freeze/ase_fair_campaign_1.json +0 -0
  127. {readcon_db-0.2.4 → readcon_db-0.2.5}/paper/cpc/freeze/fair_db_vs_ase_table.md +0 -0
  128. {readcon_db-0.2.4 → readcon_db-0.2.5}/paper/cpc/readme.org +0 -0
  129. {readcon_db-0.2.4 → readcon_db-0.2.5}/paper/cpc/scripts/gen_fair_table.py +0 -0
  130. {readcon_db-0.2.4 → readcon_db-0.2.5}/paper/cpc/src/appendix-fair-campaign.org +0 -0
  131. {readcon_db-0.2.4 → readcon_db-0.2.5}/paper/cpc/src/figures/generated/fair_campaign_table.tex +0 -0
  132. {readcon_db-0.2.4 → readcon_db-0.2.5}/pixi.lock +0 -0
  133. {readcon_db-0.2.4 → readcon_db-0.2.5}/pr-text.md +0 -0
  134. {readcon_db-0.2.4 → readcon_db-0.2.5}/prek.toml +0 -0
  135. {readcon_db-0.2.4 → readcon_db-0.2.5}/python/tests/test_atom_order.py +0 -0
  136. {readcon_db-0.2.4 → readcon_db-0.2.5}/python/tests/test_catalog_claims.py +0 -0
  137. {readcon_db-0.2.4 → readcon_db-0.2.5}/python/tests/test_export_h5md.py +0 -0
  138. {readcon_db-0.2.4 → readcon_db-0.2.5}/python/tests/test_extend_precision.py +0 -0
  139. {readcon_db-0.2.4 → readcon_db-0.2.5}/python/tests/test_hash_con_text.py +0 -0
  140. {readcon_db-0.2.4 → readcon_db-0.2.5}/python/tests/test_stream_and_random.py +0 -0
  141. {readcon_db-0.2.4 → readcon_db-0.2.5}/python/tests/test_streaming_guide.py +0 -0
  142. {readcon_db-0.2.4 → readcon_db-0.2.5}/resources/test/con_v4/README.md +0 -0
  143. {readcon_db-0.2.4 → readcon_db-0.2.5}/resources/test/con_v4/tiny_cuh2_v4.con +0 -0
  144. {readcon_db-0.2.4 → readcon_db-0.2.5}/resources/test/con_v4/tiny_cuh2_v4.convel +0 -0
  145. {readcon_db-0.2.4 → readcon_db-0.2.5}/resources/test/eon36_lj_dimer.convel +0 -0
  146. {readcon_db-0.2.4 → readcon_db-0.2.5}/resources/test/highprec_a.con +0 -0
  147. {readcon_db-0.2.4 → readcon_db-0.2.5}/resources/test/highprec_b.con +0 -0
  148. {readcon_db-0.2.4 → readcon_db-0.2.5}/resources/test/sulfolene.con +0 -0
  149. {readcon_db-0.2.4 → readcon_db-0.2.5}/resources/test/tiny_cuh2.con +0 -0
  150. {readcon_db-0.2.4 → readcon_db-0.2.5}/resources/test/tiny_cuh2.convel +0 -0
  151. {readcon_db-0.2.4 → readcon_db-0.2.5}/resources/test/tiny_cuh2_forces.con +0 -0
  152. {readcon_db-0.2.4 → readcon_db-0.2.5}/resources/test/tiny_cuh2_vel_forces.con +0 -0
  153. {readcon_db-0.2.4 → readcon_db-0.2.5}/resources/test/tiny_multi_cuh2.con +0 -0
  154. {readcon_db-0.2.4 → readcon_db-0.2.5}/scripts/assemble-site.sh +0 -0
  155. {readcon_db-0.2.4 → readcon_db-0.2.5}/scripts/build-docs.sh +0 -0
  156. {readcon_db-0.2.4 → readcon_db-0.2.5}/scripts/check-clib-dist.sh +0 -0
  157. {readcon_db-0.2.4 → readcon_db-0.2.5}/scripts/check-cpc-freeze.sh +0 -0
  158. {readcon_db-0.2.4 → readcon_db-0.2.5}/scripts/check-cxx-dist.sh +0 -0
  159. {readcon_db-0.2.4 → readcon_db-0.2.5}/scripts/check_version_lockstep.py +0 -0
  160. {readcon_db-0.2.4 → readcon_db-0.2.5}/scripts/crate_version.py +0 -0
  161. {readcon_db-0.2.4 → readcon_db-0.2.5}/scripts/export-landing.sh +0 -0
  162. {readcon_db-0.2.4 → readcon_db-0.2.5}/scripts/meson_cargo_build.py +0 -0
  163. {readcon_db-0.2.4 → readcon_db-0.2.5}/scripts/package-clib.sh +0 -0
  164. {readcon_db-0.2.4 → readcon_db-0.2.5}/scripts/package-cxx.sh +0 -0
  165. {readcon_db-0.2.4 → readcon_db-0.2.5}/scripts/release-prep.sh +0 -0
  166. {readcon_db-0.2.4 → readcon_db-0.2.5}/scripts/set-version.sh +0 -0
  167. {readcon_db-0.2.4 → readcon_db-0.2.5}/scripts/sync-version.py +0 -0
  168. {readcon_db-0.2.4 → readcon_db-0.2.5}/scripts/test_check_version_lockstep.py +0 -0
  169. {readcon_db-0.2.4 → readcon_db-0.2.5}/src/archive.rs +0 -0
  170. {readcon_db-0.2.4 → readcon_db-0.2.5}/src/bin/readcon-db.rs +0 -0
  171. {readcon_db-0.2.4 → readcon_db-0.2.5}/src/canonical.rs +0 -0
  172. {readcon_db-0.2.4 → readcon_db-0.2.5}/src/cooked_soa.rs +0 -0
  173. {readcon_db-0.2.4 → readcon_db-0.2.5}/src/error.rs +0 -0
  174. {readcon_db-0.2.4 → readcon_db-0.2.5}/src/export_h5md.rs +0 -0
  175. {readcon_db-0.2.4 → readcon_db-0.2.5}/src/export_xyz.rs +0 -0
  176. {readcon_db-0.2.4 → readcon_db-0.2.5}/src/frame_codec.rs +0 -0
  177. {readcon_db-0.2.4 → readcon_db-0.2.5}/src/frame_scalars.rs +0 -0
  178. {readcon_db-0.2.4 → readcon_db-0.2.5}/src/keys.rs +0 -0
  179. {readcon_db-0.2.4 → readcon_db-0.2.5}/src/mpi_ingest.rs +0 -0
  180. {readcon_db-0.2.4 → readcon_db-0.2.5}/src/mpi_read.rs +0 -0
  181. {readcon_db-0.2.4 → readcon_db-0.2.5}/src/mpi_wire.rs +0 -0
  182. {readcon_db-0.2.4 → readcon_db-0.2.5}/src/select.rs +0 -0
  183. {readcon_db-0.2.4 → readcon_db-0.2.5}/src/shard.rs +0 -0
  184. {readcon_db-0.2.4 → readcon_db-0.2.5}/src/topology.rs +0 -0
  185. {readcon_db-0.2.4 → readcon_db-0.2.5}/tests/atom_order.rs +0 -0
  186. {readcon_db-0.2.4 → readcon_db-0.2.5}/tests/canonical_dump.rs +0 -0
  187. {readcon_db-0.2.4 → readcon_db-0.2.5}/tests/capi_symbols.rs +0 -0
  188. {readcon_db-0.2.4 → readcon_db-0.2.5}/tests/catalog_claims.rs +0 -0
  189. {readcon_db-0.2.4 → readcon_db-0.2.5}/tests/cdylib_static_tls.rs +0 -0
  190. {readcon_db-0.2.4 → readcon_db-0.2.5}/tests/claims_shard.rs +0 -0
  191. {readcon_db-0.2.4 → readcon_db-0.2.5}/tests/cli_refuse.rs +0 -0
  192. {readcon_db-0.2.4 → readcon_db-0.2.5}/tests/cmake-project/CMakeLists.txt +0 -0
  193. {readcon_db-0.2.4 → readcon_db-0.2.5}/tests/cmake-project/main.c +0 -0
  194. {readcon_db-0.2.4 → readcon_db-0.2.5}/tests/con_v4_fixtures.rs +0 -0
  195. {readcon_db-0.2.4 → readcon_db-0.2.5}/tests/cooked_soa_authority.rs +0 -0
  196. {readcon_db-0.2.4 → readcon_db-0.2.5}/tests/hash_file.rs +0 -0
  197. {readcon_db-0.2.4 → readcon_db-0.2.5}/tests/meson-wrap/main.c +0 -0
  198. {readcon_db-0.2.4 → readcon_db-0.2.5}/tests/meson-wrap/meson.build +0 -0
  199. {readcon_db-0.2.4 → readcon_db-0.2.5}/tests/mpi-c/ingest_smoke.c +0 -0
  200. {readcon_db-0.2.4 → readcon_db-0.2.5}/tests/topology_cli.rs +0 -0
  201. {readcon_db-0.2.4 → readcon_db-0.2.5}/website/assets/logo.svg +0 -0
  202. {readcon_db-0.2.4 → readcon_db-0.2.5}/website/assets/wordmark.svg +0 -0
  203. {readcon_db-0.2.4 → readcon_db-0.2.5}/website/css/site.css +0 -0
  204. {readcon_db-0.2.4 → readcon_db-0.2.5}/website/export.el +0 -0
  205. {readcon_db-0.2.4 → readcon_db-0.2.5}/website/index.html +0 -0
  206. {readcon_db-0.2.4 → readcon_db-0.2.5}/website/index.org +0 -0
@@ -46,3 +46,30 @@ jobs:
46
46
  run: cargo doc --locked --no-deps
47
47
  - name: Verify registry package
48
48
  run: cargo package --locked
49
+
50
+ pytest:
51
+ name: pytest (ubuntu-latest)
52
+ runs-on: ubuntu-latest
53
+ steps:
54
+ - uses: actions/checkout@v4
55
+ - uses: dtolnay/rust-toolchain@stable
56
+ - name: Cache cargo
57
+ uses: Swatinem/rust-cache@v2
58
+ - uses: actions/setup-python@v5
59
+ with:
60
+ python-version: "3.12"
61
+ - name: Install test dependencies
62
+ run: |
63
+ python -m pip install --upgrade pip
64
+ python -m pip install maturin pytest numpy h5py MDAnalysis ase "readcon==0.23.2"
65
+ - name: Build the wheel
66
+ working-directory: python
67
+ run: maturin build --locked --release --features python --out ../dist
68
+ - name: Install the wheel
69
+ run: python -m pip install dist/readcon_db-*.whl
70
+ - name: Build the C ABI library for the real-archive comparison
71
+ run: cargo build --locked --release --features capi --lib
72
+ - name: Test
73
+ env:
74
+ READCON_DB_CAPI_LIB: ${{ github.workspace }}/target/release/libreadcon_db.so
75
+ run: python -m pytest python/tests -q -rfEs
@@ -1,5 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.2.5 - 2026-11-28
4
+ #### Features
5
+ - (**python**) expose the observation archive writer - (791f832) - *HaoZeke*
6
+ - (**python**) read observation archives as readcon frames - (f5b0290) - *HaoZeke*
7
+ - append CON text onto a live trajectory - (8845e31) - *HaoZeke*
8
+ #### Bug Fixes
9
+ - (**corpus**) report a failed key scan instead of truncating it - (8d1becf) - *HaoZeke*
10
+ - (**python**) label a v3.1 clock and its velocities together - (3adeaca) - *HaoZeke*
11
+ #### Documentation
12
+ - (**python**) document reading observation archives - (ca678db) - *HaoZeke*
13
+ - date the citation release with the v0.2.4 tag - (da2940f) - *HaoZeke*
14
+ #### Tests
15
+ - (**python**) compare a written archive with the C ABI text path - (a132632) - *HaoZeke*
16
+ - (**python**) cover archive reads, writes and a real archive - (84dd0b9) - *HaoZeke*
17
+ - pin the claim expiry margin test to its clock - (b4afa8d) - *HaoZeke*
18
+ #### Build system
19
+ - (**python**) depend on readcon 0.23 - (84cef59) - *HaoZeke*
20
+ #### CI
21
+ - run the Python test suite against a built wheel - (3ce9432) - *HaoZeke*
22
+
3
23
  ## v0.2.4 - 2026-11-25
4
24
  #### Features
5
25
  - expose hash_con_text to c, fortran and python - (6704042) - *HaoZeke*
@@ -10,9 +10,9 @@ authors:
10
10
  license: MIT
11
11
  repository-code: "https://github.com/lode-org/readcon-db"
12
12
  # [[[cog cog.outl(f'version: {VERSION}') ]]]
13
- version: 0.2.4
13
+ version: 0.2.5
14
14
  # [[[end]]]
15
- date-released: "2026-08-15"
15
+ date-released: "2026-11-28"
16
16
  keywords:
17
17
  - CON
18
18
  - LMDB
@@ -924,7 +924,7 @@ dependencies = [
924
924
 
925
925
  [[package]]
926
926
  name = "readcon-db"
927
- version = "0.2.4"
927
+ version = "0.2.5"
928
928
  dependencies = [
929
929
  "heed",
930
930
  "libc",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "readcon-db"
3
- version = "0.2.4"
3
+ version = "0.2.5"
4
4
  edition = "2021"
5
5
  description = "Mmap-backed CON frame corpus (Heed/LMDB), xxHash exact match, multi-language FFI"
6
6
  license = "MIT"
@@ -1,10 +1,11 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: readcon-db
3
- Version: 0.2.4
3
+ Version: 0.2.5
4
+ Requires-Dist: readcon>=0.23,<0.24
4
5
  Summary: Mmap CON corpus store (LMDB/Heed) with xxHash exact match
5
6
  Home-Page: https://lode-org.github.io/readcon-db/
6
7
  License: MIT
7
- Requires-Python: >=3.9
8
+ Requires-Python: >=3.10
8
9
  Description-Content-Type: text/markdown
9
10
  Project-URL: Documentation, https://lode-org.github.io/readcon-db/
10
11
  Project-URL: Homepage, https://github.com/lode-org/readcon-db
@@ -91,7 +92,7 @@ let h = db.frame_hash(keys[0])?;
91
92
 
92
93
  Foreign trajectories: **`readcon.read_chemfiles("traj.xyz")` → frames → ingest into readcon-db** (chemfiles-enabled build), not `ase.io.read`.
93
94
 
94
- Python `append_trajectory_frames` commits 64 frames at a time. `get_frame` returns a `StoredFrame` (`atoms[i]` builds that atom only). Gzip and zstd files are read with `readcon.read_con`, then appended. Python `append_trajectory` and Rust `append_trajectory_path` read UTF-8 and do not decompress. `readcon-db` does not register an `ase.ioformats` entry point. Guide: [`docs/orgmode/howto/streaming.org`](docs/orgmode/howto/streaming.org). Upgrade from 0.2.0: [`docs/orgmode/howto/migration.org`](docs/orgmode/howto/migration.org).
95
+ Python `append_trajectory_frames` commits 64 frames at a time. `get_frame` returns a `StoredFrame` (`atoms[i]` builds that atom only). Gzip and zstd files are read with `readcon.read_con`, then appended. Python `append_trajectory` and Rust `append_trajectory_path` read UTF-8 and do not decompress. `readcon-db` does not register an `ase.ioformats` entry point. Python `ArchiveReader(path)` opens an observation archive (`observations.rdb`) read-only and returns each stored frame as a `readcon.ConFrame` with its energy and JSON metadata ([`docs/orgmode/reference/python.org`](docs/orgmode/reference/python.org#observation-archives)). Guide: [`docs/orgmode/howto/streaming.org`](docs/orgmode/howto/streaming.org). Upgrade from 0.2.0: [`docs/orgmode/howto/migration.org`](docs/orgmode/howto/migration.org).
95
96
 
96
97
  ## Design
97
98
 
@@ -78,7 +78,7 @@ let h = db.frame_hash(keys[0])?;
78
78
 
79
79
  Foreign trajectories: **`readcon.read_chemfiles("traj.xyz")` → frames → ingest into readcon-db** (chemfiles-enabled build), not `ase.io.read`.
80
80
 
81
- Python `append_trajectory_frames` commits 64 frames at a time. `get_frame` returns a `StoredFrame` (`atoms[i]` builds that atom only). Gzip and zstd files are read with `readcon.read_con`, then appended. Python `append_trajectory` and Rust `append_trajectory_path` read UTF-8 and do not decompress. `readcon-db` does not register an `ase.ioformats` entry point. Guide: [`docs/orgmode/howto/streaming.org`](docs/orgmode/howto/streaming.org). Upgrade from 0.2.0: [`docs/orgmode/howto/migration.org`](docs/orgmode/howto/migration.org).
81
+ Python `append_trajectory_frames` commits 64 frames at a time. `get_frame` returns a `StoredFrame` (`atoms[i]` builds that atom only). Gzip and zstd files are read with `readcon.read_con`, then appended. Python `append_trajectory` and Rust `append_trajectory_path` read UTF-8 and do not decompress. `readcon-db` does not register an `ase.ioformats` entry point. Python `ArchiveReader(path)` opens an observation archive (`observations.rdb`) read-only and returns each stored frame as a `readcon.ConFrame` with its energy and JSON metadata ([`docs/orgmode/reference/python.org`](docs/orgmode/reference/python.org#observation-archives)). Guide: [`docs/orgmode/howto/streaming.org`](docs/orgmode/howto/streaming.org). Upgrade from 0.2.0: [`docs/orgmode/howto/migration.org`](docs/orgmode/howto/migration.org).
82
82
 
83
83
  ## Design
84
84
 
@@ -0,0 +1 @@
1
+ Python `ArchiveReader` opens an observation archive or any corpus read-only and returns every stored frame, in `(traj_id, frame_idx)` order, as an `Observation` that holds the `readcon.ConFrame`, its CON text, energy, metadata and the permutation back to the writer's atom order. Python `ObservationArchive` is the archive writer. A missing path raises `FileNotFoundError` and a directory that is not a corpus raises `ArchiveError`.
@@ -0,0 +1 @@
1
+ The `readcon-db` Python package depends on `readcon>=0.23,<0.24`, the range of the pinned readcon-core, and so needs Python 3.10 or newer.
@@ -0,0 +1 @@
1
+ `rkrdb_extend_trajectory_str` and Python `extend_trajectory_str` append CON text after the live frame count. The new text is parsed before the write. A span that does not parse is not written, and earlier frames stay as stored.
@@ -0,0 +1 @@
1
+ Python ingest writes one `units.time` for a v3.1 frame's clock and velocities. A pre-3.1 clock stays in its own unit (or `fs`) and velocities are converted into that unit. A clock with no velocities still gets `units.time`. A v3.1 frame that already names `units.time` is unchanged.
@@ -47,6 +47,56 @@ The generated page is @@rst::doc:`/reference/python-api`@@.
47
47
 
48
48
  Optional =select= kwargs: ~exact_hash=~ (16-byte LE xxh3-128), =energy_min= / =energy_max=, =fmax_min= / =fmax_max=, =mass_min= / =mass_max=, =volume_min= / =volume_max=, =frame_index_min= / =frame_index_max=, =charge_min= / =charge_max=, =element_exact=, =element_min=, =formula=, =require_forces=, =require_velocities=, =require_energy=, =limit=.
49
49
 
50
+ ** Observation archives
51
+ :PROPERTIES:
52
+ :CUSTOM_ID: observation-archives
53
+ :END:
54
+ An observation archive is a corpus directory, =observations.rdb=, that a consumer such as a GP surrogate fills with the oracle evaluations it made. The C writer is =rkrdb_archive_open= / =rkrdb_archive_append=. =ObservationArchive= is the same writer in Python. =ArchiveReader= opens any corpus read-only and returns each stored frame as a =readcon.ConFrame=, so =readcon= must be installed.
55
+
56
+ #+begin_src python
57
+ from readcon_db import ArchiveReader
58
+
59
+ with ArchiveReader("out/obs-archive") as archive: # or ".../observations.rdb"
60
+ print(len(archive), archive.n_trajectories)
61
+ for obs in archive:
62
+ print(obs.traj_id, obs.frame_idx, obs.energy, obs.metadata["units"])
63
+ xyz = obs.frame.coords_array()[obs.caller_order]
64
+ forces = obs.frame.forces_array()[obs.caller_order]
65
+ last = archive[-1]
66
+ frame = archive.frame(traj_id=3) # readcon.ConFrame
67
+ text = archive.text(traj_id=3, frame_idx=0) # stored CON text
68
+ #+end_src
69
+
70
+ | Call | Returns |
71
+ |------+---------|
72
+ | =ArchiveReader(path)= | =path= is the corpus directory or the archive directory that holds =observations.rdb= |
73
+ | =len(archive)=, =archive.keys()= | observation count, and the =(traj_id, frame_idx)= keys in ascending order |
74
+ | =archive.n_trajectories=, =trajectory_ids()=, =n_frames(t)=, =source(t)= | trajectory count, ids, frames per trajectory, the source label the writer stored |
75
+ | =iter(archive)=, =archive[i]= | =Observation= objects in key order, =i= may be negative |
76
+ | =archive.get(t, f=0)=, =trajectory(t)= | one =Observation=, or every frame of one trajectory |
77
+ | =archive.frame(t, f=0)=, =text(t, f=0)= | the =readcon.ConFrame=, or the stored CON text |
78
+ | =refresh()= | takes the key list again and returns the new count |
79
+ | =close()=, =closed= | closes the LMDB environment, and whether it is closed |
80
+
81
+ An =Observation= has =traj_id=, =frame_idx=, =key=, =index= (its position in key order), =text=, =frame=, =natoms=, =energy= and =metadata= (the JSON metadata line), and =caller_order=.
82
+
83
+ The archive writer stores one single-frame trajectory per evaluation, with trajectory ids =0, 1, 2, ...= in append order. Other writers can store several frames per trajectory, and the reader keys every frame. =frame= is in stored CON order, which groups atoms by type. The writer stores caller index =i= as the =atom_id= of each atom, and =caller_order[i]= is the stored row of caller atom =i=. A frame whose atom ids are not =0..natoms= raises =ValueError= on =caller_order=.
84
+
85
+ The key list is taken at open. A writer in another process can keep appending, and =refresh()= picks up the new rows. LMDB does not support opening one environment twice in the same process. Close an =ObservationArchive= before an =ArchiveReader= opens that archive in the same process. Reading takes a reader slot in =lock.mdb=, so the reader needs write permission on the corpus directory and its files. Without it the open fails with =ArchiveError= (=Permission denied=). Copy the archive first when it is not yours to write.
86
+
87
+ A missing path raises =FileNotFoundError=. A directory that holds no corpus, or one that LMDB cannot open, raises =readcon_db.ArchiveError= (a =RuntimeError=). An absent key or trajectory raises =KeyError=, a position past the end raises =IndexError=, and a closed reader raises =ValueError=.
88
+
89
+ #+begin_src python
90
+ from readcon_db import ObservationArchive
91
+
92
+ with ObservationArchive("out/obs-archive", atomic_numbers=[1, 8, 1], cell=[25.0, 25.0, 25.0]) as w:
93
+ w.append(positions, forces, energy) # (natoms, 3) rows, caller order
94
+ w.flush()
95
+ positions, forces, energy = w.fetch(0)
96
+ #+end_src
97
+
98
+ =append= queues the row for a background thread and returns. =flush= waits until every queued row is stored or counted in =dropped=. =committed= counts stored rows, including those from earlier runs.
99
+
50
100
  ** MPI: pack on root, Bcast on the caller communicator
51
101
  :PROPERTIES:
52
102
  :CUSTOM_ID: mpi-pack-on-root-bcast-on-the-caller-communicator
@@ -1,6 +1,6 @@
1
1
  name = "ReadConDb"
2
2
  # [[[cog cog.outl(f'version = "{VERSION}"') ]]]
3
- version = "0.2.4"
3
+ version = "0.2.5"
4
4
  # [[[end]]]
5
5
  license = "MIT"
6
6
  [build]
@@ -69,6 +69,9 @@ int rkrdb_append_trajectory_units(size_t id, uint64_t traj_id, const char *path,
69
69
  /** Ingest CON text. `source` may be NULL (`memory`). */
70
70
  int rkrdb_append_trajectory_str(size_t id, uint64_t traj_id, const char *text,
71
71
  const char *source, uint32_t *out_n_frames);
72
+ /** Append CON text after the live frame count. `source` may be NULL (`memory`). */
73
+ int rkrdb_extend_trajectory_str(size_t id, uint64_t traj_id, const char *text,
74
+ const char *source, uint32_t *out_n_frames);
72
75
  /** Ingest one `RKRConFrame*` from libreadcon_core. Caller keeps the handle. */
73
76
  int rkrdb_append_trajectory_frame(size_t id, uint64_t traj_id, const void *frame,
74
77
  const char *source, uint32_t *out_n_frames);
@@ -257,6 +260,14 @@ public:
257
260
  return n;
258
261
  }
259
262
 
263
+ uint32_t extend_trajectory_str(uint64_t traj_id, const char *text,
264
+ const char *source = nullptr) {
265
+ uint32_t n = 0;
266
+ if (rkrdb_extend_trajectory_str(id_, traj_id, text, source, &n) != RKRDB_OK)
267
+ throw std::runtime_error("extend_str failed");
268
+ return n;
269
+ }
270
+
260
271
  uint32_t append_trajectory_frame(uint64_t traj_id, const void *frame,
261
272
  const char *source = nullptr) {
262
273
  uint32_t n = 0;
@@ -1,7 +1,7 @@
1
1
  [workspace]
2
2
  name = "readcon-db"
3
3
  # [[[cog cog.outl(f'version = "{VERSION}"') ]]]
4
- version = "0.2.4"
4
+ version = "0.2.5"
5
5
  # [[[end]]]
6
6
  description = "Mmap-backed CON frame corpus (Heed/LMDB), xxHash exact match, multi-language FFI"
7
7
  channels = ["conda-forge"]
@@ -6,7 +6,11 @@ build-backend = "maturin"
6
6
  name = "readcon-db"
7
7
  dynamic = ["version"]
8
8
  description = "Mmap CON corpus store (LMDB/Heed) with xxHash exact match"
9
- requires-python = ">=3.9"
9
+ # readcon 0.23 needs Python 3.10.
10
+ requires-python = ">=3.10"
11
+ # ArchiveReader and append_trajectory_frames work on readcon objects. The
12
+ # range follows the readcon-core pin in Cargo.toml.
13
+ dependencies = ["readcon>=0.23,<0.24"]
10
14
  license = { text = "MIT" }
11
15
  readme = { file = "README.md", content-type = "text/markdown" }
12
16
 
@@ -6,7 +6,11 @@ build-backend = "maturin"
6
6
  name = "readcon-db"
7
7
  dynamic = ["version"]
8
8
  description = "Mmap CON corpus store (LMDB/Heed) with xxHash exact match"
9
- requires-python = ">=3.9"
9
+ # readcon 0.23 needs Python 3.10.
10
+ requires-python = ">=3.10"
11
+ # ArchiveReader and append_trajectory_frames work on readcon objects. The
12
+ # range follows the readcon-core pin in Cargo.toml.
13
+ dependencies = ["readcon>=0.23,<0.24"]
10
14
  license = { text = "MIT" }
11
15
  readme = { file = "../README.md", content-type = "text/markdown" }
12
16
 
@@ -0,0 +1,321 @@
1
+ """Observation archives read back as readcon frames."""
2
+
3
+ import json
4
+ import os
5
+ import subprocess
6
+ import sys
7
+ from pathlib import Path
8
+
9
+ import numpy as np
10
+ import pytest
11
+ import readcon
12
+ import readcon_db
13
+ from readcon_db import ArchiveError, ArchiveReader, ConCorpus, ObservationArchive
14
+
15
+ # H, O, H: CON groups atoms by type, so storage permutes the caller order.
16
+ Z = [1, 8, 1]
17
+ CELL = [25.0, 25.0, 25.0]
18
+
19
+
20
+ def _rows(n_rows):
21
+ rng = np.random.default_rng(7)
22
+ rows = []
23
+ for i in range(n_rows):
24
+ pos = rng.normal(size=(3, 3)) + 10.0
25
+ frc = rng.normal(size=(3, 3)) * 0.1
26
+ rows.append((pos, frc, -76.4 + 0.25 * i))
27
+ return rows
28
+
29
+
30
+ def _write_archive(dir_path, rows):
31
+ with ObservationArchive(dir_path, Z, CELL) as archive:
32
+ for pos, frc, energy in rows:
33
+ archive.append(pos, frc, energy)
34
+ archive.flush()
35
+ assert archive.committed == len(rows)
36
+ assert archive.dropped == 0
37
+
38
+
39
+ def test_reader_returns_readcon_frames_in_caller_order(tmp_path):
40
+ rows = _rows(3)
41
+ _write_archive(tmp_path / "obs-archive", rows)
42
+
43
+ with ArchiveReader(tmp_path / "obs-archive") as reader:
44
+ assert reader.path.endswith("observations.rdb")
45
+ assert len(reader) == 3
46
+ assert reader.n_trajectories == 3
47
+ assert reader.trajectory_ids() == [0, 1, 2]
48
+ assert reader.keys() == [(0, 0), (1, 0), (2, 0)]
49
+ assert reader.source(0) == "observation-archive"
50
+ observations = list(reader)
51
+ assert [obs.index for obs in observations] == [0, 1, 2]
52
+ for obs, (pos, frc, energy) in zip(observations, rows):
53
+ assert isinstance(obs.frame, readcon.ConFrame)
54
+ assert obs.natoms == 3
55
+ assert obs.energy == energy
56
+ assert obs.frame.energy == energy
57
+ assert obs.metadata["energy"] == energy
58
+ assert obs.metadata["units"]["energy"] == "eV"
59
+ order = obs.caller_order
60
+ assert sorted(order) == [0, 1, 2]
61
+ # Stored order is type grouped: both H before O.
62
+ assert [obs.frame.atoms[i].symbol for i in range(3)] == ["H", "H", "O"]
63
+ # The archive writes round-trip floats, so the match is exact.
64
+ np.testing.assert_array_equal(obs.frame.coords_array()[order], pos)
65
+ np.testing.assert_array_equal(obs.frame.forces_array()[order], frc)
66
+ assert reader[-1].key == (2, 0)
67
+ assert reader.get(1).energy == rows[1][2]
68
+ assert reader.frame(1).energy == rows[1][2]
69
+ assert reader.closed
70
+
71
+
72
+ def test_reader_accepts_the_corpus_directory_and_str_paths(tmp_path):
73
+ _write_archive(tmp_path / "obs-archive", _rows(2))
74
+ corpus_dir = tmp_path / "obs-archive" / "observations.rdb"
75
+ with ArchiveReader(str(corpus_dir)) as reader:
76
+ assert len(reader) == 2
77
+ assert reader.path == str(corpus_dir)
78
+
79
+
80
+ def test_text_matches_the_corpus_and_round_trips_through_write_con(tmp_path):
81
+ _write_archive(tmp_path / "obs-archive", _rows(2))
82
+ with ArchiveReader(tmp_path / "obs-archive") as reader:
83
+ obs = reader.get(1)
84
+ text = reader.text(1)
85
+ assert text == obs.text
86
+ out = tmp_path / "one.con"
87
+ readcon.write_con(str(out), [obs.frame])
88
+ again = readcon.read_con(str(out))[0]
89
+ assert again.energy == obs.energy
90
+ np.testing.assert_array_equal(again.coords_array(), obs.frame.coords_array())
91
+ corpus = ConCorpus(
92
+ str(tmp_path / "obs-archive" / "observations.rdb"), readonly=True
93
+ )
94
+ assert corpus.get_frame_text(1, 0) == text
95
+
96
+
97
+ def test_writer_fetch_and_reader_agree(tmp_path):
98
+ rows = _rows(2)
99
+ with ObservationArchive(tmp_path / "a", Z, CELL) as archive:
100
+ for pos, frc, energy in rows:
101
+ archive.append(pos.ravel().tolist(), frc.tolist(), energy)
102
+ archive.flush()
103
+ pos, frc, energy = archive.fetch(1)
104
+ np.testing.assert_array_equal(np.array(pos), rows[1][0])
105
+ np.testing.assert_array_equal(np.array(frc), rows[1][1])
106
+ assert energy == rows[1][2]
107
+ with pytest.raises(IndexError):
108
+ archive.fetch(5)
109
+ with pytest.raises(ValueError, match="expected 9"):
110
+ archive.append([0.0] * 6, [0.0] * 9, 0.0)
111
+ with pytest.raises(ValueError, match="closed"):
112
+ archive.append([0.0] * 9, [0.0] * 9, 0.0)
113
+
114
+
115
+ def test_trajectory_ids_continue_across_writer_restarts(tmp_path):
116
+ rows = _rows(3)
117
+ _write_archive(tmp_path / "a", rows[:2])
118
+ archive = ObservationArchive(tmp_path / "a", Z, CELL)
119
+ assert archive.committed == 2
120
+ archive.append(*rows[2])
121
+ archive.flush()
122
+ archive.close()
123
+ with ArchiveReader(tmp_path / "a") as reader:
124
+ assert reader.keys() == [(0, 0), (1, 0), (2, 0)]
125
+ assert reader[2].energy == rows[2][2]
126
+
127
+
128
+ def _frame(x):
129
+ atoms = [
130
+ readcon.Atom("Cu", x, 0.0, 0.0, atom_id=0),
131
+ readcon.Atom("Cu", x + 1.0, 0.0, 0.0, atom_id=1),
132
+ ]
133
+ frame = readcon.ConFrame((10.0, 10.0, 10.0), (90.0, 90.0, 90.0), atoms)
134
+ frame.metadata = {"energy": -x}
135
+ return frame
136
+
137
+
138
+ def test_multi_frame_trajectories_are_keyed_by_frame(tmp_path):
139
+ path = tmp_path / "corpus"
140
+ db = ConCorpus(str(path))
141
+ db.append_trajectory_frames(
142
+ 7, [_frame(1.0), _frame(2.0), _frame(3.0)], source="neb"
143
+ )
144
+ db.append_trajectory_frames(2, [_frame(9.0)], source="single")
145
+ del db
146
+
147
+ with ArchiveReader(path) as reader:
148
+ assert len(reader) == 4
149
+ assert reader.keys() == [(2, 0), (7, 0), (7, 1), (7, 2)]
150
+ assert reader.trajectory_ids() == [2, 7]
151
+ assert reader.n_frames(7) == 3
152
+ assert reader.n_frames(2) == 1
153
+ assert reader.source(7) == "neb"
154
+ assert (7, 2) in reader
155
+ assert (7, 3) not in reader
156
+ traj = reader.trajectory(7)
157
+ assert [obs.frame_idx for obs in traj] == [0, 1, 2]
158
+ assert [obs.index for obs in traj] == [1, 2, 3]
159
+ assert [obs.energy for obs in traj] == [-1.0, -2.0, -3.0]
160
+ obs = reader.get(7, 2)
161
+ assert obs.index == 3
162
+ assert obs.frame.atoms[1].x == 4.0
163
+ assert reader[-1].key == (7, 2)
164
+ assert reader[0].key == (2, 0)
165
+ assert [o.key for o in reader] == reader.keys()
166
+
167
+
168
+ def test_missing_and_non_archive_paths_raise(tmp_path):
169
+ with pytest.raises(FileNotFoundError, match="not found"):
170
+ ArchiveReader(tmp_path / "nope")
171
+ (tmp_path / "empty").mkdir()
172
+ with pytest.raises(ArchiveError, match="not an observation archive"):
173
+ ArchiveReader(tmp_path / "empty")
174
+ junk = tmp_path / "junk"
175
+ junk.mkdir()
176
+ (junk / "data.mdb").write_bytes(b"not lmdb" * 512)
177
+ with pytest.raises(ArchiveError, match="cannot open"):
178
+ ArchiveReader(junk)
179
+ assert issubclass(ArchiveError, RuntimeError)
180
+ assert readcon_db.ArchiveError is ArchiveError
181
+
182
+
183
+ def test_lookup_errors_and_closed_reader(tmp_path):
184
+ _write_archive(tmp_path / "a", _rows(2))
185
+ reader = ArchiveReader(tmp_path / "a")
186
+ with pytest.raises(KeyError):
187
+ reader.get(9)
188
+ with pytest.raises(KeyError):
189
+ reader.get(0, 1)
190
+ with pytest.raises(KeyError):
191
+ reader.text(9)
192
+ with pytest.raises(KeyError):
193
+ reader.n_frames(9)
194
+ with pytest.raises(KeyError):
195
+ reader.trajectory(9)
196
+ with pytest.raises(KeyError):
197
+ reader.source(9)
198
+ with pytest.raises(IndexError):
199
+ reader[2]
200
+ with pytest.raises(IndexError):
201
+ reader[-3]
202
+ assert "observations=2" in repr(reader)
203
+ reader.close()
204
+ reader.close()
205
+ assert "closed" in repr(reader)
206
+ for call in (len, list, lambda r: r[0], lambda r: r.get(0), lambda r: r.keys()):
207
+ with pytest.raises(ValueError, match="closed"):
208
+ call(reader)
209
+
210
+
211
+ def test_caller_order_rejects_ids_that_are_not_a_permutation(tmp_path):
212
+ path = tmp_path / "corpus"
213
+ db = ConCorpus(str(path))
214
+ atoms = [
215
+ readcon.Atom("Cu", 0.0, 0.0, 0.0, atom_id=4),
216
+ readcon.Atom("Cu", 1.0, 0.0, 0.0, atom_id=5),
217
+ ]
218
+ db.append_trajectory_frames(
219
+ 0, [readcon.ConFrame((5.0, 5.0, 5.0), (90.0, 90.0, 90.0), atoms)]
220
+ )
221
+ del db
222
+ with ArchiveReader(path) as reader:
223
+ obs = reader[0]
224
+ assert obs.energy is None
225
+ with pytest.raises(ValueError, match="out of range"):
226
+ obs.caller_order
227
+
228
+
229
+ _APPEND_ONE = """
230
+ import sys
231
+ from readcon_db import ObservationArchive
232
+ with ObservationArchive(sys.argv[1], [1, 8, 1], [25.0, 25.0, 25.0]) as a:
233
+ a.append([0.5] * 9, [0.0] * 9, -1.5)
234
+ a.flush()
235
+ """
236
+
237
+
238
+ def test_refresh_sees_rows_another_process_appended(tmp_path):
239
+ _write_archive(tmp_path / "a", _rows(1))
240
+ with ArchiveReader(tmp_path / "a") as reader:
241
+ assert len(reader) == 1
242
+ subprocess.run(
243
+ [sys.executable, "-c", _APPEND_ONE, str(tmp_path / "a")], check=True
244
+ )
245
+ assert len(reader) == 1
246
+ assert reader.refresh() == 2
247
+ assert reader[1].energy == -1.5
248
+
249
+
250
+ # ---------------------------------------------------------------------------
251
+ # A real archive against the C ABI text path
252
+ # ---------------------------------------------------------------------------
253
+
254
+
255
+ def _con_columns(text):
256
+ """Energy and the coordinate rows of one CON frame, parsed by hand."""
257
+ lines = text.split("\n")
258
+ energy = json.loads(lines[1])["energy"]
259
+ counts = [int(c) for c in lines[7].split()]
260
+ rows, i = [], 9
261
+ for count in counts:
262
+ i += 2 # symbol line, "Coordinates of Component" line
263
+ rows.extend([float(v) for v in lines[i + j].split()[:3]] for j in range(count))
264
+ i += count
265
+ return energy, np.array(rows)
266
+
267
+
268
+ _CAPI_DUMP = """
269
+ import ctypes, json, sys
270
+ lib = ctypes.CDLL(sys.argv[1])
271
+ lib.rkrdb_open_readonly.argtypes = [ctypes.c_char_p, ctypes.POINTER(ctypes.c_size_t)]
272
+ lib.rkrdb_get_frame_text.argtypes = [
273
+ ctypes.c_size_t, ctypes.c_uint64, ctypes.c_uint32, ctypes.c_char_p, ctypes.c_size_t,
274
+ ]
275
+ h = ctypes.c_size_t()
276
+ assert lib.rkrdb_open_readonly(sys.argv[2].encode(), ctypes.byref(h)) == 0
277
+ buf = ctypes.create_string_buffer(1 << 22)
278
+ texts = []
279
+ for traj in range(1 << 20):
280
+ if lib.rkrdb_get_frame_text(h.value, traj, 0, buf, len(buf)) <= 0:
281
+ break
282
+ texts.append(buf.value.decode())
283
+ json.dump(texts, sys.stdout)
284
+ """
285
+
286
+
287
+ @pytest.mark.skipif(
288
+ not os.environ.get("READCON_DB_CAPI_LIB"),
289
+ reason="set READCON_DB_CAPI_LIB to a libreadcon_db built with the capi feature",
290
+ )
291
+ def test_archive_matches_the_c_abi_text_path(tmp_path):
292
+ """READCON_DB_REAL_ARCHIVE names an archive to compare, else one is written."""
293
+ real = os.environ.get("READCON_DB_REAL_ARCHIVE")
294
+ if real:
295
+ archive = Path(real)
296
+ else:
297
+ archive = tmp_path / "obs-archive" / "observations.rdb"
298
+ _write_archive(archive.parent, _rows(4))
299
+ lib = os.environ["READCON_DB_CAPI_LIB"]
300
+ # A second LMDB library in this process would open the same environment
301
+ # twice, so the C ABI reads in a child process.
302
+ out = subprocess.run(
303
+ [sys.executable, "-c", _CAPI_DUMP, lib, str(archive)],
304
+ check=True,
305
+ capture_output=True,
306
+ text=True,
307
+ )
308
+ texts = json.loads(out.stdout)
309
+ assert texts
310
+ with ArchiveReader(archive) as reader:
311
+ assert len(reader) == len(texts)
312
+ assert reader.keys() == [(t, 0) for t in range(len(texts))]
313
+ for obs, text in zip(reader, texts):
314
+ assert obs.text == text
315
+ ref = readcon.read_con_string(text)[0]
316
+ energy, coords = _con_columns(text)
317
+ assert obs.energy == energy == ref.energy
318
+ np.testing.assert_array_equal(obs.frame.coords_array(), coords)
319
+ np.testing.assert_array_equal(obs.frame.coords_array(), ref.coords_array())
320
+ np.testing.assert_array_equal(obs.frame.forces_array(), ref.forces_array())
321
+ assert sorted(obs.caller_order) == list(range(obs.natoms))