stringforge 0.1.3__tar.gz → 0.1.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. {stringforge-0.1.3/stringforge.egg-info → stringforge-0.1.4}/PKG-INFO +2 -2
  2. {stringforge-0.1.3 → stringforge-0.1.4}/README.md +1 -1
  3. {stringforge-0.1.3 → stringforge-0.1.4}/pyproject.toml +1 -1
  4. {stringforge-0.1.3 → stringforge-0.1.4}/stringforge/__init__.py +1 -1
  5. {stringforge-0.1.3 → stringforge-0.1.4}/stringforge/cy_io.py +244 -28
  6. {stringforge-0.1.3 → stringforge-0.1.4}/stringforge/cy_phase.py +2 -2
  7. {stringforge-0.1.3 → stringforge-0.1.4}/stringforge/kklt_database.py +97 -23
  8. {stringforge-0.1.3 → stringforge-0.1.4}/stringforge/lcs_database.py +144 -73
  9. {stringforge-0.1.3 → stringforge-0.1.4}/stringforge/toric_db.py +1 -1
  10. {stringforge-0.1.3 → stringforge-0.1.4}/stringforge/toric_normalize.py +5 -5
  11. {stringforge-0.1.3 → stringforge-0.1.4/stringforge.egg-info}/PKG-INFO +2 -2
  12. {stringforge-0.1.3 → stringforge-0.1.4}/stringforge.egg-info/SOURCES.txt +1 -0
  13. {stringforge-0.1.3 → stringforge-0.1.4}/tests/test_cicy_conventions.py +5 -1
  14. stringforge-0.1.4/tests/test_reader_filters_and_keys.py +715 -0
  15. {stringforge-0.1.3 → stringforge-0.1.4}/LICENSE +0 -0
  16. {stringforge-0.1.3 → stringforge-0.1.4}/setup.cfg +0 -0
  17. {stringforge-0.1.3 → stringforge-0.1.4}/setup.py +0 -0
  18. {stringforge-0.1.3 → stringforge-0.1.4}/stringforge/_vacuum_adapter.py +0 -0
  19. {stringforge-0.1.3 → stringforge-0.1.4}/stringforge/vacua_writer.py +0 -0
  20. {stringforge-0.1.3 → stringforge-0.1.4}/stringforge/vacuavault/__init__.py +0 -0
  21. {stringforge-0.1.3 → stringforge-0.1.4}/stringforge/vacuavault/__main__.py +0 -0
  22. {stringforge-0.1.3 → stringforge-0.1.4}/stringforge/vacuavault/catalog.py +0 -0
  23. {stringforge-0.1.3 → stringforge-0.1.4}/stringforge/vacuavault/ci.py +0 -0
  24. {stringforge-0.1.3 → stringforge-0.1.4}/stringforge/vacuavault/curate.py +0 -0
  25. {stringforge-0.1.3 → stringforge-0.1.4}/stringforge/vacuavault/schema.py +0 -0
  26. {stringforge-0.1.3 → stringforge-0.1.4}/stringforge/vulcan/__init__.py +0 -0
  27. {stringforge-0.1.3 → stringforge-0.1.4}/stringforge/vulcan/__main__.py +0 -0
  28. {stringforge-0.1.3 → stringforge-0.1.4}/stringforge/vulcan/certify.py +0 -0
  29. {stringforge-0.1.3 → stringforge-0.1.4}/stringforge/vulcan/community.py +0 -0
  30. {stringforge-0.1.3 → stringforge-0.1.4}/stringforge/vulcan/hf_io.py +0 -0
  31. {stringforge-0.1.3 → stringforge-0.1.4}/stringforge/vulcan/ml_view.py +0 -0
  32. {stringforge-0.1.3 → stringforge-0.1.4}/stringforge/vulcan/ratelimit.py +0 -0
  33. {stringforge-0.1.3 → stringforge-0.1.4}/stringforge/vulcan/reader.py +0 -0
  34. {stringforge-0.1.3 → stringforge-0.1.4}/stringforge/vulcan/runid.py +0 -0
  35. {stringforge-0.1.3 → stringforge-0.1.4}/stringforge/vulcan/schema.py +0 -0
  36. {stringforge-0.1.3 → stringforge-0.1.4}/stringforge/vulcan/snapshot.py +0 -0
  37. {stringforge-0.1.3 → stringforge-0.1.4}/stringforge/vulcan/sync.py +0 -0
  38. {stringforge-0.1.3 → stringforge-0.1.4}/stringforge/vulcan/verifier.py +0 -0
  39. {stringforge-0.1.3 → stringforge-0.1.4}/stringforge/vulcan/writer.py +0 -0
  40. {stringforge-0.1.3 → stringforge-0.1.4}/stringforge.egg-info/dependency_links.txt +0 -0
  41. {stringforge-0.1.3 → stringforge-0.1.4}/stringforge.egg-info/requires.txt +0 -0
  42. {stringforge-0.1.3 → stringforge-0.1.4}/stringforge.egg-info/top_level.txt +0 -0
  43. {stringforge-0.1.3 → stringforge-0.1.4}/tests/test_complete_missing.py +0 -0
  44. {stringforge-0.1.3 → stringforge-0.1.4}/tests/test_import_hygiene.py +0 -0
  45. {stringforge-0.1.3 → stringforge-0.1.4}/tests/test_kklt_database.py +0 -0
  46. {stringforge-0.1.3 → stringforge-0.1.4}/tests/test_lcs_database.py +0 -0
  47. {stringforge-0.1.3 → stringforge-0.1.4}/tests/test_local_namespace.py +0 -0
  48. {stringforge-0.1.3 → stringforge-0.1.4}/tests/test_packaging_metadata.py +0 -0
  49. {stringforge-0.1.3 → stringforge-0.1.4}/tests/test_toric_db.py +0 -0
  50. {stringforge-0.1.3 → stringforge-0.1.4}/tests/test_vacua_vault.py +0 -0
  51. {stringforge-0.1.3 → stringforge-0.1.4}/tests/test_vacua_writer_release.py +0 -0
  52. {stringforge-0.1.3 → stringforge-0.1.4}/tests/test_vacuum_adapter.py +0 -0
  53. {stringforge-0.1.3 → stringforge-0.1.4}/tests/test_vulcan_certify.py +0 -0
  54. {stringforge-0.1.3 → stringforge-0.1.4}/tests/test_vulcan_cli.py +0 -0
  55. {stringforge-0.1.3 → stringforge-0.1.4}/tests/test_vulcan_community.py +0 -0
  56. {stringforge-0.1.3 → stringforge-0.1.4}/tests/test_vulcan_ml_view.py +0 -0
  57. {stringforge-0.1.3 → stringforge-0.1.4}/tests/test_vulcan_ratelimit.py +0 -0
  58. {stringforge-0.1.3 → stringforge-0.1.4}/tests/test_vulcan_reader.py +0 -0
  59. {stringforge-0.1.3 → stringforge-0.1.4}/tests/test_vulcan_roundtrip.py +0 -0
  60. {stringforge-0.1.3 → stringforge-0.1.4}/tests/test_vulcan_runid.py +0 -0
  61. {stringforge-0.1.3 → stringforge-0.1.4}/tests/test_vulcan_schema.py +0 -0
  62. {stringforge-0.1.3 → stringforge-0.1.4}/tests/test_vulcan_snapshot.py +0 -0
  63. {stringforge-0.1.3 → stringforge-0.1.4}/tests/test_vulcan_sync.py +0 -0
  64. {stringforge-0.1.3 → stringforge-0.1.4}/tests/test_vulcan_vacua.py +0 -0
  65. {stringforge-0.1.3 → stringforge-0.1.4}/tests/test_vulcan_vault_floor.py +0 -0
  66. {stringforge-0.1.3 → stringforge-0.1.4}/tests/test_vulcan_verifier.py +0 -0
  67. {stringforge-0.1.3 → stringforge-0.1.4}/tests/test_vulcan_write.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: stringforge
