testmechs 0.1.0__py3-none-any.whl
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.
- testmechs/__init__.py +395 -0
- testmechs/_json_io.py +69 -0
- testmechs/bounds.py +3224 -0
- testmechs/contracts.py +2661 -0
- testmechs/empirical.py +1089 -0
- testmechs/monte_carlo.py +19744 -0
- testmechs/parity.py +777 -0
- testmechs/partial_density.py +2204 -0
- testmechs/preprocess.py +783 -0
- testmechs/regression.py +1448 -0
- testmechs/reproduction.py +5030 -0
- testmechs/resources/__init__.py +447 -0
- testmechs/resources/fixtures/__init__.py +1 -0
- testmechs/resources/fixtures/baranov_mother_data.csv +904 -0
- testmechs/resources/fixtures/burstzyn_data.csv +376 -0
- testmechs/resources/fixtures/kerwin_data.csv +946 -0
- testmechs/resources/statistics/__init__.py +1 -0
- testmechs/resources/statistics/baranov-alt-grandmother-cs-pval.tex +1 -0
- testmechs/resources/statistics/baranov-alt-grandmother-percent-nts-affected.tex +1 -0
- testmechs/resources/statistics/baranov-both-cs-pval.tex +1 -0
- testmechs/resources/statistics/baranov-both-tv-all-percent.tex +1 -0
- testmechs/resources/statistics/baranov-grandmother-cs-pval.tex +1 -0
- testmechs/resources/statistics/baranov-grandmother-min-defiers-percent.tex +1 -0
- testmechs/resources/statistics/baranov-grandmother-min-defiers-ratio.tex +1 -0
- testmechs/resources/statistics/baranov-grandmother-percent-nts-affected.tex +1 -0
- testmechs/resources/statistics/baranov-relationship-at-bounds-all-percent.tex +1 -0
- testmechs/resources/statistics/baranov-relationship-cs-pval.tex +1 -0
- testmechs/resources/statistics/baranov-relationship-diff-cdf-4-pval.tex +1 -0
- testmechs/resources/statistics/baranov-relationship-diff-cdf-4.tex +1 -0
- testmechs/resources/statistics/baranov-relationship-max-defiers-percent.tex +1 -0
- testmechs/resources/statistics/baranov-sample-size-both.tex +1 -0
- testmechs/resources/statistics/baranov-sample-size-grandmother.tex +1 -0
- testmechs/resources/statistics/burstzyn-ate-restricted-sample.tex +1 -0
- testmechs/resources/statistics/burstzyn-cs-pval-restricted-sample.tex +1 -0
- testmechs/resources/statistics/burstzyn-lee-bounds-lb-nts-full-sample.tex +1 -0
- testmechs/resources/statistics/burstzyn-lee-bounds-lb-nts-restricted-sample.tex +1 -0
- testmechs/resources/statistics/burstzyn-lee-bounds-ub-nts-full-sample.tex +1 -0
- testmechs/resources/statistics/burstzyn-lee-bounds-ub-nts-restricted-sample.tex +1 -0
- testmechs/resources/statistics/burstzyn-min-defier-fraction-restricted-sample.tex +1 -0
- testmechs/resources/statistics/burstzyn-min-defier-percent-full-sample.tex +1 -0
- testmechs/resources/statistics/burstzyn-min-defier-percent-restricted-sample.tex +1 -0
- testmechs/resources/statistics/burstzyn-min-defier-ratio-restricted-sample.tex +1 -0
- testmechs/resources/statistics/burstzyn-percent-nts-affected-full-sample.tex +1 -0
- testmechs/resources/statistics/burstzyn-percent-nts-affected-restricted-sample.tex +1 -0
- testmechs/resources/statistics/burstzyn-percent-wedge-negative.tex +1 -0
- testmechs/resources/statistics/burstzyn-sample-size-treated-wedge-negative.tex +1 -0
- testmechs/resources/statistics/burstzyn-sample-size-wedge-negative.tex +1 -0
- testmechs/resources/tables/__init__.py +1 -0
- testmechs/resources/tables/appendix_table1.tex +54 -0
- testmechs/resources/tables/appendix_table2.tex +56 -0
- testmechs/resources/tables/clustered_cell_count.tex +33 -0
- testmechs/resources/tables/pvals-table-dif-bins.tex +12 -0
- testmechs/resources/tables/pvals-table.tex +13 -0
- testmechs/resources/tables/table1.tex +44 -0
- testmechs/resources/tables/table2.tex +34 -0
- testmechs/results.py +1137 -0
- testmechs/sharp_null.py +4844 -0
- testmechs-0.1.0.dist-info/METADATA +450 -0
- testmechs-0.1.0.dist-info/RECORD +62 -0
- testmechs-0.1.0.dist-info/WHEEL +5 -0
- testmechs-0.1.0.dist-info/licenses/LICENSE.md +235 -0
- testmechs-0.1.0.dist-info/top_level.txt +1 -0
testmechs/__init__.py
ADDED
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
"""Public contracts for the TestMechs Python package."""
|
|
2
|
+
|
|
3
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
4
|
+
from importlib import import_module
|
|
5
|
+
|
|
6
|
+
try:
|
|
7
|
+
__version__ = version("testmechs")
|
|
8
|
+
except PackageNotFoundError:
|
|
9
|
+
__version__ = "0.1.0"
|
|
10
|
+
|
|
11
|
+
__all__ = [
|
|
12
|
+
"__version__",
|
|
13
|
+
"ADEBoundsRequest",
|
|
14
|
+
"ADEBoundsResult",
|
|
15
|
+
"AdjustedMediatorMassResult",
|
|
16
|
+
"AdjustedProbabilityInfluenceResult",
|
|
17
|
+
"AdjustedProbabilityResult",
|
|
18
|
+
"BinaryCSMonteCarloDesign",
|
|
19
|
+
"BinaryEmpiricalMixtureBenchmarkDataSource",
|
|
20
|
+
"BinaryEmpiricalMixtureMonteCarloDesign",
|
|
21
|
+
"BinaryPartialDensityMonteCarloDesign",
|
|
22
|
+
"BreakdownDefierShareRequest",
|
|
23
|
+
"BoundsSupport",
|
|
24
|
+
"CellCountDiagnosticsSupport",
|
|
25
|
+
"ClusterCellCount",
|
|
26
|
+
"MonteCarloBlockedBenchmarkRow",
|
|
27
|
+
"MonteCarloBenchmarkCell",
|
|
28
|
+
"MonteCarloBenchmarkDataSourceDiagnostic",
|
|
29
|
+
"LowerBoundResult",
|
|
30
|
+
"LowerBoundRequest",
|
|
31
|
+
"MonteCarloBenchmarkDiagnostic",
|
|
32
|
+
"MonteCarloBenchmarkMatrixResult",
|
|
33
|
+
"MonteCarloCellCountHeuristic",
|
|
34
|
+
"MonteCarloBenchmarkPlan",
|
|
35
|
+
"MonteCarloBenchmarkPlanReadinessReport",
|
|
36
|
+
"MonteCarloBenchmarkPlanRerunCell",
|
|
37
|
+
"MonteCarloBenchmarkPlanRerunManifest",
|
|
38
|
+
"MonteCarloBenchmarkPlanRunResult",
|
|
39
|
+
"MonteCarloBenchmarkSuiteReadinessReport",
|
|
40
|
+
"MonteCarloBenchmarkSuiteRunResult",
|
|
41
|
+
"MonteCarloContracts",
|
|
42
|
+
"MonteCarloDrawResult",
|
|
43
|
+
"MonteCarloMethodExecutionContract",
|
|
44
|
+
"MonteCarloMethodGuidance",
|
|
45
|
+
"MonteCarloResultRow",
|
|
46
|
+
"MonteCarloSizeDiagnostic",
|
|
47
|
+
"MonteCarloSimulationResult",
|
|
48
|
+
"PaperMonteCarloReproductionReport",
|
|
49
|
+
"PartialDensityDataResult",
|
|
50
|
+
"PartialDensityRequest",
|
|
51
|
+
"PartialDensitySupport",
|
|
52
|
+
"PaperEmpiricalReproductionReport",
|
|
53
|
+
"PaperEmpiricalReproductionRequest",
|
|
54
|
+
"PaperMonteCarloReproductionRequest",
|
|
55
|
+
"PaperReproductionComparisonReport",
|
|
56
|
+
"PaperReproductionComparisonRequest",
|
|
57
|
+
"PaperReproductionE2EReport",
|
|
58
|
+
"PaperReproductionE2ERequest",
|
|
59
|
+
"PaperReproductionResource",
|
|
60
|
+
"PaperReproductionResourceManifestRequest",
|
|
61
|
+
"PaperReproductionResourceManifestPacket",
|
|
62
|
+
"RegressionAdjustmentSupport",
|
|
63
|
+
"RegressionFormulaSpec",
|
|
64
|
+
"SharedCSVInput",
|
|
65
|
+
"SharpNullRequest",
|
|
66
|
+
"SharpNullResult",
|
|
67
|
+
"TVConfidenceIntervalResult",
|
|
68
|
+
"SharpNullDiagnosticsSupport",
|
|
69
|
+
"bounds_ade_ats",
|
|
70
|
+
"breakdown_defier_share",
|
|
71
|
+
"build_python_fixture_summary",
|
|
72
|
+
"build_cell_count_diagnostics",
|
|
73
|
+
"bounds_diagnostic_schema_frame",
|
|
74
|
+
"bounds_support_contract",
|
|
75
|
+
"bounds_support_frame",
|
|
76
|
+
"cell_count_diagnostics_support_contract",
|
|
77
|
+
"cell_count_diagnostics_support_frame",
|
|
78
|
+
"ci_TV",
|
|
79
|
+
"compute_positive_part_partial_pmf_diff",
|
|
80
|
+
"compute_adjusted_mediator_masses",
|
|
81
|
+
"compute_adjusted_probability_influences",
|
|
82
|
+
"compute_adjusted_probabilities",
|
|
83
|
+
"discretize_y",
|
|
84
|
+
"diff_fixture_summaries",
|
|
85
|
+
"lb_frac_affected",
|
|
86
|
+
"load_paper_monte_carlo_reproduction_report_json",
|
|
87
|
+
"load_monte_carlo_suite_run_result_json",
|
|
88
|
+
"load_paper_empirical_mixture_benchmark_data_sources",
|
|
89
|
+
"load_paper_monte_carlo_contracts",
|
|
90
|
+
"load_paper_reproduction_resource_manifest_json",
|
|
91
|
+
"load_paper_reproduction_resource_manifest_packet_json",
|
|
92
|
+
"milestone_audit_status_for_version",
|
|
93
|
+
"milestone_audit_status_from_file",
|
|
94
|
+
"paper_monte_carlo_reproduction_display_frame",
|
|
95
|
+
"paper_monte_carlo_reproduction_report",
|
|
96
|
+
"paper_monte_carlo_reproduction_report_frame",
|
|
97
|
+
"summarize_paper_empirical_mixture_benchmark_suite_archive_blocker_packet",
|
|
98
|
+
"summarize_paper_empirical_mixture_benchmark_suite_archive_gate",
|
|
99
|
+
"raise_for_milestone_archive_blockers",
|
|
100
|
+
"raise_for_paper_empirical_mixture_benchmark_suite_archive_blockers",
|
|
101
|
+
"partial_density_data",
|
|
102
|
+
"partial_density_diagnostic_schema_frame",
|
|
103
|
+
"partial_density_plot",
|
|
104
|
+
"partial_density_support_contract",
|
|
105
|
+
"partial_density_support_frame",
|
|
106
|
+
"parse_reg_formula",
|
|
107
|
+
"paper_empirical_reproduction_display_frame",
|
|
108
|
+
"paper_empirical_reproduction_report",
|
|
109
|
+
"paper_empirical_reproduction_report_frame",
|
|
110
|
+
"paper_reproduction_comparison_display_frame",
|
|
111
|
+
"paper_reproduction_comparison_report",
|
|
112
|
+
"paper_reproduction_comparison_report_frame",
|
|
113
|
+
"paper_reproduction_e2e_display_frame",
|
|
114
|
+
"paper_reproduction_e2e_report",
|
|
115
|
+
"paper_reproduction_e2e_report_frame",
|
|
116
|
+
"paper_reproduction_resource_manifest",
|
|
117
|
+
"paper_reproduction_resource_manifest_frame",
|
|
118
|
+
"paper_reproduction_resource_manifest_packet",
|
|
119
|
+
"remove_missing_from_df",
|
|
120
|
+
"run_r_bounds_ade_ats_case",
|
|
121
|
+
"run_r_fixture_summary",
|
|
122
|
+
"run_r_lb_frac_affected_case",
|
|
123
|
+
"run_r_sharp_null_arp_case",
|
|
124
|
+
"run_r_sharp_null_cr_case",
|
|
125
|
+
"run_r_simulate_data_binary_m_contract",
|
|
126
|
+
"run_r_sharp_null_cs_case",
|
|
127
|
+
"run_binary_cs_monte_carlo",
|
|
128
|
+
"run_binary_empirical_mixture_cs_benchmark_focused_probe",
|
|
129
|
+
"run_binary_empirical_mixture_cs_benchmark_matrix",
|
|
130
|
+
"run_binary_empirical_mixture_cs_benchmark_manifest",
|
|
131
|
+
"run_binary_empirical_mixture_cs_benchmark_plan",
|
|
132
|
+
"run_binary_empirical_mixture_cs_benchmark_plan_by_source",
|
|
133
|
+
"run_binary_empirical_mixture_cs_monte_carlo",
|
|
134
|
+
"run_binary_partial_density_cs_monte_carlo",
|
|
135
|
+
"run_empirical_mixture_arp_benchmark_manifest",
|
|
136
|
+
"run_empirical_mixture_benchmark_focused_probe",
|
|
137
|
+
"run_empirical_mixture_benchmark_manifest",
|
|
138
|
+
"run_empirical_mixture_benchmark_plan_by_source",
|
|
139
|
+
"run_empirical_mixture_fsstdd_benchmark_manifest",
|
|
140
|
+
"run_empirical_mixture_fsstndd_benchmark_manifest",
|
|
141
|
+
"run_empirical_mixture_k_benchmark_manifest",
|
|
142
|
+
"run_empirical_mixture_cs_benchmark_focused_probe",
|
|
143
|
+
"run_empirical_mixture_cs_benchmark_matrix",
|
|
144
|
+
"run_empirical_mixture_cs_benchmark_manifest",
|
|
145
|
+
"run_empirical_mixture_cs_benchmark_plan",
|
|
146
|
+
"run_empirical_mixture_cs_benchmark_plan_by_source",
|
|
147
|
+
"run_nonbinary_empirical_mixture_cs_monte_carlo",
|
|
148
|
+
"write_monte_carlo_suite_run_result_json",
|
|
149
|
+
"write_merged_monte_carlo_suite_run_result_json",
|
|
150
|
+
"write_paper_monte_carlo_reproduction_report_json",
|
|
151
|
+
"write_paper_reproduction_comparison_report_json",
|
|
152
|
+
"write_paper_reproduction_e2e_report_json",
|
|
153
|
+
"write_paper_reproduction_resource_manifest_json",
|
|
154
|
+
"load_paper_reproduction_comparison_report_json",
|
|
155
|
+
"load_paper_reproduction_e2e_report_json",
|
|
156
|
+
"write_paper_empirical_mixture_benchmark_suite_evidence",
|
|
157
|
+
"write_next_paper_empirical_mixture_benchmark_suite_archive_evidence",
|
|
158
|
+
"run_paper_empirical_mixture_benchmark_suite_chunk",
|
|
159
|
+
"summarize_paper_empirical_mixture_benchmark_suite_evidence",
|
|
160
|
+
"regression_adjustment_support_contract",
|
|
161
|
+
"regression_adjustment_support_frame",
|
|
162
|
+
"sharp_null_diagnostic_schema_frame",
|
|
163
|
+
"sharp_null_diagnostics_support_contract",
|
|
164
|
+
"sharp_null_diagnostics_support_frame",
|
|
165
|
+
"test_sharp_null_cr",
|
|
166
|
+
"test_sharp_null",
|
|
167
|
+
"theta_kk_min_ordered_monotone",
|
|
168
|
+
"write_next_paper_empirical_mixture_benchmark_suite_chunk_evidence",
|
|
169
|
+
"write_paper_empirical_mixture_benchmark_suite_chunk_evidence",
|
|
170
|
+
]
|
|
171
|
+
|
|
172
|
+
_EXPORT_MODULES = {
|
|
173
|
+
"ADEBoundsResult": "results",
|
|
174
|
+
"LowerBoundResult": "results",
|
|
175
|
+
"SharpNullResult": "results",
|
|
176
|
+
"TVConfidenceIntervalResult": "results",
|
|
177
|
+
"bounds_ade_ats": "bounds",
|
|
178
|
+
"breakdown_defier_share": "bounds",
|
|
179
|
+
"compute_positive_part_partial_pmf_diff": "bounds",
|
|
180
|
+
"lb_frac_affected": "bounds",
|
|
181
|
+
"theta_kk_min_ordered_monotone": "bounds",
|
|
182
|
+
"ADEBoundsRequest": "contracts",
|
|
183
|
+
"BreakdownDefierShareRequest": "contracts",
|
|
184
|
+
"BoundsSupport": "contracts",
|
|
185
|
+
"CellCountDiagnosticsSupport": "contracts",
|
|
186
|
+
"LowerBoundRequest": "contracts",
|
|
187
|
+
"PartialDensityRequest": "contracts",
|
|
188
|
+
"PartialDensitySupport": "contracts",
|
|
189
|
+
"PaperEmpiricalReproductionRequest": "contracts",
|
|
190
|
+
"PaperMonteCarloReproductionRequest": "contracts",
|
|
191
|
+
"PaperReproductionComparisonRequest": "contracts",
|
|
192
|
+
"PaperReproductionE2ERequest": "contracts",
|
|
193
|
+
"PaperReproductionResourceManifestRequest": "contracts",
|
|
194
|
+
"RegressionAdjustmentSupport": "contracts",
|
|
195
|
+
"SharedCSVInput": "contracts",
|
|
196
|
+
"SharpNullDiagnosticsSupport": "contracts",
|
|
197
|
+
"SharpNullRequest": "contracts",
|
|
198
|
+
"bounds_diagnostic_schema_frame": "contracts",
|
|
199
|
+
"bounds_support_contract": "contracts",
|
|
200
|
+
"bounds_support_frame": "contracts",
|
|
201
|
+
"cell_count_diagnostics_support_contract": "contracts",
|
|
202
|
+
"cell_count_diagnostics_support_frame": "contracts",
|
|
203
|
+
"ci_TV": "sharp_null",
|
|
204
|
+
"partial_density_diagnostic_schema_frame": "contracts",
|
|
205
|
+
"partial_density_support_contract": "contracts",
|
|
206
|
+
"partial_density_support_frame": "contracts",
|
|
207
|
+
"regression_adjustment_support_contract": "contracts",
|
|
208
|
+
"regression_adjustment_support_frame": "contracts",
|
|
209
|
+
"sharp_null_diagnostic_schema_frame": "contracts",
|
|
210
|
+
"sharp_null_diagnostics_support_contract": "contracts",
|
|
211
|
+
"sharp_null_diagnostics_support_frame": "contracts",
|
|
212
|
+
"test_sharp_null_cr": "sharp_null",
|
|
213
|
+
"PaperEmpiricalReproductionReport": "empirical",
|
|
214
|
+
"paper_empirical_reproduction_display_frame": "empirical",
|
|
215
|
+
"paper_empirical_reproduction_report": "empirical",
|
|
216
|
+
"paper_empirical_reproduction_report_frame": "empirical",
|
|
217
|
+
"build_python_fixture_summary": "parity",
|
|
218
|
+
"diff_fixture_summaries": "parity",
|
|
219
|
+
"run_r_bounds_ade_ats_case": "parity",
|
|
220
|
+
"run_r_fixture_summary": "parity",
|
|
221
|
+
"run_r_lb_frac_affected_case": "parity",
|
|
222
|
+
"run_r_sharp_null_arp_case": "parity",
|
|
223
|
+
"run_r_sharp_null_cr_case": "parity",
|
|
224
|
+
"run_r_simulate_data_binary_m_contract": "parity",
|
|
225
|
+
"run_r_sharp_null_cs_case": "parity",
|
|
226
|
+
"PartialDensityDataResult": "partial_density",
|
|
227
|
+
"partial_density_data": "partial_density",
|
|
228
|
+
"partial_density_plot": "partial_density",
|
|
229
|
+
"build_cell_count_diagnostics": "preprocess",
|
|
230
|
+
"discretize_y": "preprocess",
|
|
231
|
+
"remove_missing_from_df": "preprocess",
|
|
232
|
+
"AdjustedMediatorMassResult": "regression",
|
|
233
|
+
"AdjustedProbabilityInfluenceResult": "regression",
|
|
234
|
+
"AdjustedProbabilityResult": "regression",
|
|
235
|
+
"RegressionFormulaSpec": "regression",
|
|
236
|
+
"compute_adjusted_mediator_masses": "regression",
|
|
237
|
+
"compute_adjusted_probability_influences": "regression",
|
|
238
|
+
"compute_adjusted_probabilities": "regression",
|
|
239
|
+
"parse_reg_formula": "regression",
|
|
240
|
+
"PaperReproductionComparisonReport": "reproduction",
|
|
241
|
+
"PaperReproductionE2EReport": "reproduction",
|
|
242
|
+
"load_paper_reproduction_comparison_report_json": "reproduction",
|
|
243
|
+
"load_paper_reproduction_e2e_report_json": "reproduction",
|
|
244
|
+
"paper_reproduction_comparison_display_frame": "reproduction",
|
|
245
|
+
"paper_reproduction_comparison_report": "reproduction",
|
|
246
|
+
"paper_reproduction_comparison_report_frame": "reproduction",
|
|
247
|
+
"paper_reproduction_e2e_display_frame": "reproduction",
|
|
248
|
+
"paper_reproduction_e2e_report": "reproduction",
|
|
249
|
+
"paper_reproduction_e2e_report_frame": "reproduction",
|
|
250
|
+
"write_paper_reproduction_comparison_report_json": "reproduction",
|
|
251
|
+
"write_paper_reproduction_e2e_report_json": "reproduction",
|
|
252
|
+
"PaperReproductionResource": "resources",
|
|
253
|
+
"PaperReproductionResourceManifestPacket": "resources",
|
|
254
|
+
"load_paper_reproduction_resource_manifest_json": "resources",
|
|
255
|
+
"load_paper_reproduction_resource_manifest_packet_json": "resources",
|
|
256
|
+
"paper_reproduction_resource_manifest": "resources",
|
|
257
|
+
"paper_reproduction_resource_manifest_frame": "resources",
|
|
258
|
+
"paper_reproduction_resource_manifest_packet": "resources",
|
|
259
|
+
"write_paper_reproduction_resource_manifest_json": "resources",
|
|
260
|
+
"test_sharp_null": "sharp_null",
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
_MONTE_CARLO_EXPORTS = {
|
|
264
|
+
"BinaryCSMonteCarloDesign",
|
|
265
|
+
"BinaryEmpiricalMixtureBenchmarkDataSource",
|
|
266
|
+
"BinaryEmpiricalMixtureMonteCarloDesign",
|
|
267
|
+
"BinaryPartialDensityMonteCarloDesign",
|
|
268
|
+
"ClusterCellCount",
|
|
269
|
+
"MonteCarloBlockedBenchmarkRow",
|
|
270
|
+
"MonteCarloBenchmarkCell",
|
|
271
|
+
"MonteCarloBenchmarkDataSourceDiagnostic",
|
|
272
|
+
"MonteCarloBenchmarkDiagnostic",
|
|
273
|
+
"MonteCarloBenchmarkMatrixResult",
|
|
274
|
+
"MonteCarloCellCountHeuristic",
|
|
275
|
+
"MonteCarloBenchmarkPlan",
|
|
276
|
+
"MonteCarloBenchmarkPlanReadinessReport",
|
|
277
|
+
"MonteCarloBenchmarkPlanRerunCell",
|
|
278
|
+
"MonteCarloBenchmarkPlanRerunManifest",
|
|
279
|
+
"MonteCarloBenchmarkPlanRunResult",
|
|
280
|
+
"MonteCarloBenchmarkSuiteReadinessReport",
|
|
281
|
+
"MonteCarloBenchmarkSuiteRunResult",
|
|
282
|
+
"MonteCarloContracts",
|
|
283
|
+
"MonteCarloDrawResult",
|
|
284
|
+
"MonteCarloMethodExecutionContract",
|
|
285
|
+
"MonteCarloMethodGuidance",
|
|
286
|
+
"MonteCarloResultRow",
|
|
287
|
+
"MonteCarloSizeDiagnostic",
|
|
288
|
+
"MonteCarloSimulationResult",
|
|
289
|
+
"PaperMonteCarloReproductionReport",
|
|
290
|
+
"load_paper_empirical_mixture_benchmark_data_sources",
|
|
291
|
+
"load_paper_monte_carlo_contracts",
|
|
292
|
+
"load_paper_monte_carlo_reproduction_report_json",
|
|
293
|
+
"load_monte_carlo_suite_run_result_json",
|
|
294
|
+
"milestone_audit_status_for_version",
|
|
295
|
+
"milestone_audit_status_from_file",
|
|
296
|
+
"paper_monte_carlo_reproduction_display_frame",
|
|
297
|
+
"paper_monte_carlo_reproduction_report",
|
|
298
|
+
"paper_monte_carlo_reproduction_report_frame",
|
|
299
|
+
"raise_for_milestone_archive_blockers",
|
|
300
|
+
"raise_for_paper_empirical_mixture_benchmark_suite_archive_blockers",
|
|
301
|
+
"run_binary_cs_monte_carlo",
|
|
302
|
+
"run_binary_empirical_mixture_cs_benchmark_focused_probe",
|
|
303
|
+
"run_binary_empirical_mixture_cs_benchmark_manifest",
|
|
304
|
+
"run_binary_empirical_mixture_cs_benchmark_matrix",
|
|
305
|
+
"run_binary_empirical_mixture_cs_benchmark_plan",
|
|
306
|
+
"run_binary_empirical_mixture_cs_benchmark_plan_by_source",
|
|
307
|
+
"run_binary_empirical_mixture_cs_monte_carlo",
|
|
308
|
+
"run_binary_partial_density_cs_monte_carlo",
|
|
309
|
+
"run_empirical_mixture_arp_benchmark_manifest",
|
|
310
|
+
"run_empirical_mixture_benchmark_focused_probe",
|
|
311
|
+
"run_empirical_mixture_benchmark_manifest",
|
|
312
|
+
"run_empirical_mixture_benchmark_plan_by_source",
|
|
313
|
+
"run_empirical_mixture_cs_benchmark_focused_probe",
|
|
314
|
+
"run_empirical_mixture_cs_benchmark_manifest",
|
|
315
|
+
"run_empirical_mixture_cs_benchmark_matrix",
|
|
316
|
+
"run_empirical_mixture_cs_benchmark_plan",
|
|
317
|
+
"run_empirical_mixture_cs_benchmark_plan_by_source",
|
|
318
|
+
"run_empirical_mixture_fsstdd_benchmark_manifest",
|
|
319
|
+
"run_empirical_mixture_fsstndd_benchmark_manifest",
|
|
320
|
+
"run_empirical_mixture_k_benchmark_manifest",
|
|
321
|
+
"run_nonbinary_empirical_mixture_cs_monte_carlo",
|
|
322
|
+
"run_paper_empirical_mixture_benchmark_suite_chunk",
|
|
323
|
+
"summarize_paper_empirical_mixture_benchmark_suite_archive_blocker_packet",
|
|
324
|
+
"summarize_paper_empirical_mixture_benchmark_suite_archive_gate",
|
|
325
|
+
"summarize_paper_empirical_mixture_benchmark_suite_evidence",
|
|
326
|
+
"write_monte_carlo_suite_run_result_json",
|
|
327
|
+
"write_merged_monte_carlo_suite_run_result_json",
|
|
328
|
+
"write_next_paper_empirical_mixture_benchmark_suite_archive_evidence",
|
|
329
|
+
"write_next_paper_empirical_mixture_benchmark_suite_chunk_evidence",
|
|
330
|
+
"write_paper_empirical_mixture_benchmark_suite_chunk_evidence",
|
|
331
|
+
"write_paper_empirical_mixture_benchmark_suite_evidence",
|
|
332
|
+
"write_paper_monte_carlo_reproduction_report_json",
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
_ROOT_EXPORT_EXCLUSIONS = {
|
|
336
|
+
"build_python_fixture_summary",
|
|
337
|
+
"diff_fixture_summaries",
|
|
338
|
+
"run_r_bounds_ade_ats_case",
|
|
339
|
+
"run_r_fixture_summary",
|
|
340
|
+
"run_r_lb_frac_affected_case",
|
|
341
|
+
"run_r_sharp_null_arp_case",
|
|
342
|
+
"run_r_sharp_null_cr_case",
|
|
343
|
+
"run_r_sharp_null_cs_case",
|
|
344
|
+
"run_r_simulate_data_binary_m_contract",
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
_ROOT_EXPORT_EXCLUSION_FRAGMENTS = (
|
|
348
|
+
"archive",
|
|
349
|
+
"benchmark",
|
|
350
|
+
"chunk",
|
|
351
|
+
"evidence",
|
|
352
|
+
"focused_probe",
|
|
353
|
+
"milestone_audit",
|
|
354
|
+
)
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
def _is_root_export_excluded(name: str) -> bool:
|
|
358
|
+
lower_name = name.lower()
|
|
359
|
+
return (
|
|
360
|
+
name in _ROOT_EXPORT_EXCLUSIONS
|
|
361
|
+
or name.startswith("run_")
|
|
362
|
+
or name.startswith("write_next_")
|
|
363
|
+
or any(fragment in lower_name for fragment in _ROOT_EXPORT_EXCLUSION_FRAGMENTS)
|
|
364
|
+
)
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
__all__ = [name for name in __all__ if not _is_root_export_excluded(name)]
|
|
368
|
+
|
|
369
|
+
_EXPORT_MODULES.update(
|
|
370
|
+
{
|
|
371
|
+
name: "monte_carlo"
|
|
372
|
+
for name in _MONTE_CARLO_EXPORTS
|
|
373
|
+
}
|
|
374
|
+
)
|
|
375
|
+
|
|
376
|
+
for _name in tuple(_EXPORT_MODULES):
|
|
377
|
+
if _is_root_export_excluded(_name):
|
|
378
|
+
_EXPORT_MODULES.pop(_name, None)
|
|
379
|
+
for _name in _ROOT_EXPORT_EXCLUSIONS:
|
|
380
|
+
_EXPORT_MODULES.pop(_name, None)
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
def __getattr__(name: str) -> object:
|
|
384
|
+
if name == "__version__":
|
|
385
|
+
return __version__
|
|
386
|
+
module_name = _EXPORT_MODULES.get(name)
|
|
387
|
+
if module_name is None:
|
|
388
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
389
|
+
value = getattr(import_module(f".{module_name}", __name__), name)
|
|
390
|
+
globals()[name] = value
|
|
391
|
+
return value
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
def __dir__() -> list[str]:
|
|
395
|
+
return sorted(set(globals()) | set(__all__))
|
testmechs/_json_io.py
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"""Atomic strict-JSON file writer for testmechs report persistence.
|
|
2
|
+
|
|
3
|
+
This module provides a single utility function that serializes a Python
|
|
4
|
+
object to a JSON file using an atomic write pattern (write-to-temp then
|
|
5
|
+
rename). Non-finite floats (NaN, Infinity) are rejected at serialization
|
|
6
|
+
time so that all persisted artifacts remain valid strict JSON.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import json
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
import tempfile
|
|
14
|
+
from typing import Any
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def write_strict_json_atomic(path: Path, payload: Any) -> None:
|
|
18
|
+
"""Serialize *payload* to *path* as strict JSON using an atomic write.
|
|
19
|
+
|
|
20
|
+
The function writes to a temporary file in the same directory as *path*
|
|
21
|
+
and then atomically renames it to *path*, ensuring readers never observe
|
|
22
|
+
a partially-written file.
|
|
23
|
+
|
|
24
|
+
Parameters
|
|
25
|
+
----------
|
|
26
|
+
path : Path
|
|
27
|
+
Destination file path. Parent directories are created if absent.
|
|
28
|
+
payload : Any
|
|
29
|
+
JSON-serializable object. Must not contain ``NaN`` or ``Infinity``
|
|
30
|
+
values (``allow_nan=False`` is enforced).
|
|
31
|
+
|
|
32
|
+
Raises
|
|
33
|
+
------
|
|
34
|
+
ValueError
|
|
35
|
+
If *payload* contains non-finite numeric values.
|
|
36
|
+
OSError
|
|
37
|
+
If the temporary file cannot be written or renamed.
|
|
38
|
+
|
|
39
|
+
Examples
|
|
40
|
+
--------
|
|
41
|
+
>>> from pathlib import Path
|
|
42
|
+
>>> write_strict_json_atomic(Path("/tmp/result.json"), {"score": 0.95})
|
|
43
|
+
"""
|
|
44
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
45
|
+
temp_path: Path | None = None
|
|
46
|
+
try:
|
|
47
|
+
with tempfile.NamedTemporaryFile(
|
|
48
|
+
"w",
|
|
49
|
+
encoding="utf-8",
|
|
50
|
+
dir=path.parent,
|
|
51
|
+
prefix=f".{path.name}.",
|
|
52
|
+
suffix=".tmp",
|
|
53
|
+
delete=False,
|
|
54
|
+
) as handle:
|
|
55
|
+
temp_path = Path(handle.name)
|
|
56
|
+
json.dump(
|
|
57
|
+
payload,
|
|
58
|
+
handle,
|
|
59
|
+
allow_nan=False,
|
|
60
|
+
ensure_ascii=False,
|
|
61
|
+
indent=2,
|
|
62
|
+
sort_keys=True,
|
|
63
|
+
)
|
|
64
|
+
handle.write("\n")
|
|
65
|
+
temp_path.replace(path)
|
|
66
|
+
except Exception:
|
|
67
|
+
if temp_path is not None:
|
|
68
|
+
temp_path.unlink(missing_ok=True)
|
|
69
|
+
raise
|