stringforge 0.1.1__tar.gz → 0.1.3__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 (66) hide show
  1. {stringforge-0.1.1/stringforge.egg-info → stringforge-0.1.3}/PKG-INFO +16 -15
  2. {stringforge-0.1.1 → stringforge-0.1.3}/README.md +10 -10
  3. {stringforge-0.1.1 → stringforge-0.1.3}/pyproject.toml +2 -3
  4. {stringforge-0.1.1 → stringforge-0.1.3}/setup.py +4 -2
  5. {stringforge-0.1.1 → stringforge-0.1.3}/stringforge/__init__.py +3 -1
  6. stringforge-0.1.3/stringforge/_vacuum_adapter.py +231 -0
  7. {stringforge-0.1.1 → stringforge-0.1.3}/stringforge/cy_io.py +37 -12
  8. stringforge-0.1.3/stringforge/cy_phase.py +1360 -0
  9. {stringforge-0.1.1 → stringforge-0.1.3}/stringforge/kklt_database.py +1 -1
  10. {stringforge-0.1.1 → stringforge-0.1.3}/stringforge/lcs_database.py +84 -16
  11. stringforge-0.1.3/stringforge/toric_db.py +440 -0
  12. stringforge-0.1.3/stringforge/toric_normalize.py +280 -0
  13. {stringforge-0.1.1 → stringforge-0.1.3}/stringforge/vacua_writer.py +286 -5
  14. {stringforge-0.1.1 → stringforge-0.1.3}/stringforge/vulcan/__init__.py +124 -0
  15. {stringforge-0.1.1 → stringforge-0.1.3}/stringforge/vulcan/certify.py +8 -12
  16. {stringforge-0.1.1 → stringforge-0.1.3}/stringforge/vulcan/verifier.py +43 -8
  17. {stringforge-0.1.1 → stringforge-0.1.3}/stringforge/vulcan/writer.py +85 -0
  18. {stringforge-0.1.1 → stringforge-0.1.3/stringforge.egg-info}/PKG-INFO +16 -15
  19. {stringforge-0.1.1 → stringforge-0.1.3}/stringforge.egg-info/SOURCES.txt +8 -0
  20. {stringforge-0.1.1 → stringforge-0.1.3}/stringforge.egg-info/requires.txt +1 -2
  21. stringforge-0.1.3/tests/test_cicy_conventions.py +251 -0
  22. {stringforge-0.1.1 → stringforge-0.1.3}/tests/test_packaging_metadata.py +4 -0
  23. stringforge-0.1.3/tests/test_toric_db.py +340 -0
  24. stringforge-0.1.3/tests/test_vacuum_adapter.py +319 -0
  25. stringforge-0.1.3/tests/test_vulcan_vacua.py +77 -0
  26. {stringforge-0.1.1 → stringforge-0.1.3}/LICENSE +0 -0
  27. {stringforge-0.1.1 → stringforge-0.1.3}/setup.cfg +0 -0
  28. {stringforge-0.1.1 → stringforge-0.1.3}/stringforge/vacuavault/__init__.py +0 -0
  29. {stringforge-0.1.1 → stringforge-0.1.3}/stringforge/vacuavault/__main__.py +0 -0
  30. {stringforge-0.1.1 → stringforge-0.1.3}/stringforge/vacuavault/catalog.py +0 -0
  31. {stringforge-0.1.1 → stringforge-0.1.3}/stringforge/vacuavault/ci.py +0 -0
  32. {stringforge-0.1.1 → stringforge-0.1.3}/stringforge/vacuavault/curate.py +0 -0
  33. {stringforge-0.1.1 → stringforge-0.1.3}/stringforge/vacuavault/schema.py +0 -0
  34. {stringforge-0.1.1 → stringforge-0.1.3}/stringforge/vulcan/__main__.py +0 -0
  35. {stringforge-0.1.1 → stringforge-0.1.3}/stringforge/vulcan/community.py +0 -0
  36. {stringforge-0.1.1 → stringforge-0.1.3}/stringforge/vulcan/hf_io.py +0 -0
  37. {stringforge-0.1.1 → stringforge-0.1.3}/stringforge/vulcan/ml_view.py +0 -0
  38. {stringforge-0.1.1 → stringforge-0.1.3}/stringforge/vulcan/ratelimit.py +0 -0
  39. {stringforge-0.1.1 → stringforge-0.1.3}/stringforge/vulcan/reader.py +0 -0
  40. {stringforge-0.1.1 → stringforge-0.1.3}/stringforge/vulcan/runid.py +0 -0
  41. {stringforge-0.1.1 → stringforge-0.1.3}/stringforge/vulcan/schema.py +0 -0
  42. {stringforge-0.1.1 → stringforge-0.1.3}/stringforge/vulcan/snapshot.py +0 -0
  43. {stringforge-0.1.1 → stringforge-0.1.3}/stringforge/vulcan/sync.py +0 -0
  44. {stringforge-0.1.1 → stringforge-0.1.3}/stringforge.egg-info/dependency_links.txt +0 -0
  45. {stringforge-0.1.1 → stringforge-0.1.3}/stringforge.egg-info/top_level.txt +0 -0
  46. {stringforge-0.1.1 → stringforge-0.1.3}/tests/test_complete_missing.py +0 -0
  47. {stringforge-0.1.1 → stringforge-0.1.3}/tests/test_import_hygiene.py +0 -0
  48. {stringforge-0.1.1 → stringforge-0.1.3}/tests/test_kklt_database.py +0 -0
  49. {stringforge-0.1.1 → stringforge-0.1.3}/tests/test_lcs_database.py +0 -0
  50. {stringforge-0.1.1 → stringforge-0.1.3}/tests/test_local_namespace.py +0 -0
  51. {stringforge-0.1.1 → stringforge-0.1.3}/tests/test_vacua_vault.py +0 -0
  52. {stringforge-0.1.1 → stringforge-0.1.3}/tests/test_vacua_writer_release.py +0 -0
  53. {stringforge-0.1.1 → stringforge-0.1.3}/tests/test_vulcan_certify.py +0 -0
  54. {stringforge-0.1.1 → stringforge-0.1.3}/tests/test_vulcan_cli.py +0 -0
  55. {stringforge-0.1.1 → stringforge-0.1.3}/tests/test_vulcan_community.py +0 -0
  56. {stringforge-0.1.1 → stringforge-0.1.3}/tests/test_vulcan_ml_view.py +0 -0
  57. {stringforge-0.1.1 → stringforge-0.1.3}/tests/test_vulcan_ratelimit.py +0 -0
  58. {stringforge-0.1.1 → stringforge-0.1.3}/tests/test_vulcan_reader.py +0 -0
  59. {stringforge-0.1.1 → stringforge-0.1.3}/tests/test_vulcan_roundtrip.py +0 -0
  60. {stringforge-0.1.1 → stringforge-0.1.3}/tests/test_vulcan_runid.py +0 -0
  61. {stringforge-0.1.1 → stringforge-0.1.3}/tests/test_vulcan_schema.py +0 -0
  62. {stringforge-0.1.1 → stringforge-0.1.3}/tests/test_vulcan_snapshot.py +0 -0
  63. {stringforge-0.1.1 → stringforge-0.1.3}/tests/test_vulcan_sync.py +0 -0
  64. {stringforge-0.1.1 → stringforge-0.1.3}/tests/test_vulcan_vault_floor.py +0 -0
  65. {stringforge-0.1.1 → stringforge-0.1.3}/tests/test_vulcan_verifier.py +0 -0
  66. {stringforge-0.1.1 → stringforge-0.1.3}/tests/test_vulcan_write.py +0 -0