3
- Version: 0.1.3
3
+ Version: 0.1.4
4
4
  Summary: Shared database, model-loading, and vacua-vault infrastructure for string compactifications.
5
5
  Home-page: https://github.com/StringJAX/stringforge
6
6
  Author: Andreas Schachner
@@ -252,7 +252,7 @@ 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.3},
255
+ version = {0.1.4},
256
256
  url = {https://github.com/StringJAX/stringforge}
257
257
  }
258
258
  ```
@@ -215,7 +215,7 @@ If you find this work useful, please cite the companion paper as the **primary**
215
215
  author = {Schachner, Andreas},
216
216
  title = {StringForge: shared infrastructure for string-compactification workflows},
217
217
  year = {2026},
218
- version = {0.1.3},
218
+ version = {0.1.4},
219
219
  url = {https://github.com/StringJAX/stringforge}
220
220
  }
221
221
  ```
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "stringforge"
7
- version = "0.1.3"
7
+ version = "0.1.4"
8
8
  description = "Shared database, model-loading, and vacua-vault infrastructure for string compactifications."
9
9
  requires-python = ">=3.12"
10
10
  dependencies = [
@@ -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.3"
77
+ __version__ = "0.1.4"
78
78
 
79
79
  # ── Data directory ────────────────────────────────────────────────────────
80
80
  # Default location for database cache files. Override
@@ -173,7 +173,9 @@ SCHEMA_CHANGELOG: Dict[int, str] = {
173
173
  "(ks_id, coni_class_id, coni_id) carrying the logical TDF link "
174
174
  "(triang_id, tdf_conifold_id); optional tag columns record "
175
175
  "curation and release-readiness metadata; schema.json carries a "
176
- "TDF-compat fingerprint (tdf_schema_version, tdf_catalog_sha256).",
176
+ "TDF-compat fingerprint (tdf_schema_version, tdf_catalog_sha256). "
177
+ "Note (2026-11-26): the published tdf catalog.parquet does not carry "
178
+ "'D3_tadpole'.",
177
179
  }
178
180
 
179
181
  class SchemaVersionError(RuntimeError):
@@ -195,6 +197,111 @@ class ValidationError(RuntimeError):
195
197
  self.report = report or []
196
198
 
197
199
 
200
+ class CatalogMismatchError(RuntimeError):
201
+ r"""
202
+ Raised when a shard row does not carry the key that its catalogue entry
203
+ points to.
204
+
205
+ Rows are fetched by ``(shard_id, row_index)`` pointers stored in the
206
+ catalogue. If the cached catalogue and the shards come from different
207
+ revisions of the database, a pointer can resolve to another model's row.
208
+ Without a check, that model's geometry would be returned silently. The
209
+ same error is raised when the conifold shards read hold a different number
210
+ of a model's conifolds than the catalogue lists.
211
+ """
212
+
213
+
214
+ def _as_integral(value: Any) -> Optional[int]:
215
+ r"""Return *value* as an ``int`` if it is an integral number, else ``None``.
216
+
217
+ Accepts Python and NumPy integers, and floats with an integral value
218
+ (``3.0``). Rejects missing values (``None``, NaN, ``pd.NA``), non-integral
219
+ floats (``10.9``), strings and booleans.
220
+ """
221
+ if value is None or isinstance(value, (bool, np.bool_, str, bytes)):
222
+ return None
223
+ if isinstance(value, (int, np.integer)):
224
+ return int(value)
225
+ try:
226
+ f = float(value)
227
+ except (TypeError, ValueError):
228
+ return None
229
+ return int(f) if np.isfinite(f) and f.is_integer() else None
230
+
231
+
232
+ def _is_missing(value: Any) -> bool:
233
+ r"""Whether *value* is a missing scalar: ``None``, a float NaN, ``pd.NA`` or ``pd.NaT``."""
234
+ if value is None:
235
+ return True
236
+ if isinstance(value, (float, np.floating)):
237
+ return bool(np.isnan(value))
238
+ return type(value).__name__ in ("NAType", "NaTType")
239
+
240
+
241
+ def _show_key(value: Any) -> str:
242
+ r"""Format a key value for a message: ``7884``, not ``np.int64(7884)``; non-integral values as ``repr``."""
243
+ i = _as_integral(value)
244
+ return repr(value) if i is None else str(i)
245
+
246
+
247
+ def _check_row_key(row: Any, expected: Dict[str, Any], where: str) -> None:
248
+ r"""
249
+ **Description:**
250
+ Verify that a fetched shard row carries the expected primary-key values.
251
+
252
+ The row must carry every expected key column whose expected value is
253
+ present, and each must hold the same integral value. A row that lacks one
254
+ of them cannot be told apart from a neighbouring row (in an
255
+ ``lcs_data/h11_N`` shard every row has ``h11 = N``), so it is refused.
256
+ Every published shard of ``tdf``, ``cicy`` and ``kklt`` carries its key
257
+ columns.
258
+
259
+ Args:
260
+ row: The fetched row (a ``pandas.Series`` or a mapping).
261
+ expected (dict): Key column -> expected value, e.g.
262
+ ``{"ks_id": 12, "triang_id": 0, "h11": 3}``. Missing expected
263
+ values (``None``, NaN, ``pd.NA``, ``pd.NaT``) are not compared.
264
+ An expected value that is present but not an integral number (a
265
+ corrupt catalogue entry) counts as a mismatch.
266
+ where (str): Human-readable location of the row, used in the message
267
+ (e.g. ``"lcs_data/h11_3 shard 0 row 5"``).
268
+
269
+ Raises:
270
+ CatalogMismatchError: If a key column disagrees, if either side of a
271
+ comparison is not an integral number, if the row lacks a key
272
+ column whose expected value is present, or if every expected
273
+ value is missing.
274
+ """
275
+ keys = set(row.keys()) if hasattr(row, "keys") else set()
276
+ present = {c: w for c, w in expected.items() if not _is_missing(w)}
277
+ remedy = ("The cached catalogue and shards probably come from different revisions of "
278
+ "the database. Clear the cache of this database (for KKLT, also that of its "
279
+ "wrapped TDF database) and load again; for a local build, rebuild it.")
280
+ if not present:
281
+ raise CatalogMismatchError(
282
+ f"The catalogue entry for the row at {where} has no key value to check it "
283
+ f"against (all of {sorted(expected)} are missing)."
284
+ )
285
+ absent = sorted(c for c in present if c not in keys)
286
+ if absent:
287
+ raise CatalogMismatchError(
288
+ f"The row at {where} lacks the key column(s) {absent}, so it cannot be "
289
+ f"checked against its catalogue entry. {remedy}"
290
+ )
291
+ bad = {}
292
+ for col, want in present.items():
293
+ got = row[col]
294
+ want_i = _as_integral(want)
295
+ if want_i is None or _as_integral(got) != want_i:
296
+ bad[col] = (got, want)
297
+ if bad:
298
+ detail = ", ".join(f"{c}={_show_key(g)} (expected {_show_key(w)})"
299
+ for c, (g, w) in bad.items())
300
+ raise CatalogMismatchError(
301
+ f"The row at {where} does not belong to the requested model: {detail}. {remedy}"
302
+ )
303
+
304
+
198
305
  def _require_pandas() -> Any:
199
306
  r"""
200
307
  **Description:**
@@ -1147,6 +1254,83 @@ class CYDatabase:
1147
1254
 
1148
1255
  return result
1149
1256
 
1257
+ def _fetch_conifold_rows(
1258
+ self,
1259
+ entry: Any,
1260
+ ks_id: Optional[int] = None,
1261
+ triang_id: Optional[int] = None,
1262
+ cicy_id: Optional[int] = None,
1263
+ target_id: Optional[int] = None,
1264
+ ) -> Any:
1265
+ r"""
1266
+ **Description:**
1267
+ Fetch the rows of one model from the ``conifolds`` split.
1268
+
1269
+ The rows are selected by key, ``(ks_id, triang_id, h11)`` for ``tdf`` or
1270
+ ``cicy_id`` for ``cicy``, starting at the catalogue's
1271
+ ``conifold_shard_id``. A model's rows can continue in the next shard,
1272
+ which is read while fewer than the catalogue's ``n_conifolds`` rows
1273
+ have been found, unless the conifold ``target_id`` has already been
1274
+ found. Shard ids are not contiguous, but a model that continues does
1275
+ so in the shard with the next id. A fetch error, such as a shard that
1276
+ is missing from an offline cache, propagates unchanged.
1277
+
1278
+ Args:
1279
+ entry (pandas.Series): The model's catalogue row (catalogue
1280
+ convention), with ``h11``, ``n_conifolds`` and
1281
+ ``conifold_shard_id``.
1282
+ ks_id (int | None): Kreuzer-Skarke polytope index (tdf).
1283
+ triang_id (int | None): Triangulation index (tdf).
1284
+ cicy_id (int | None): CICY model index (cicy).
1285
+ target_id (int | None): Stop as soon as this ``conifold_id`` is
1286
+ found. ``None`` reads every row of the model.
1287
+
1288
+ Returns:
1289
+ pandas.DataFrame: The rows read; empty if ``n_conifolds`` is 0.
1290
+
1291
+ Raises:
1292
+ CatalogMismatchError: If the shards read hold more rows of the model
1293
+ than ``n_conifolds``, none at all, or fewer when every row was
1294
+ needed (``target_id`` not found).
1295
+ """
1296
+ pd = _require_pandas()
1297
+ n_cf = int(entry.get("n_conifolds", 0))
1298
+ if n_cf <= 0:
1299
+ return pd.DataFrame()
1300
+ cat_h11 = int(entry["h11"])
1301
+ split = f"conifolds/h11_{cat_h11}"
1302
+
1303
+ def mask(df: Any) -> Any:
1304
+ if self.dataset != "tdf":
1305
+ return df["cicy_id"] == cicy_id
1306
+ m = (df["ks_id"] == ks_id) & (df["triang_id"] == triang_id)
1307
+ return m & (df["h11"] == cat_h11) if "h11" in df.columns else m
1308
+
1309
+ first = shard_id = int(entry["conifold_shard_id"])
1310
+ parts, n_found, target_found = [], 0, False
1311
+ while n_found < n_cf:
1312
+ if self.cache_mode == "persistent":
1313
+ shard = self._fetch_shard(split, shard_id)
1314
+ rows = shard[mask(shard)]
1315
+ else:
1316
+ rows = self._fetch_rows(split, shard_id, mask)
1317
+ if len(rows) == 0:
1318
+ break
1319
+ parts.append(rows)
1320
+ n_found += len(rows)
1321
+ shard_id += 1
1322
+ if target_id is not None and bool((rows["conifold_id"] == target_id).any()):
1323
+ target_found = True
1324
+ break
1325
+ if n_found > n_cf or n_found == 0 or (n_found < n_cf and not target_found):
1326
+ raise CatalogMismatchError(
1327
+ f"The catalogue lists {n_cf} conifold(s) for this model, but the {split} "
1328
+ f"shards read from {first} on hold {n_found}. The cached catalogue and shards "
1329
+ f"probably come from different revisions of the database. Clear the cache of "
1330
+ f"this database and load again; for a local build, rebuild it."
1331
+ )
1332
+ return pd.concat(parts)
1333
+
1150
1334
  def _lookup(
1151
1335
  self,
1152
1336
  ks_id: Optional[int],
@@ -1159,10 +1343,11 @@ class CYDatabase:
1159
1343
  **Description:**
1160
1344
  Look up the catalog row for a given model primary key.
1161
1345
 
1162
- For ``tdf`` models the full primary key is
1163
- ``(h11, h12, ks_id, triang_id)``. When ``h11`` and ``h12`` are
1164
- omitted, only ``(ks_id, triang_id)`` is used; if this yields multiple
1165
- matches an error is raised asking the caller to disambiguate.
1346
+ For ``tdf`` models the primary key is ``(h11, ks_id, triang_id)``:
1347
+ ``ks_id`` is unique only within one ``h11``, so ``(ks_id, triang_id)``
1348
+ alone can match models at two values of ``h11``. ``h12`` is accepted
1349
+ as an extra check but is not needed. When ``h11`` is omitted and the
1350
+ pair matches several models, an error asks the caller to disambiguate.
1166
1351
 
1167
1352
  Args:
1168
1353
  ks_id (int | None): Kreuzer-Skarke polytope index (tdf only).
@@ -1176,8 +1361,10 @@ class CYDatabase:
1176
1361
 
1177
1362
  Raises:
1178
1363
  KeyError: If no matching row is found.
1179
- ValueError: If multiple rows match — supply ``h11`` and ``h12``
1180
- to disambiguate.
1364
+ ValueError: If multiple rows match. Supplying ``h11`` resolves it;
1365
+ the message asks for both Hodge numbers, because callers in
1366
+ the mirror convention (:class:`~stringforge.lcs_database.LCSDatabase`)
1367
+ pass the catalogue ``h11`` as their ``h12``.
1181
1368
  """
