nickh007 commited on
Commit
ef4acbc
·
verified ·
1 Parent(s): 0f966db

Documentation a newcomer actually needs

Browse files
Files changed (1) hide show
  1. tests/test_conformance.py +45 -0
tests/test_conformance.py CHANGED
@@ -230,3 +230,48 @@ def test_readme_flags_the_one_figure_it_cannot_reproduce():
230
  net = read_touchstone(str(HERE / "data" / "passive_resonator.s2p"))
231
  sigma = float(np.max(np.linalg.svd(net.s, compute_uv=False)))
232
  assert sigma <= 1.0 + 1e-9, f"shipped resonator is not passive: {sigma}"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
230
  net = read_touchstone(str(HERE / "data" / "passive_resonator.s2p"))
231
  sigma = float(np.max(np.linalg.svd(net.s, compute_uv=False)))
232
  assert sigma <= 1.0 + 1e-9, f"shipped resonator is not passive: {sigma}"
233
+
234
+
235
+ # ------------------------------------- an unreported law must not be a pass
236
+
237
+ def _score_with(fn):
238
+ from score import load_manifest, score
239
+ return score(fn, load_manifest())
240
+
241
+
242
+ def test_a_checker_that_omits_a_law_is_incomplete_not_conforming():
243
+ """The corpus cannot certify a law the checker never reported."""
244
+ from sparam_lint_adapter import check as complete
245
+
246
+ def missing_passivity(path):
247
+ return {k: v for k, v in complete(path).items() if k != "passivity"}
248
+
249
+ full = _score_with(complete)
250
+ assert full["verdict"] == "CONFORMING" and full["passed"]
251
+ assert full["n_missing"] == 0
252
+
253
+ partial = _score_with(missing_passivity)
254
+ assert partial["false_pass"] == 0, "the omission is not a false pass"
255
+ assert partial["n_missing"] == full["n_cases"], "one law short on every case"
256
+ assert partial["verdict"] == "INCOMPLETE", (
257
+ "a checker missing a whole law was told it conforms"
258
+ )
259
+ assert not partial["passed"], "INCOMPLETE must not exit 0"
260
+
261
+
262
+ def test_a_false_pass_still_outranks_incompleteness():
263
+ """Admitting a non-physical network is the worse failure and keeps its name."""
264
+ def permissive_and_partial(path):
265
+ return {"reciprocity": True, "energy_conservation": True,
266
+ "positive_real_z0": True, "group_delay_nonneg": True,
267
+ "passivity": True} # passes everything, including the violators
268
+
269
+ r = _score_with(permissive_and_partial)
270
+ assert r["false_pass"] > 0
271
+ assert r["verdict"] == "NOT CONFORMING"
272
+
273
+
274
+ def test_readme_verdict_table_matches_the_scorer():
275
+ readme = (HERE / "README.md").read_text(encoding="utf-8")
276
+ for verdict in ("CONFORMING", "INCOMPLETE", "NOT CONFORMING"):
277
+ assert f"`{verdict}`" in readme, f"README does not document the {verdict} verdict"