@@ -1,13 +1,15 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: stringforge
3
- Version: 0.1.1
3
+ Version: 0.1.3
4
4
  Summary: Shared database, model-loading, and vacua-vault infrastructure for string compactifications.
5
- Home-page: https://github.com/AndreasSchachner/stringforge
5
+ Home-page: https://github.com/StringJAX/stringforge
6
6
  Author: Andreas Schachner
7
7
  Author-email: as3475@cornell.edu
8
- License: GPL-3.0-only
8
+ License: GPL-3.0-or-later
9
+ Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
9
10
  Classifier: Programming Language :: Python :: 3
10
11
  Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Programming Language :: Python :: 3.13
11
13
  Classifier: Intended Audience :: Science/Research
12
14
  Classifier: Topic :: Scientific/Engineering :: Physics
13
15
  Requires-Python: >=3.12
@@ -19,8 +21,7 @@ Requires-Dist: jaxlib
19
21
  Requires-Dist: pandas
20
22
  Requires-Dist: pyarrow
21
23
  Requires-Dist: huggingface_hub
22
- Requires-Dist: jaxpolylog>=0.3.0
23
- Requires-Dist: jaxvacua>=0.1.1
24
+ Requires-Dist: jaxvacua>=0.1.2
24
25
  Provides-Extra: sync
25
26
  Requires-Dist: huggingface_hub; extra == "sync"