1182
1369
  self._ensure_catalog()
1183
1370
  cat = self._catalog
@@ -1327,33 +1514,55 @@ class CYDatabase:
1327
1514
  has_gv (bool | None): If ``True``, return only models for which
1328
1515
  Gopakumar-Vafa invariants are stored.
1329
1516
  D3_tadpole_max (int | None): Return only models whose D3-tadpole
1330
- is at most this value.
1517
+ is at most this value. Requires a ``D3_tadpole`` catalogue
1518
+ column, which the published ``tdf`` catalogue does not have.
1331
1519
  **filters: Additional exact-match filters on catalog columns,
1332
1520
  e.g. ``chi=-240``.
1333
1521
 
1334
1522
  Returns:
1335
1523
  pandas.DataFrame: Matching rows from the catalog.
1524
+
1525
+ Raises:
1526
+ ValueError: If one of the named filters is given and its catalogue
1527
+ column is absent (``has_conifolds`` / ``n_conifolds_min`` /
1528
+ ``n_conifolds_max`` need ``n_conifolds``; ``has_gv`` needs
1529
+ ``has_gv``; ``D3_tadpole_max`` needs ``D3_tadpole``). In 0.1.3
1530
+ and earlier such a filter was skipped silently, so the result
1531
+ was not restricted by it. An unknown column passed through
1532
+ ``**filters`` still only warns and is skipped.
1336
1533
  """
1337
1534
  self._ensure_catalog()
1535
+ cols = self._catalog.columns
1536
+ for name, value, col in (
1537
+ ("has_conifolds", has_conifolds, "n_conifolds"),
1538
+ ("n_conifolds_min", n_conifolds_min, "n_conifolds"),
1539
+ ("n_conifolds_max", n_conifolds_max, "n_conifolds"),
1540
+ ("has_gv", has_gv, "has_gv"),
1541
+ ("D3_tadpole_max", D3_tadpole_max, "D3_tadpole"),
1542
+ ):
1543
+ if value is not None and col not in cols:
1544
+ raise ValueError(
1545
+ f"Cannot apply the filter `{name}`: the '{self.dataset}' catalogue "
1546
+ f"has no '{col}' column."
1547
+ )
1338
1548
  mask = np.ones(len(self._catalog), dtype=bool)
1339
1549
 
1340
1550
  if h11 is not None:
1341
1551
  mask &= (self._catalog["h11"] == h11).values
1342
1552
  if h12 is not None:
1343
1553
  mask &= (self._catalog["h12"] == h12).values
1344
- if "n_conifolds" in self._catalog.columns:
1345
- if has_conifolds is not None:
1346
- if has_conifolds:
1347
- mask &= (self._catalog["n_conifolds"] > 0).values
1348
- else:
1349
- mask &= (self._catalog["n_conifolds"] == 0).values
1350
- if n_conifolds_min is not None:
1351
- mask &= (self._catalog["n_conifolds"] >= n_conifolds_min).values
1352
- if n_conifolds_max is not None:
1353
- mask &= (self._catalog["n_conifolds"] <= n_conifolds_max).values
1354
- if has_gv is not None and "has_gv" in self._catalog.columns:
1554
+ if has_conifolds is not None:
1555
+ if has_conifolds:
1556
+ mask &= (self._catalog["n_conifolds"] > 0).values
1557
+ else:
1558
+ mask &= (self._catalog["n_conifolds"] == 0).values
1559
+ if n_conifolds_min is not None:
1560
+ mask &= (self._catalog["n_conifolds"] >= n_conifolds_min).values
1561
+ if n_conifolds_max is not None:
1562
+ mask &= (self._catalog["n_conifolds"] <= n_conifolds_max).values
1563
+ if has_gv is not None:
1355
1564
  mask &= (self._catalog["has_gv"] == has_gv).values
1356
- if D3_tadpole_max is not None and "D3_tadpole" in self._catalog.columns:
1565
+ if D3_tadpole_max is not None:
1357
1566
  mask &= (self._catalog["D3_tadpole"] <= D3_tadpole_max).values
1358
1567
  for col, val in filters.items():
1359
1568
  if col in self._catalog.columns:
@@ -1371,14 +1580,13 @@ class CYDatabase:
1371
1580
  ) -> Dict[str, Any]:
1372
1581
  r"""
