pyruleanalyzer 2.1.1__tar.gz → 2.1.2__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 (71) hide show
  1. {pyruleanalyzer-2.1.1/pyruleanalyzer.egg-info → pyruleanalyzer-2.1.2}/PKG-INFO +2 -2
  2. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/README.md +1 -1
  3. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/pyproject.toml +1 -1
  4. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/pyruleanalyzer/cpn_mutants.py +6 -2
  5. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2/pyruleanalyzer.egg-info}/PKG-INFO +2 -2
  6. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/tests/test_cpn_profile.py +31 -0
  7. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/LICENSE +0 -0
  8. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/pyruleanalyzer/__init__.py +0 -0
  9. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/pyruleanalyzer/_accel.py +0 -0
  10. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/pyruleanalyzer/_arrays.py +0 -0
  11. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/pyruleanalyzer/_binary_format.py +0 -0
  12. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/pyruleanalyzer/_c_export.py +0 -0
  13. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/pyruleanalyzer/_engine.py +0 -0
  14. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/pyruleanalyzer/_extraction.py +0 -0
  15. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/pyruleanalyzer/_labels.py +0 -0
  16. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/pyruleanalyzer/_native_python.py +0 -0
  17. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/pyruleanalyzer/_pycodegen.py +0 -0
  18. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/pyruleanalyzer/_refinement.py +0 -0
  19. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/pyruleanalyzer/_reporting.py +0 -0
  20. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/pyruleanalyzer/_rules.py +0 -0
  21. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/pyruleanalyzer/_serialization.py +0 -0
  22. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/pyruleanalyzer/_tree_traversal.c +0 -0
  23. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/pyruleanalyzer/compositional.py +0 -0
  24. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/pyruleanalyzer/cpn_profile.py +0 -0
  25. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/pyruleanalyzer/cpn_semantics.py +0 -0
  26. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/pyruleanalyzer/cpn_statespace.py +0 -0
  27. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/pyruleanalyzer/cpn_tools_exporter.py +0 -0
  28. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/pyruleanalyzer/cpntools_oracle.py +0 -0
  29. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/pyruleanalyzer/dt_analyzer.py +0 -0
  30. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/pyruleanalyzer/exporters.py +0 -0
  31. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/pyruleanalyzer/footprint.py +0 -0
  32. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/pyruleanalyzer/full_pipeline.py +0 -0
  33. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/pyruleanalyzer/gbdt_analyzer.py +0 -0
  34. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/pyruleanalyzer/model_checker.py +0 -0
  35. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/pyruleanalyzer/pyruleanalyzer.py +0 -0
  36. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/pyruleanalyzer/rf_analyzer.py +0 -0
  37. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/pyruleanalyzer/rule_classifier.py +0 -0
  38. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/pyruleanalyzer/verified_pipeline.py +0 -0
  39. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/pyruleanalyzer.egg-info/SOURCES.txt +0 -0
  40. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/pyruleanalyzer.egg-info/dependency_links.txt +0 -0
  41. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/pyruleanalyzer.egg-info/entry_points.txt +0 -0
  42. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/pyruleanalyzer.egg-info/requires.txt +0 -0
  43. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/pyruleanalyzer.egg-info/top_level.txt +0 -0
  44. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/setup.cfg +0 -0
  45. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/setup.py +0 -0
  46. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/tests/test_cheap_fixes.py +0 -0
  47. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/tests/test_compositional.py +0 -0
  48. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/tests/test_coverage_and_precision.py +0 -0
  49. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/tests/test_cpn_export.py +0 -0
  50. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/tests/test_cpn_profile_counterexamples.py +0 -0
  51. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/tests/test_cpn_profile_generic.py +0 -0
  52. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/tests/test_cpn_profile_oracle.py +0 -0
  53. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/tests/test_cpn_profile_reduction.py +0 -0
  54. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/tests/test_cpn_profile_structural.py +0 -0
  55. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/tests/test_cpn_safe_eval.py +0 -0
  56. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/tests/test_dt_invariants.py +0 -0
  57. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/tests/test_engine_hardening.py +0 -0
  58. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/tests/test_footprint.py +0 -0
  59. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/tests/test_full_pipeline.py +0 -0
  60. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/tests/test_gbdt_invariants.py +0 -0
  61. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/tests/test_json_serialization.py +0 -0
  62. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/tests/test_labels_and_nan.py +0 -0
  63. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/tests/test_model_checker.py +0 -0
  64. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/tests/test_predict_batch.py +0 -0
  65. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/tests/test_refinement_v2.py +0 -0
  66. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/tests/test_regressions.py +0 -0
  67. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/tests/test_rf_invariants.py +0 -0
  68. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/tests/test_rule_fidelity.py +0 -0
  69. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/tests/test_sklearn_api.py +0 -0
  70. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/tests/test_usage_engine.py +0 -0
  71. {pyruleanalyzer-2.1.1 → pyruleanalyzer-2.1.2}/tests/test_verified_pipeline_gate.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyruleanalyzer
3
- Version: 2.1.1
3
+ Version: 2.1.2
4
4
  Summary: Extract, refine and formally verify the rules of scikit-learn decision trees, random forests and gradient boosting, and export them as standalone Python, C and Arduino classifiers
5
5
  Author: GrupoCybersegurancaVirtus
6
6
  License-Expression: MIT
@@ -960,7 +960,7 @@ cd docs && make html
960
960
 
961
961
  ## Status
962
962
 