26
27
  Provides-Extra: ml
@@ -46,7 +47,7 @@ Dynamic: license-file
46
47
 
47
48
  **Shared database, model-loading, and vacua-vault infrastructure for string-compactification workflows.**
48
49
 
49
- StringForge is the infrastructure layer for the [StringJAX](https://github.com/AndreasSchachner/stringjax) ecosystem of JAX-based string-compactification packages. It provides reproducible access to Calabi-Yau geometry databases, bridges those data into physics engines such as [JAXVacua](https://github.com/AndreasSchachner/jaxvacua), and manages persistent vacuum-solution storage with provenance.
50
+ StringForge is the infrastructure layer for the [StringJAX](https://github.com/StringJAX/stringjax) ecosystem of JAX-based string-compactification packages. It provides reproducible access to Calabi-Yau geometry databases, bridges those data into physics engines such as [JAXVacua](https://github.com/StringJAX/jaxvacua), and manages persistent vacuum-solution storage with provenance.
50
51
 
51
52
  The package is intentionally solver-light. It does not replace JAXVacua, KahlerJAX, JAXiverse, or CYTools. Instead, it standardises the shared conventions that those packages and downstream scans need: catalogue queries, lazy downloads, cache/offline workflows, model loading, vault layout, validation, and curation.
52
53
 
@@ -90,8 +91,8 @@ VulcanMLView -> geometry-disjoint train/val/test splits for ML
90
91
 
91
92
  | Package | Role | Release status |
92
93
  | --- | --- | --- |
93
- | **[JAXVacua](https://github.com/AndreasSchachner/jaxvacua)** — [docs](https://jaxvacua.readthedocs.io) | Type IIB flux vacua, complex-structure/axio-dilaton EFTs, vacuum finding, stability analysis | Public |
94
- | **[JAXPolyLog](https://github.com/AndreasSchachner/jaxpolylog)** — [docs](https://jaxpolylog.readthedocs.io) | JAX-compatible polylogarithms with autodiff support | Public |
94
+ | **[JAXVacua](https://github.com/StringJAX/jaxvacua)** — [docs](https://jaxvacua.readthedocs.io) | Type IIB flux vacua, complex-structure/axio-dilaton EFTs, vacuum finding, stability analysis | Public |
95
+ | **[JAXPolyLog](https://github.com/StringJAX/jaxpolylog)** — [docs](https://jaxpolylog.readthedocs.io) | JAX-compatible polylogarithms with autodiff support | Public |
95
96
  | **KahlerJAX** | Kähler-moduli stabilisation for 4D N=1 EFTs | Planned; not a StringForge dependency |
96
97
  | **JAXiverse** | Multi-axion EFT spectra, decay constants, and couplings | Planned; not a StringForge dependency |
97
98
  | **[CYTools](https://cy.tools)** | External toric Calabi-Yau geometry package | Public external dependency for selected workflows |
@@ -190,11 +191,11 @@ print(designated[["label", "n_vacua", "created"]])
190
191
  **Prerequisites:** Python >= 3.12. If GPU acceleration is needed, install [JAX with CUDA support](https://github.com/jax-ml/jax#installation) first.
191
192
 
192
193
  ```bash
193
- # Recommended once the package is public on PyPI
194
+ # From PyPI
194
195
  pip install stringforge
195
196
 
196
197
  # Development install from a local clone
197
- git clone https://github.com/AndreasSchachner/stringforge.git
198
+ git clone https://github.com/StringJAX/stringforge.git
198
199
  cd stringforge
199
200
  pip install -e .
200
201
  ```
@@ -222,8 +223,7 @@ Core dependencies installed by `pip`:
222
223
  - Pandas and PyArrow
223
224
  - HuggingFace Hub
224
225
  - JAX and jaxlib
225
- - JAXPolyLog
226
- - JAXVacua
226
+ - JAXVacua (which brings JAXPolyLog)
227
227
 
228
228
  Optional workflow dependencies:
229
229
 
@@ -252,8 +252,8 @@ If you find this work useful, please cite the companion paper as the **primary**
252
252
  author = {Schachner, Andreas},
253
253
  title = {StringForge: shared infrastructure for string-compactification workflows},
254
254
  year = {2026},
255
- version = {0.1.0},
256
- url = {https://github.com/AndreasSchachner/stringforge}
255
+ version = {0.1.3},
256
+ url = {https://github.com/StringJAX/stringforge}
257
257
  }
258
258
  ```
259
259
 
@@ -276,7 +276,8 @@ If you find this work useful, please cite the companion paper as the **primary**
276
276
 
277
277
  ## License
278
278
 
279
- StringForge is released under the [GNU General Public License v3.0](LICENSE).
279
+ StringForge is released under the [GNU General Public License](LICENSE), version 3 or (at your option)
280
+ any later version (GPL-3.0-or-later).
280
281
 
281
282
  ## Contact
282
283
 
@@ -10,7 +10,7 @@
10
10
 
11
11
  **Shared database, model-loading, and vacua-vault infrastructure for string-compactification workflows.**
12
12
 
13
- StringForge is the infrastructure layer for the [StringJAX](https://github.com/AndreasSchachner/stringjax) ecosystem of JAX-based string-compactification packages. It provides reproducible access to Calabi-Yau geometry databases, bridges those data into physics engines such as [JAXVacua](https://github.com/AndreasSchachner/jaxvacua), and manages persistent vacuum-solution storage with provenance.
13
+ StringForge is the infrastructure layer for the [StringJAX](https://github.com/StringJAX/stringjax) ecosystem of JAX-based string-compactification packages. It provides reproducible access to Calabi-Yau geometry databases, bridges those data into physics engines such as [JAXVacua](https://github.com/StringJAX/jaxvacua), and manages persistent vacuum-solution storage with provenance.
14
14
 
15
15
  The package is intentionally solver-light. It does not replace JAXVacua, KahlerJAX, JAXiverse, or CYTools. Instead, it standardises the shared conventions that those packages and downstream scans need: catalogue queries, lazy downloads, cache/offline workflows, model loading, vault layout, validation, and curation.
16
16
 
@@ -54,8 +54,8 @@ VulcanMLView -> geometry-disjoint train/val/test splits for ML
54
54
 
55
55
  | Package | Role | Release status |
56
56
  | --- | --- | --- |
57
- | **[JAXVacua](https://github.com/AndreasSchachner/jaxvacua)** — [docs](https://jaxvacua.readthedocs.io) | Type IIB flux vacua, complex-structure/axio-dilaton EFTs, vacuum finding, stability analysis | Public |
58
- | **[JAXPolyLog](https://github.com/AndreasSchachner/jaxpolylog)** — [docs](https://jaxpolylog.readthedocs.io) | JAX-compatible polylogarithms with autodiff support | Public |
57
+ | **[JAXVacua](https://github.com/StringJAX/jaxvacua)** — [docs](https://jaxvacua.readthedocs.io) | Type IIB flux vacua, complex-structure/axio-dilaton EFTs, vacuum finding, stability analysis | Public |
58
+ | **[JAXPolyLog](https://github.com/StringJAX/jaxpolylog)** — [docs](https://jaxpolylog.readthedocs.io) | JAX-compatible polylogarithms with autodiff support | Public |
59
59
  | **KahlerJAX** | Kähler-moduli stabilisation for 4D N=1 EFTs | Planned; not a StringForge dependency |
60
60
  | **JAXiverse** | Multi-axion EFT spectra, decay constants, and couplings | Planned; not a StringForge dependency |
61
61
  | **[CYTools](https://cy.tools)** | External toric Calabi-Yau geometry package | Public external dependency for selected workflows |
@@ -154,11 +154,11 @@ print(designated[["label", "n_vacua", "created"]])
154
154
  **Prerequisites:** Python >= 3.12. If GPU acceleration is needed, install [JAX with CUDA support](https://github.com/jax-ml/jax#installation) first.
155
155
 
156
156
  ```bash
157
- # Recommended once the package is public on PyPI
157
+ # From PyPI
158
158
  pip install stringforge
159
159
 
160
160
  # Development install from a local clone
161
- git clone https://github.com/AndreasSchachner/stringforge.git
161
+ git clone https://github.com/StringJAX/stringforge.git
162
162
  cd stringforge
163
163
  pip install -e .
164
164
  ```
@@ -186,8 +186,7 @@ Core dependencies installed by `pip`:
186
186
  - Pandas and PyArrow
187
187
  - HuggingFace Hub
188
188
  - JAX and jaxlib
189
- - JAXPolyLog
190
- - JAXVacua
189
+ - JAXVacua (which brings JAXPolyLog)
191
190
 
192
191
  Optional workflow dependencies:
193
192
 
@@ -216,8 +215,8 @@ If you find this work useful, please cite the companion paper as the **primary**
216
215
  author = {Schachner, Andreas},
217
216
  title = {StringForge: shared infrastructure for string-compactification workflows},
218
217
  year = {2026},
219
- version = {0.1.0},
220
- url = {https://github.com/AndreasSchachner/stringforge}
218
+ version = {0.1.3},
219
+ url = {https://github.com/StringJAX/stringforge}
221
220
  }
222
221
  ```
223
222
 
@@ -240,7 +239,8 @@ If you find this work useful, please cite the companion paper as the **primary**
240
239
 
241
240
  ## License
242
241
 
243
- StringForge is released under the [GNU General Public License v3.0](LICENSE).
242
+ StringForge is released under the [GNU General Public License](LICENSE), version 3 or (at your option)
243
+ any later version (GPL-3.0-or-later).
244
244
 
245
245
  ## Contact
246
246
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "stringforge"
7
- version = "0.1.1"
7
+ version = "0.1.3"
8
8
  description = "Shared database, model-loading, and vacua-vault infrastructure for string compactifications."
9
9
  requires-python = ">=3.12"
10
10
  dependencies = [
@@ -14,8 +14,7 @@ dependencies = [
14
14
  "pandas",
15
15
  "pyarrow",
16
16
  "huggingface_hub",
17
- "jaxpolylog>=0.3.0",
18
- "jaxvacua>=0.1.1",
17
+ "jaxvacua>=0.1.2",
19
18
  ]
20
19
  # Fields below are still owned by setup.py; declaring them dynamic
21
20
  # lets setuptools accept the values without rejecting the build.
@@ -10,12 +10,14 @@ setup(
10
10
  long_description_content_type='text/markdown',
11
11
  author='Andreas Schachner',
12
12
  author_email='as3475@cornell.edu',
13
- url='https://github.com/AndreasSchachner/stringforge',
13
+ url='https://github.com/StringJAX/stringforge',
14
14
  packages=find_packages(include=['stringforge', 'stringforge.*']),
15
- license='GPL-3.0-only',
15
+ license='GPL-3.0-or-later',
16
16
  classifiers=[
17
+ 'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
17
18
  'Programming Language :: Python :: 3',
18
19
  'Programming Language :: Python :: 3.12',
20
+ 'Programming Language :: Python :: 3.13',
19
21
  'Intended Audience :: Science/Research',
20
22
  'Topic :: Scientific/Engineering :: Physics',
21
23
  ],
@@ -74,7 +74,7 @@ curated results. Pass ``offline=True`` to a database constructor, or use
74
74
  ``from_local(...)``, to disable network access.
75
75
  """
76
76
 
77
- __version__ = "0.1.1"
77
+ __version__ = "0.1.3"
78
78
 
79
79
  # ── Data directory ────────────────────────────────────────────────────────
80
80
  # Default location for database cache files. Override
@@ -288,6 +288,8 @@ def set_vulcan_budget(budget):
288
288
  # ──────────────────────────────────────────────────────────────────────────
289
289
 
290
290
  from .cy_io import *
291
+ from .toric_db import * # ToricCYDatabase (sharded toric sub-dataset)
292
+ from .cy_phase import * # CYPhase / ToricCYPhase (per-geometry objects)
291
293
  from .lcs_database import *
292
294
  from .kklt_database import *
293
295
  from .vacua_writer import *
@@ -0,0 +1,231 @@
1
+ """Adapter between ``jaxvacua.vacuum`` objects and the stringforge writer schema.
2
+
3
+ A ``jaxvacua.vacuum.Vacuum`` (or ``PFV`` / ``AFV``) stores the *real* coordinate
4
+ vector ``x`` (not complex ``moduli``/``tau``) and carries no geometry identity.
5
+ This module maps such an object to the writer's ``{"moduli", "tau", "flux", ...}``
6
+ row dict (the *queryable projection*) and stashes the full, authoritative
7
+ ``Vacuum.to_dict()`` in the free ``extra_data`` column (the *record*), so read-back
8
+ is exact and finder-free.
9
+
10
+ Design constraints (kept deliberately):
11
+ * ``jaxvacua`` imports are **lazy / in-function** — importing this module never
12
+ imports ``jaxvacua`` (mirrors the rest of stringforge).
13
+ * The record is stored as **JSON** (a recursive numpy/complex codec), never
14
+ ``pickle`` — the vault is public/community, so an unpickle-on-load would be a
15
+ remote-code-execution vector. The codec itself lives in
16
+ :mod:`jaxvacua.vacuum` (``encode_json`` / ``decode_json``); this module only
17
+ wraps it.
18
+ """
19
+ from __future__ import annotations
20
+
21
+ import json
22
+ from typing import Any, Dict, Optional, Tuple
23
+
24
+ import numpy as np
25
+
26
+ # The JSON tags (``__nd__`` / ``__c__``) are defined with the codec in
27
+ # ``jaxvacua.vacuum``; nothing here needs them directly any more.
28
+
29
+
30
+ def is_vacuum(obj: Any) -> bool:
31
+ r"""
32
+ **Description:**
33
+ ``True`` iff *obj* is a ``jaxvacua.vacuum.Vacuum`` (or subclass).
34
+
35
+ Existing writer inputs (``dict`` / ``tuple`` / ``list``) short-circuit to
36
+ ``False`` *before* any ``jaxvacua`` import, so a plain ``append(dict)`` never
37
+ drags in the physics stack.
38
+
39
+ Args:
40
+ obj: Any candidate object.
41
+
42
+ Returns:
43
+ bool: Whether *obj* is a ``Vacuum`` (or ``PFV`` / ``AFV``) instance.
44
+ """
45
+ if isinstance(obj, (dict, tuple, list)):
46
+ return False
47
+ try:
48
+ from jaxvacua.vacuum import Vacuum
49
+ except Exception:
50
+ return False
51
+ return isinstance(obj, Vacuum)
52
+
53
+
54
+ # --------------------------------------------------------------------------- #
55
+ # JSON codec for a ``Vacuum.to_dict()`` payload
56
+ # --------------------------------------------------------------------------- #
57
+ # The tagged-JSON codec (``{"__nd__": ...}`` / ``{"__c__": ...}``) now lives in
58
+ # ``jaxvacua.vacuum``, so this repository and jaxvacua share one implementation
59
+ # rather than each carrying its own. These wrappers keep the local names and the
60
+ # lazy-import discipline: both are only ever reached from code paths that already
61
+ # require ``jaxvacua`` (encoding needs a ``Vacuum``; decoding is immediately
62
+ # followed by ``Vacuum.from_dict``).
63
+ def _json_encode(obj: Any) -> Any:
64
+ r"""
65
+ **Description:**
66
+ Encode a ``to_dict()`` payload to JSON-safe data.
67
+
68
+ Delegates to :func:`jaxvacua.vacuum.encode_json`.
69
+
70
+ Args:
71
+ obj: The (possibly nested) value to encode.
72
+
73
+ Returns:
74
+ A JSON-serialisable representation of *obj*.
75
+ """
76
+ from jaxvacua.vacuum import encode_json
77
+ return encode_json(obj)
78
+
79
+
80
+ def _json_decode(obj: Any) -> Any:
81
+ r"""
82
+ **Description:**
83
+ Inverse of :func:`_json_encode`.
84
+
85
+ Delegates to :func:`jaxvacua.vacuum.decode_json`.
86
+
87
+ Args:
88
+ obj: A value produced by :func:`_json_encode`.
89
+
90
+ Returns:
91
+ The decoded value, with numpy arrays and ``complex`` scalars restored.
92
+ """
93
+ from jaxvacua.vacuum import decode_json
94
+ return decode_json(obj)
95
+
96
+
97
+ # --------------------------------------------------------------------------- #
98
+ # Vacuum <-> writer row
99
+ # --------------------------------------------------------------------------- #
100
+ def _decode_moduli_tau(x: Any) -> Tuple[np.ndarray, complex]:
101
+ r"""
102
+ **Description:**
103
+ Decode the real coordinate vector ``x`` into complex moduli ``z`` and the
104
+ axio-dilaton ``tau``.
105
+
106
+ Delegates to :func:`jaxvacua.vacuum.real_to_complex`, the model-free statement
107
+ of the ``(Re z1, Im z1, ..., Re tau, Im tau)`` layout -- previously written out
108
+ independently here, in ``jaxvacua.vacuum`` and in
109
+ ``FluxEFT._convert_real_to_complex``. No finder is needed, so the queryable
110
+ ``moduli`` / ``tau`` columns stay finder-free.
111
+
112
+ Args:
113
+ x (Array): Full real coordinate vector.
114
+
115
+ Returns:
116
+ tuple: ``(z, tau)`` -- the complex moduli vector and the axio-dilaton.
117
+ """
118
+ from jaxvacua.vacuum import real_to_complex
119
+ return real_to_complex(x)
120
+
121
+
122
+ def vacuum_to_row(
123
+ vacuum: Any,
124
+ finder: Any = None,
125
+ *,
126
+ F_term_tol: float = 1e-8,
127
+ store_trajectory: bool = False,
128
+ ) -> Tuple[Dict[str, Any], Dict[str, Any]]:
129
+ r"""
130
+ **Description:**
131
+ Map a ``Vacuum`` to the ``(result, extra_data)`` pair the writer consumes.
132
+
133
+ ``result`` is the ``{"moduli", "tau", "flux", "residual", "is_susy",
134
+ "N_flux", "W", "F_terms"}`` dict fed to
135
+ :func:`stringforge.vacua_writer._vacua_row_from_dict` (the queryable typed
136
+ columns). ``extra_data`` carries the authoritative JSON-encoded
137
+ ``Vacuum.to_dict()`` under ``"vacuum"``, plus a readable ``"kind"`` and
138
+ ``"model_name"``.
139
+
140
+ .. admonition:: Details
141
+ :class: dropdown
142
+
143
+ ``is_susy`` is the *physics* flag ``residual < F_term_tol`` (F-flatness),
144
+ **not** the solver's ``success``. ``N_flux`` is the geometry-independent
145
+ D3 charge and requires a finder; without one it is ``None`` (a nullable
146
+ column, fillable later via ``VacuaWriter.complete_missing``).
147
+
148
+ Args:
149
+ vacuum: A ``jaxvacua.vacuum.Vacuum`` (or ``PFV`` / ``AFV``).
150
+ finder: Optional finder, used only for ``N_flux = finder.tadpole(flux)``.
151
+ F_term_tol (float): F-flatness threshold for the ``is_susy`` flag.
152
+ store_trajectory (bool): Keep the verbose optimisation trajectory in the
153
+ stored record.
154
+
155
+ Returns:
156
+ tuple: ``(result, extra_data)`` — the typed row dict and the extras dict
157
+ carrying the JSON record.
158
+ """
159
+ z, tau = _decode_moduli_tau(vacuum.x)
160
+ flux = np.asarray(vacuum.flux)
161
+
162
+ n_flux: Optional[int] = None
163
+ if finder is not None and hasattr(finder, "tadpole"):
164
+ try:
165
+ n_flux = int(round(float(finder.tadpole(flux))))
166
+ except Exception:
167
+ n_flux = None
168
+
169
+ res = float(vacuum.residual)
170
+ result: Dict[str, Any] = {
171
+ "moduli": z,
172
+ "tau": tau,
173
+ "flux": flux,
174
+ "residual": res,
175
+ "is_susy": bool(np.isfinite(res) and res < F_term_tol),
176
+ "N_flux": n_flux,
177
+ "W": (complex(vacuum.W0) if vacuum.W0 is not None else None),
178
+ "F_terms": (np.asarray(vacuum.DW) if vacuum.DW is not None else None),
179
+ }
180
+
181
+ d = vacuum.to_dict()
182
+ if not store_trajectory:
183
+ d.pop("trajectory", None)
184
+ try:
185
+ import jaxvacua as _jvc
186
+ d["_jaxvacua_version"] = getattr(_jvc, "__version__", None)
187
+ except Exception:
188
+ pass
189
+
190
+ extra: Dict[str, Any] = {
191
+ "vacuum": _json_encode(d),
192
+ "kind": d.get("_kind"),
193
+ "model_name": (getattr(vacuum, "metadata", None) or {}).get("model_name"),
194
+ }
195
+ return result, extra
196
+
197
+
198
+ def row_to_vacuum(extra_data: Any, *, finder: Any = None) -> Optional[Any]:
199
+ r"""
200
+ **Description:**
201
+ Rebuild a ``Vacuum`` from a stored row's ``extra_data`` — the inverse of
202
+ :func:`vacuum_to_row`.
203
+
204
+ Returns the exact original ``Vacuum`` / ``PFV`` / ``AFV`` (finder-free) when
205
+ the ``"vacuum"`` record is present. Rows written via the array path carry no
206
+ record and return ``None`` (the caller may rebuild a bare ``Vacuum`` from the
207
+ typed columns if a *finder* is available).
208
+
209
+ Args:
210
+ extra_data: The parsed ``extra_data`` dict or the raw JSON string.
211
+ finder: Optional finder (reserved for rebuilding record-less rows).
212
+
213
+ Returns:
214
+ Vacuum | None: The reconstructed vacuum, or ``None`` when no record is
215
+ present or *extra_data* is unparseable.
216
+ """
217
+ if extra_data is None:
218
+ return None
219
+ if isinstance(extra_data, str):
220
+ try:
221
+ extra_data = json.loads(extra_data)
222
+ except (ValueError, TypeError):
223
+ return None
224
+ if not isinstance(extra_data, dict):
225
+ return None
226
+ blob = extra_data.get("vacuum")
227
+ if blob is None:
228
+ return None
229
+ payload = _json_decode(blob)
230
+ from jaxvacua.vacuum import Vacuum
231
+ return Vacuum.from_dict(payload)
@@ -152,6 +152,12 @@ _DATASET_CONFIGS: Dict[str, str] = {
152
152
  "tdf": "KS",
153
153
  "cicy": "CICY",
154
154
  "kklt": "KKLT",
155
+ # ``toric`` is likewise a Kreuzer–Skarke toric hypersurface family, so it shares tdf's
156
+ # ``model_type`` label (the value is consumed only as ``lcs_tree(model_type=...)``, see
157
+ # ``lcs_database._parse_lcs_row``). Unlike the others, toric's catalogue is **sharded**
158
+ # per h11 with no monolithic ``catalog.parquet`` — see :class:`toric_db.ToricCYDatabase`,
159
+ # which replaces the catalogue layer rather than extending it.
160
+ "toric": "KS",
155
161
  }
156
162
 
157
163
  SCHEMA_VERSION: int = 1
@@ -329,19 +335,28 @@ def _parse_gv_row(row: Any) -> Dict[str, Any]:
329
335
  Args:
330
336
  row: A ``pandas.Series`` from the GV parquet file.
331
337
 
338
+ Not every sub-dataset carries both families: the ``cicy`` ``gv`` split has no
339
+ ``gw_charges``/``gw_invariants`` columns at all, whereas ``tdf``'s does. A missing
340
+ family is reported as ``None`` rather than as a dict of ``None``s, because
341
+ :meth:`jaxvacua.lcs.lcs_tree._charges_from_gv_gw` guards on ``x is not None`` — handing
342
+ it ``{"charges": None, "invariants": None}`` slipped past that guard and raised
343
+ ``AttributeError: 'NoneType' object has no attribute 'shape'``.
344
+
332
345
  Returns:
333
- Dict[str, Any]: Dictionary with keys ``"GVs"`` and ``"GWs"``, each a
334
- dict with ``"charges"`` and ``"invariants"`` arrays.
346
+ Dict[str, Any]: Dictionary with keys ``"GVs"``, ``"GWs"`` and
347
+ ``"grading_vector"``. ``"GVs"``/``"GWs"`` are each a dict with ``"charges"``
348
+ and ``"invariants"`` arrays, or ``None`` when that family is absent.
335
349
  """
350
+ def _family(charge_col: str, invariant_col: str) -> Optional[Dict[str, Any]]:
351
+ charges = _decode_array(row.get(charge_col))
352
+ invariants = _decode_invariants(row.get(invariant_col))
353
+ if charges is None or invariants is None:
354
+ return None
355
+ return {"charges": charges, "invariants": invariants}
356
+
336
357
  return {
337
- "GVs": {
338
- "charges": _decode_array(row.get("gv_charges")),
339
- "invariants": _decode_invariants(row.get("gv_invariants")),
340
- },
341
- "GWs": {
342
- "charges": _decode_array(row.get("gw_charges")),
343
- "invariants": _decode_invariants(row.get("gw_invariants")),
344
- },
358
+ "GVs": _family("gv_charges", "gv_invariants"),
359
+ "GWs": _family("gw_charges", "gw_invariants"),
345
360
  "grading_vector": _decode_array(row.get("grading_vector")),
346
361
  }
347
362
 
@@ -606,8 +621,18 @@ class CYDatabase:
606
621
  if dataset is None:
607
622
  dataset = getattr(cls, "_DATASET", "tdf")
608
623
  path = Path(path)
609
- # If the user passed the sub-dataset directory itself, step up.
610
- if path.name == dataset and (path / "catalog.parquet").exists():
624
+ # If the user passed the sub-dataset directory itself, step up so that
625
+ # `__init__`'s `cache_dir / dataset` lands back on it.
626
+ #
627
+ # The marker must not assume a monolithic `catalog.parquet`: sharded sub-datasets
628
+ # (`toric`) have no such file, so keying only on it silently resolved
629
+ # `.../toric` to `.../toric/toric` — and `__init__` then *created* that directory.
630
+ # `schema.json` is written by every sub-dataset regardless of layout, so accept
631
+ # either marker; falling back to "the directory is named after the dataset and
632
+ # holds something" would step up on an empty directory, which is worse.
633
+ if path.name == dataset and any(
634
+ (path / marker).exists() for marker in ("catalog.parquet", "schema.json")
635
+ ):
611
636
  path = path.parent
612
637
  return cls(
613
638
  dataset=dataset,