1373
1582
  **Description:**
1374
- Fetch the polytope data for a model identified by ``(h11, ks_id)``,
1375
- optionally disambiguated by ``h12``.
1583
+ Fetch the polytope data for a model identified by ``(h11, ks_id)``.
1376
1584
 
1377
1585
  Polytope data is stored per-polytope (not per-triangulation), so
1378
1586
  ``triang_id`` is not required: every triangulation of the same
1379
- polytope shares one row in the ``polytope`` parquet split. When
1380
- multiple polytopes share the same ``(h11, ks_id)`` (which is rare),
1381
- pass ``h12`` to disambiguate.
1587
+ polytope shares one row in the ``polytope`` parquet split.
1588
+ ``(h11, ks_id)`` identifies a polytope uniquely; ``h12`` is accepted
1589
+ as an extra check.
1382
1590
 
1383
1591
  Args:
1384
1592
  ks_id (int): Kreuzer-Skarke polytope index.
@@ -1396,6 +1604,8 @@ class CYDatabase:
1396
1604
  catalog has no ``polytope`` split, or the matching row has
1397
1605
  no polytope shard pointer.
1398
1606
  KeyError: If no row matches the supplied filters.
1607
+ CatalogMismatchError: If the fetched polytope row carries a
1608
+ different key than the catalogue entry that points to it.
1399
1609
  """
1400
1610
  if self.dataset != "tdf":
1401
1611
  raise ValueError(
@@ -1442,7 +1652,9 @@ class CYDatabase:
1442
1652
  poly_row = poly_shard.iloc[int(prid)]
1443
1653
  else:
1444
1654
  poly_row = self._fetch_row("polytope", int(psid), int(prid))
1445
-
1655
+ _check_row_key(poly_row, {"ks_id": row.get("ks_id"), "h11": row.get("h11")},
1656
+ f"polytope shard {int(psid)} row {int(prid)}")
1657
+
1446
1658
  poly_data = _parse_polytope_row(poly_row)
1447
1659
  points = poly_data["polytope_points"] # np.ndarray
1448
1660
  points = np.array([list(x) for x in points])
@@ -1652,7 +1864,7 @@ class CICYDatabase(CYDatabase):
1652
1864
  Example usage::
1653
1865
 
1654
1866
  db = CICYDatabase()
1655
- rows = db.query(h11=1)
1867
+ rows = db.query(h12=1) # the stored h12 is h^{1,1}(X): the catalogue is mirror-convention
1656
1868
  """