963
- Version 2.1.1; [CHANGELOG.md](https://github.com/GrupoCybersegurancaVirtus/pyruleanalyzer/blob/main/CHANGELOG.md)
963
+ Version 2.1.2; [CHANGELOG.md](https://github.com/GrupoCybersegurancaVirtus/pyruleanalyzer/blob/main/CHANGELOG.md)
964
964
  says what changed. The figures on this page are drawn from real runs by
965
965
  [`docs/figures/make_figures.py`](https://github.com/GrupoCybersegurancaVirtus/pyruleanalyzer/blob/main/docs/figures/make_figures.py).
966
966
 
@@ -918,7 +918,7 @@ cd docs && make html
918
918
 
919
919
  ## Status
920
920
 
921
- Version 2.1.1; [CHANGELOG.md](https://github.com/GrupoCybersegurancaVirtus/pyruleanalyzer/blob/main/CHANGELOG.md)
921
+ Version 2.1.2; [CHANGELOG.md](https://github.com/GrupoCybersegurancaVirtus/pyruleanalyzer/blob/main/CHANGELOG.md)
922
922
  says what changed. The figures on this page are drawn from real runs by
923
923
  [`docs/figures/make_figures.py`](https://github.com/GrupoCybersegurancaVirtus/pyruleanalyzer/blob/main/docs/figures/make_figures.py).
924
924
 
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
5
5
 
6
6
  [project]
7
7
  name = "pyruleanalyzer"
8
- version = "2.1.1"
8
+ version = "2.1.2"
9
9
  description = "Extract, refine and formally verify the rules of scikit-learn decision trees, random forests and gradient boosting, and export them as standalone Python, C and Arduino classifiers"
10
10
  authors = [{ name = "GrupoCybersegurancaVirtus" }]
11
11
  readme = "README.md"
@@ -227,10 +227,14 @@ def _double_output(doc: CPNDocument, info) -> bool:
227
227
 
228
228
  # Function to deposit a label outside the domain (A6).
229
229
  def _bad_label(doc: CPNDocument, info) -> bool:
230
+ # One past the largest class the correct net can predict; a fixed label
231
+ # such as 7 is a valid class of any model with eight or more classes.
232
+ known = list(info.get("labels") or []) + list(info.get("prediction") or [])
233
+ bad = max(known) + 1 if info.get("labels") else max(known + [0]) + 1_000_000
230
234
  page, name = info["producer_page"], info["producer"]
231
235
  for arc in doc.arcs(page, name, "TtoP"):
232
236
  if doc.place_of(page, arc) == "Prediction":
233
- doc.set_inscription(arc, "7")
237
+ doc.set_inscription(arc, str(bad))
234
238
  return True
235
239
 
236
240
 
@@ -373,7 +377,7 @@ TREE_MUTANTS: List[Mutant] = [
373
377
  "dormant leaf always enabled, produces nothing", _dead_branch),
374
378
  Mutant("double_output", ("A5", "A7"), _ALL,
375
379
  "prediction deposited twice", _double_output),
376
- Mutant("bad_label", ("A6",), _ALL, "prediction replaced by label 7", _bad_label),
380
+ Mutant("bad_label", ("A6",), _ALL, "prediction replaced by a label outside the domain", _bad_label),
377
381
  Mutant("overlap", ("B1", "B4"), _ALL,
378
382
  "dormant leaf enabled next to the live one", _overlap),
379
383
  Mutant("hidden_overlap", ("B4",), _ALL,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyruleanalyzer
3
- Version: 2.1.1
3
+ Version: 2.1.2
4
4
  Summary: Extract, refine and formally verify the rules of scikit-learn decision trees, random forests and gradient boosting, and export them as standalone Python, C and Arduino classifiers
5
5
  Author: GrupoCybersegurancaVirtus
6
6
  License-Expression: MIT
@@ -960,7 +960,7 @@ cd docs && make html
960
960
 
961
961
  ## Status
962
962
 
963
- Version 2.1.1; [CHANGELOG.md](https://github.com/GrupoCybersegurancaVirtus/pyruleanalyzer/blob/main/CHANGELOG.md)
963
+ Version 2.1.2; [CHANGELOG.md](https://github.com/GrupoCybersegurancaVirtus/pyruleanalyzer/blob/main/CHANGELOG.md)
964
964
  says what changed. The figures on this page are drawn from real runs by
965
965
  [`docs/figures/make_figures.py`](https://github.com/GrupoCybersegurancaVirtus/pyruleanalyzer/blob/main/docs/figures/make_figures.py).
966
966
 
@@ -87,3 +87,34 @@ def test_the_askctl_script_is_written(tmp_path):
87
87
  decl, queries = mc.ml_program()
88
88
  assert set(queries) <= set(mc.check().oracle)
89
89
  assert "EXIST_UNTIL" in text or "EV(" in text
90
+
91
+
92
+ class _StubDoc:
93
+ """Records the label bad_label writes on the producer's Prediction arc."""
94
+
95
+ def __init__(self):
96
+ self.written = None
97
+
98
+ def arcs(self, page, name, direction):
99
+ return ["a1"]
100
+
101
+ def place_of(self, page, arc):
102
+ return "Prediction"
103
+
104
+ def set_inscription(self, arc, text):
105
+ self.written = text
106
+
107
+
108
+ @pytest.mark.parametrize("labels,prediction,expected", [
109
+ (list(range(8)), [3], "8"), # 7 would be a valid class here
110
+ (list(range(19)), [7], "19"),
111
+ ([], [2], str(2 + 1_000_000)), # no constant domain (forests)
112
+ ])
113
+ def test_bad_label_writes_a_label_outside_the_domain(labels, prediction, expected):
114
+ from pyruleanalyzer.cpn_mutants import _bad_label
115
+ doc = _StubDoc()
116
+ info = {"labels": labels, "prediction": prediction,
117
+ "producer_page": "Top", "producer": "Decide_3"}
118
+ assert _bad_label(doc, info)
119
+ assert doc.written == expected
120
+ assert labels == [] or int(doc.written) not in labels
File without changes
File without changes
File without changes