1657
1869
 
1658
1870
  # Consumed by :meth:`CYDatabase.from_local` so that
@@ -1721,6 +1933,10 @@ def query_models(
1721
1933
 
1722
1934
  Returns:
1723
1935
  pandas.DataFrame: Matching rows from the catalog.
1936
+
1937
+ Raises:
1938
+ ValueError: If a named filter is given whose catalogue column is
1939
+ absent (see :meth:`CYDatabase.query`).
1724
1940
  """
1725
1941
  db = CYDatabase(dataset=dataset, cache_dir=cache_dir)
1726
1942
  return db.query(
@@ -1802,7 +2018,7 @@ __all__ = [
1802
2018
  # ----- constants & exceptions --------------------------------------------
1803
2019
  "HF_REPO_ID", "DEFAULT_CACHE_DIR", "VAULT_DIRNAME", "DEFAULT_VAULT_REPO",
1804
2020
  "SCHEMA_VERSION", "SCHEMA_CHANGELOG",
1805
- "SchemaVersionError", "ValidationError",
2021
+ "SchemaVersionError", "ValidationError", "CatalogMismatchError",
1806
2022
  # ----- parsing helpers ---------------------------------------------------
1807
2023
  "_decode_array", "_parse_gv_row", "_parse_conifold_rows", "_parse_polytope_row",
1808
2024
  # ----- classes -----------------------------------------------------------
@@ -545,8 +545,8 @@ class ToricCYPhase(CYPhase):
545
545
  - ``h12`` is **not** needed for identification. ``ks_id`` is the *global per-h11* KS
546
546
  emission index, so it is already unique within an ``h11`` (audited: ``#unique ks_id ==
547
547
  #rows`` in every built bucket, e.g. 568 078/568 078 at ``h11=10``), and ``h12`` is a
548
- *function* of ``(h11, ks_id)``. Do not confuse it with the *within-Hodge-pair* index
549
- used by some other tooling (``hash_database``'s ``KS_index``), which does need both:
548
+ *function* of ``(h11, ks_id)``. Do not confuse it with a *within-Hodge-pair* index
549
+ (a ``KS_index`` counted within one ``(h11, h12)``), which does need both:
550
550
  ``global ks_id = offset(h12) + within-pair index``. If you pass ``h12`` it is used as
551
551
  a **cross-check** and a mismatch raises, which is the useful thing it can do here.
552
552