scientific-computing-system 1.0.0 → 2.2.0

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 (430) hide show
  1. package/CHANGELOG.md +284 -0
  2. package/LICENSE +0 -0
  3. package/README.md +89 -218
  4. package/SECURITY.md +0 -0
  5. package/bin/scs.js +12 -2
  6. package/index.js +115 -1
  7. package/package.json +45 -1
  8. package/.binder/postBuild +0 -9
  9. package/.binder/requirements.txt +0 -10
  10. package/.gitattributes +0 -35
  11. package/.github/CODEOWNERS +0 -4
  12. package/.github/FUNDING.yml +0 -3
  13. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -50
  14. package/.github/ISSUE_TEMPLATE/config.yml +0 -8
  15. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -28
  16. package/.github/PULL_REQUEST_TEMPLATE.md +0 -29
  17. package/.github/dependabot.yml +0 -32
  18. package/.github/labeler.yml +0 -50
  19. package/.github/workflows/benchmarks.yml +0 -97
  20. package/.github/workflows/bot-reviewer.yml +0 -58
  21. package/.github/workflows/changelog.yml +0 -130
  22. package/.github/workflows/cli-package-smoke.yml +0 -45
  23. package/.github/workflows/codeql.yml +0 -55
  24. package/.github/workflows/npm-publish.yml +0 -33
  25. package/.github/workflows/p08-cancel-noncanonical-runs.yml +0 -41
  26. package/.github/workflows/pr-automation.yml +0 -78
  27. package/.github/workflows/public-external-validation-p08-v2-glm.yml +0 -161
  28. package/.github/workflows/public-external-validation-p08-v2-recovery-merge-gate.yml +0 -72
  29. package/.github/workflows/public-external-validation-p08-v2-recovery-merge.yml +0 -113
  30. package/.github/workflows/public-external-validation-p08-v2-run-recovery-anatomy-gate.yml +0 -57
  31. package/.github/workflows/public-external-validation-p08-v2-run-recovery-merge-gate.yml +0 -63
  32. package/.github/workflows/public-external-validation-p08-v2-run-recovery-merge.yml +0 -89
  33. package/.github/workflows/public-external-validation-p08-v2-run-recovery.yml +0 -182
  34. package/.github/workflows/public-external-validation-p08-v3-glm-gate.yml +0 -67
  35. package/.github/workflows/public-external-validation-p08-v4-recovery-glm-gate.yml +0 -78
  36. package/.github/workflows/public-external-validation-p08-v4-recovery-glm.yml +0 -248
  37. package/.github/workflows/public-external-validation-p08-v5-run-recovery-glm-gate.yml +0 -66
  38. package/.github/workflows/public-external-validation-p08-v5-run-recovery-glm.yml +0 -218
  39. package/.github/workflows/pypi-registry-smoke.yml +0 -116
  40. package/.github/workflows/release.yml +0 -359
  41. package/.github/workflows/tests.yml +0 -250
  42. package/.github/workflows/tmp-compassion-raw-acquire.yml +0 -63
  43. package/.github/workflows/wsl-science-runner-smoke.yml +0 -45
  44. package/.pre-commit-config.yaml +0 -48
  45. package/CITATION.cff +0 -29
  46. package/CODE_OF_CONDUCT.md +0 -25
  47. package/CONTRIBUTING.md +0 -275
  48. package/ROADMAP.md +0 -155
  49. package/assets/logo.svg +0 -38
  50. package/assets/social_preview.png +0 -0
  51. package/benchmarks/results.json +0 -43
  52. package/benchmarks/robust_runner.py +0 -118
  53. package/benchmarks/run_benchmarks.py +0 -394
  54. package/cliff.toml +0 -100
  55. package/dashboard/app.py +0 -224
  56. package/docs/ARCHITECTURE.md +0 -252
  57. package/docs/CASE_STUDY_HUBBLE.md +0 -78
  58. package/docs/CASE_STUDY_QUANTUM_ML.md +0 -79
  59. package/docs/api.md +0 -133
  60. package/docs/assets/icon.svg +0 -17
  61. package/docs/assets/logo.svg +0 -38
  62. package/docs/benchmarks.md +0 -62
  63. package/docs/cookbook.md +0 -930
  64. package/docs/getting-started.md +0 -185
  65. package/docs/index.md +0 -111
  66. package/docs/maintenance.md +0 -61
  67. package/docs/ml_reference.md +0 -92
  68. package/docs/research-workflows.md +0 -82
  69. package/docs/stylesheets/extra.css +0 -122
  70. package/docs/tour_of_numerical_methods.md +0 -330
  71. package/docs/tutorials/core_demo.md +0 -35
  72. package/docs/tutorials/data_analysis_demo.md +0 -43
  73. package/docs/tutorials/diffeq_demo.md +0 -48
  74. package/docs/tutorials/fft2_demo.md +0 -67
  75. package/docs/tutorials/graph_demo.md +0 -45
  76. package/docs/tutorials/hypothesis_demo.md +0 -44
  77. package/docs/tutorials/hypothesis_tests_demo.md +0 -170
  78. package/docs/tutorials/hypothesis_with_stats_demo.md +0 -80
  79. package/docs/tutorials/knowledge_demo.md +0 -114
  80. package/docs/tutorials/linalg_demo.md +0 -103
  81. package/docs/tutorials/math_utils_demo.md +0 -46
  82. package/docs/tutorials/ml_advanced_demo.md +0 -96
  83. package/docs/tutorials/ml_and_viz_demo.md +0 -93
  84. package/docs/tutorials/ml_demo.md +0 -70
  85. package/docs/tutorials/modeling_demo.md +0 -82
  86. package/docs/tutorials/montecarlo_demo.md +0 -42
  87. package/docs/tutorials/nlp_attention_demo.md +0 -107
  88. package/docs/tutorials/nlp_bpe_demo.md +0 -103
  89. package/docs/tutorials/nlp_mini_gpt_demo.md +0 -110
  90. package/docs/tutorials/nlp_viz.md +0 -76
  91. package/docs/tutorials/numerical_integration_demo.md +0 -65
  92. package/docs/tutorials/optimization_demo.md +0 -106
  93. package/docs/tutorials/pandas_io_demo.md +0 -160
  94. package/docs/tutorials/pca_demo.md +0 -87
  95. package/docs/tutorials/probability_demo.md +0 -48
  96. package/docs/tutorials/quantum_demo.md +0 -31
  97. package/docs/tutorials/quick_start.md +0 -44
  98. package/docs/tutorials/scientific_demo.md +0 -46
  99. package/docs/tutorials/signals_demo.md +0 -167
  100. package/docs/tutorials/stats_demo.md +0 -94
  101. package/docs/tutorials/stiff_ode_demo.md +0 -84
  102. package/docs/tutorials/time_series_demo.md +0 -145
  103. package/examples/core_demo.py +0 -40
  104. package/examples/data_analysis_demo.py +0 -60
  105. package/examples/diffeq_demo.py +0 -34
  106. package/examples/discovery_pipeline_demo.py +0 -57
  107. package/examples/ensemble_showcase.py +0 -81
  108. package/examples/fft2_demo.py +0 -32
  109. package/examples/graph_demo.py +0 -49
  110. package/examples/hypothesis_custom_generator.py +0 -121
  111. package/examples/hypothesis_demo.py +0 -48
  112. package/examples/hypothesis_tests_demo.py +0 -52
  113. package/examples/hypothesis_with_stats_demo.py +0 -43
  114. package/examples/interpolate_demo.py +0 -57
  115. package/examples/knowledge_demo.py +0 -100
  116. package/examples/linalg_demo.py +0 -61
  117. package/examples/math_utils_demo.py +0 -53
  118. package/examples/ml_and_viz_demo.py +0 -47
  119. package/examples/modeling_demo.py +0 -110
  120. package/examples/montecarlo_demo.py +0 -41
  121. package/examples/nlp_attention_demo.py +0 -168
  122. package/examples/nlp_bpe_demo.py +0 -79
  123. package/examples/nlp_mini_gpt_demo.py +0 -76
  124. package/examples/nlp_viz_demo.py +0 -98
  125. package/examples/numerical_integration_demo.py +0 -60
  126. package/examples/optimization_demo.py +0 -34
  127. package/examples/pca_demo.py +0 -124
  128. package/examples/pde_demo.py +0 -65
  129. package/examples/plot_demo.py +0 -84
  130. package/examples/plotting_notebook.ipynb +0 -87
  131. package/examples/probability_demo.py +0 -39
  132. package/examples/quantum_demo.py +0 -42
  133. package/examples/scientific_demo.py +0 -49
  134. package/examples/signals_demo.py +0 -86
  135. package/examples/stats_demo.py +0 -40
  136. package/examples/tour_of_numerical_methods.ipynb +0 -497
  137. package/mkdocs.yml +0 -159
  138. package/pyproject.toml +0 -288
  139. package/requirements-dev.lock +0 -427
  140. package/requirements-dev.txt +0 -39
  141. package/requirements.lock +0 -6
  142. package/requirements.txt +0 -13
  143. package/scripts/build_gif.py +0 -111
  144. package/scripts/build_video.py +0 -214
  145. package/scripts/cleanup_deployments.py +0 -173
  146. package/scripts/crop_readme_png.py +0 -40
  147. package/scripts/make_pi_dashboard.py +0 -316
  148. package/scripts/make_pi_gif.py +0 -138
  149. package/scripts/publish.py +0 -203
  150. package/scripts/render_promo.mjs +0 -93
  151. package/scripts/render_readme.py +0 -211
  152. package/scripts/render_readme_sections.py +0 -168
  153. package/scripts/verify_cli_install.py +0 -99
  154. package/scripts/verify_cookbook.py +0 -601
  155. package/scripts/verify_d1_numerics.py +0 -504
  156. package/scripts/verify_d2_edge_cases.py +0 -442
  157. package/scripts/verify_d4_hypothesis.py +0 -337
  158. package/scripts/verify_ml_reference.py +0 -160
  159. package/scripts/verify_pypi_release.py +0 -97
  160. package/scripts/verify_release_integrity.py +0 -194
  161. package/src/cds/__init__.py +0 -132
  162. package/src/cds/__main__.py +0 -8
  163. package/src/cds/_version.py +0 -11
  164. package/src/cds/bayes/__init__.py +0 -25
  165. package/src/cds/bayes/conjugate.py +0 -560
  166. package/src/cds/cli/__init__.py +0 -104
  167. package/src/cds/cli/__main__.py +0 -8
  168. package/src/cds/cli/_handlers.py +0 -323
  169. package/src/cds/cli/_parser.py +0 -155
  170. package/src/cds/cli/_style.py +0 -208
  171. package/src/cds/cli/_system_info.py +0 -71
  172. package/src/cds/core/__init__.py +0 -5
  173. package/src/cds/core/_numeric.py +0 -92
  174. package/src/cds/core/models.py +0 -166
  175. package/src/cds/data_analysis/__init__.py +0 -30
  176. package/src/cds/data_analysis/dataset.py +0 -122
  177. package/src/cds/data_analysis/loader.py +0 -75
  178. package/src/cds/data_analysis/pandas_io.py +0 -108
  179. package/src/cds/data_analysis/transform.py +0 -36
  180. package/src/cds/data_analysis/viz.py +0 -88
  181. package/src/cds/data_io/__init__.py +0 -27
  182. package/src/cds/data_io/streaming.py +0 -314
  183. package/src/cds/diffeq/__init__.py +0 -37
  184. package/src/cds/diffeq/_implicit.py +0 -349
  185. package/src/cds/diffeq/solvers.py +0 -312
  186. package/src/cds/diffeq/symplectic.py +0 -225
  187. package/src/cds/fractals/__init__.py +0 -34
  188. package/src/cds/fractals/sets.py +0 -356
  189. package/src/cds/genetics/__init__.py +0 -22
  190. package/src/cds/genetics/sequence.py +0 -199
  191. package/src/cds/graph/__init__.py +0 -31
  192. package/src/cds/graph/algorithms.py +0 -399
  193. package/src/cds/hypothesis/__init__.py +0 -51
  194. package/src/cds/hypothesis/evaluator.py +0 -311
  195. package/src/cds/hypothesis/generator.py +0 -275
  196. package/src/cds/hypothesis/mining.py +0 -314
  197. package/src/cds/infotheory/__init__.py +0 -25
  198. package/src/cds/infotheory/measures.py +0 -276
  199. package/src/cds/interpolate/__init__.py +0 -156
  200. package/src/cds/knowledge/__init__.py +0 -45
  201. package/src/cds/knowledge/graph.py +0 -489
  202. package/src/cds/knowledge/notes.py +0 -231
  203. package/src/cds/knowledge/retrieval.py +0 -339
  204. package/src/cds/math_utils/__init__.py +0 -46
  205. package/src/cds/math_utils/calculus.py +0 -40
  206. package/src/cds/math_utils/linalg.py +0 -496
  207. package/src/cds/math_utils/special.py +0 -167
  208. package/src/cds/math_utils/svd.py +0 -261
  209. package/src/cds/ml/__init__.py +0 -60
  210. package/src/cds/ml/boosting.py +0 -304
  211. package/src/cds/ml/clustering.py +0 -190
  212. package/src/cds/ml/decomposition.py +0 -172
  213. package/src/cds/ml/ensemble.py +0 -152
  214. package/src/cds/ml/linear_models.py +0 -225
  215. package/src/cds/ml/metrics.py +0 -227
  216. package/src/cds/ml/model_selection.py +0 -150
  217. package/src/cds/ml/naive_bayes.py +0 -179
  218. package/src/cds/ml/neighbors.py +0 -162
  219. package/src/cds/ml/neural.py +0 -204
  220. package/src/cds/ml/preprocessing.py +0 -131
  221. package/src/cds/ml/tree.py +0 -228
  222. package/src/cds/ml/voting.py +0 -175
  223. package/src/cds/modeling/__init__.py +0 -44
  224. package/src/cds/modeling/_base.py +0 -210
  225. package/src/cds/modeling/_nodes.py +0 -526
  226. package/src/cds/modeling/expression.py +0 -81
  227. package/src/cds/modeling/fitting.py +0 -477
  228. package/src/cds/modeling/model.py +0 -134
  229. package/src/cds/modeling/solver.py +0 -187
  230. package/src/cds/montecarlo/__init__.py +0 -24
  231. package/src/cds/montecarlo/markov.py +0 -112
  232. package/src/cds/montecarlo/methods.py +0 -294
  233. package/src/cds/nlp/__init__.py +0 -170
  234. package/src/cds/nlp/attention.py +0 -285
  235. package/src/cds/nlp/autograd/__init__.py +0 -70
  236. package/src/cds/nlp/autograd/_grad.py +0 -120
  237. package/src/cds/nlp/autograd/ops.py +0 -133
  238. package/src/cds/nlp/autograd/tensor.py +0 -298
  239. package/src/cds/nlp/bpe.py +0 -449
  240. package/src/cds/nlp/data.py +0 -70
  241. package/src/cds/nlp/embed.py +0 -190
  242. package/src/cds/nlp/layers.py +0 -259
  243. package/src/cds/nlp/model.py +0 -456
  244. package/src/cds/nlp/optim.py +0 -163
  245. package/src/cds/nlp/training.py +0 -167
  246. package/src/cds/nlp/viz.py +0 -254
  247. package/src/cds/numerical_integration/__init__.py +0 -31
  248. package/src/cds/numerical_integration/quadrature.py +0 -480
  249. package/src/cds/optimization/__init__.py +0 -26
  250. package/src/cds/optimization/_metaheuristics.py +0 -287
  251. package/src/cds/optimization/constrained.py +0 -212
  252. package/src/cds/optimization/minimize.py +0 -425
  253. package/src/cds/pde/__init__.py +0 -266
  254. package/src/cds/plot/__init__.py +0 -49
  255. package/src/cds/plot/_backend.py +0 -32
  256. package/src/cds/plot/charts.py +0 -462
  257. package/src/cds/probability/__init__.py +0 -65
  258. package/src/cds/probability/_advanced.py +0 -283
  259. package/src/cds/probability/distributions.py +0 -236
  260. package/src/cds/probability/extra_distributions.py +0 -199
  261. package/src/cds/provenance/__init__.py +0 -25
  262. package/src/cds/provenance/manifest.py +0 -355
  263. package/src/cds/py.typed +0 -0
  264. package/src/cds/quantum/__init__.py +0 -51
  265. package/src/cds/quantum/circuit.py +0 -122
  266. package/src/cds/quantum/multi_qubit.py +0 -310
  267. package/src/cds/quantum/simulator.py +0 -53
  268. package/src/cds/scientific/__init__.py +0 -34
  269. package/src/cds/scientific/constants.py +0 -35
  270. package/src/cds/scientific/formulas.py +0 -116
  271. package/src/cds/sensitivity.py +0 -204
  272. package/src/cds/signals/__init__.py +0 -59
  273. package/src/cds/signals/filters.py +0 -449
  274. package/src/cds/signals/processing.py +0 -224
  275. package/src/cds/signals/stft.py +0 -177
  276. package/src/cds/signals/wavelet.py +0 -146
  277. package/src/cds/stats/__init__.py +0 -99
  278. package/src/cds/stats/_distributions.py +0 -102
  279. package/src/cds/stats/bootstrap.py +0 -188
  280. package/src/cds/stats/descriptive.py +0 -172
  281. package/src/cds/stats/hypothesis_tests.py +0 -294
  282. package/src/cds/stats/nonparametric.py +0 -141
  283. package/src/cds/stats/power.py +0 -290
  284. package/src/cds/stats/regression.py +0 -51
  285. package/src/cds/stats/time_series.py +0 -420
  286. package/src/cds/tools/__init__.py +0 -29
  287. package/src/cds/tools/adapters.py +0 -218
  288. package/src/cds/tools/registry.py +0 -181
  289. package/src/cds/uncertainty/__init__.py +0 -17
  290. package/src/cds/uncertainty/propagation.py +0 -233
  291. package/src/cds/units/__init__.py +0 -45
  292. package/src/cds/units/core.py +0 -199
  293. package/src/cds/validation/__init__.py +0 -41
  294. package/src/cds/validation/adequacy.py +0 -157
  295. package/src/cds/validation/checks.py +0 -485
  296. package/src/cds/validation/report.py +0 -50
  297. package/src/cds/wavelets/__init__.py +0 -5
  298. package/src/cds/wavelets/haar.py +0 -219
  299. package/src/cds/workflow/__init__.py +0 -77
  300. package/src/cds/workflow/engine.py +0 -116
  301. package/src/cds/workflow/gates.py +0 -120
  302. package/src/cds/workflow/orchestrator.py +0 -431
  303. package/src/cds/workflow/selection.py +0 -454
  304. package/src/cds/workflow/tooling.py +0 -155
  305. package/src/cds/workflow/types.py +0 -107
  306. package/tests/__init__.py +0 -0
  307. package/tests/conftest.py +0 -109
  308. package/tests/test_advanced_fitting.py +0 -247
  309. package/tests/test_audit_completion_coverage.py +0 -183
  310. package/tests/test_audit_guard_coverage.py +0 -115
  311. package/tests/test_audit_hardening.py +0 -138
  312. package/tests/test_audit_hardening_coverage.py +0 -111
  313. package/tests/test_bayes_v2.py +0 -208
  314. package/tests/test_benchmarks.py +0 -111
  315. package/tests/test_bootstrap.py +0 -135
  316. package/tests/test_cli.py +0 -51
  317. package/tests/test_cli_color.py +0 -114
  318. package/tests/test_cli_extended.py +0 -239
  319. package/tests/test_cli_system_info.py +0 -36
  320. package/tests/test_constrained_opt.py +0 -174
  321. package/tests/test_core.py +0 -273
  322. package/tests/test_data_analysis.py +0 -146
  323. package/tests/test_data_analysis_lazy_bridge.py +0 -68
  324. package/tests/test_data_analysis_pandas_io.py +0 -119
  325. package/tests/test_data_io.py +0 -149
  326. package/tests/test_dataset.py +0 -91
  327. package/tests/test_diffeq.py +0 -186
  328. package/tests/test_diffeq_implicit.py +0 -173
  329. package/tests/test_domain_validation.py +0 -66
  330. package/tests/test_edge_misc_numerical.py +0 -666
  331. package/tests/test_edge_ml_quantum_linalg.py +0 -191
  332. package/tests/test_edge_nlp.py +0 -229
  333. package/tests/test_edge_quantum_evaluator_cli.py +0 -601
  334. package/tests/test_edge_stats_optimization_signals.py +0 -406
  335. package/tests/test_extra_distributions.py +0 -206
  336. package/tests/test_fft2.py +0 -67
  337. package/tests/test_fitting_bootstrap.py +0 -202
  338. package/tests/test_fractals.py +0 -387
  339. package/tests/test_genetics.py +0 -159
  340. package/tests/test_graph.py +0 -380
  341. package/tests/test_hardening_privacy_provenance.py +0 -306
  342. package/tests/test_hypothesis.py +0 -216
  343. package/tests/test_hypothesis_engine.py +0 -59
  344. package/tests/test_hypothesis_mining.py +0 -247
  345. package/tests/test_hypothesis_tests.py +0 -277
  346. package/tests/test_infotheory.py +0 -302
  347. package/tests/test_interpolate.py +0 -189
  348. package/tests/test_knowledge.py +0 -1149
  349. package/tests/test_layering.py +0 -112
  350. package/tests/test_linalg_extended.py +0 -179
  351. package/tests/test_linalg_qr_cholesky.py +0 -68
  352. package/tests/test_markov.py +0 -155
  353. package/tests/test_math_utils.py +0 -157
  354. package/tests/test_ml_boosting.py +0 -148
  355. package/tests/test_ml_clustering.py +0 -92
  356. package/tests/test_ml_ensemble.py +0 -103
  357. package/tests/test_ml_knn.py +0 -95
  358. package/tests/test_ml_linreg.py +0 -70
  359. package/tests/test_ml_logreg.py +0 -84
  360. package/tests/test_ml_metrics.py +0 -125
  361. package/tests/test_ml_model_selection.py +0 -108
  362. package/tests/test_ml_naive_bayes.py +0 -183
  363. package/tests/test_ml_pca.py +0 -98
  364. package/tests/test_ml_preprocessing.py +0 -104
  365. package/tests/test_ml_tree.py +0 -89
  366. package/tests/test_ml_viz.py +0 -58
  367. package/tests/test_ml_voting.py +0 -219
  368. package/tests/test_modeling.py +0 -726
  369. package/tests/test_modeling_fit_validation.py +0 -46
  370. package/tests/test_montecarlo.py +0 -245
  371. package/tests/test_multi_qubit.py +0 -466
  372. package/tests/test_nlp_attention.py +0 -335
  373. package/tests/test_nlp_autograd.py +0 -435
  374. package/tests/test_nlp_bpe.py +0 -463
  375. package/tests/test_nlp_embed.py +0 -240
  376. package/tests/test_nlp_layers.py +0 -276
  377. package/tests/test_nlp_model.py +0 -172
  378. package/tests/test_nlp_training.py +0 -262
  379. package/tests/test_nlp_viz.py +0 -188
  380. package/tests/test_numerical_integration.py +0 -374
  381. package/tests/test_numerical_invariants.py +0 -768
  382. package/tests/test_numerical_oracles.py +0 -241
  383. package/tests/test_optimization.py +0 -139
  384. package/tests/test_optimization_metaheuristics.py +0 -221
  385. package/tests/test_pde.py +0 -294
  386. package/tests/test_plot_charts.py +0 -247
  387. package/tests/test_plot_lazy.py +0 -48
  388. package/tests/test_power.py +0 -226
  389. package/tests/test_probability.py +0 -274
  390. package/tests/test_probability_advanced.py +0 -226
  391. package/tests/test_property_invariants.py +0 -277
  392. package/tests/test_provenance.py +0 -215
  393. package/tests/test_provenance_audit_hardening.py +0 -45
  394. package/tests/test_public_api.py +0 -75
  395. package/tests/test_quantum.py +0 -195
  396. package/tests/test_release_contract.py +0 -105
  397. package/tests/test_retrieval.py +0 -255
  398. package/tests/test_scientific.py +0 -185
  399. package/tests/test_selection_audit_hardening.py +0 -55
  400. package/tests/test_sensitivity.py +0 -59
  401. package/tests/test_sensitivity_global.py +0 -73
  402. package/tests/test_signals.py +0 -146
  403. package/tests/test_signals_filters.py +0 -460
  404. package/tests/test_special_invariants.py +0 -222
  405. package/tests/test_special_numerics.py +0 -44
  406. package/tests/test_statistical_audit.py +0 -75
  407. package/tests/test_stats.py +0 -206
  408. package/tests/test_stats_audit_coverage.py +0 -17
  409. package/tests/test_stats_nonparametric.py +0 -87
  410. package/tests/test_stats_time_series.py +0 -352
  411. package/tests/test_stft.py +0 -208
  412. package/tests/test_streaming_analytics.py +0 -128
  413. package/tests/test_svd.py +0 -170
  414. package/tests/test_symplectic.py +0 -200
  415. package/tests/test_tool_adapters.py +0 -197
  416. package/tests/test_tools_registry.py +0 -132
  417. package/tests/test_uncertainty.py +0 -171
  418. package/tests/test_units.py +0 -139
  419. package/tests/test_validation.py +0 -100
  420. package/tests/test_validation_adequacy.py +0 -129
  421. package/tests/test_validation_advanced.py +0 -110
  422. package/tests/test_wavelet.py +0 -170
  423. package/tests/test_wavelets_v2.py +0 -119
  424. package/tests/test_workflow.py +0 -173
  425. package/tests/test_workflow_gates.py +0 -144
  426. package/tests/test_workflow_orchestrator.py +0 -516
  427. package/tests/test_workflow_orchestrator_blocked_review.py +0 -95
  428. package/tests/test_workflow_selection.py +0 -312
  429. package/tests/test_workflow_selection_coverage.py +0 -114
  430. package/tests/test_workflow_tooling.py +0 -190
@@ -1,94 +0,0 @@
1
- # Statistics Tutorial
2
-
3
- `cds.stats` covers descriptive statistics, linear regression, and a set of
4
- classic hypothesis tests (t-tests, ANOVA, chi-square). Tests return a
5
- `TestResult` dataclass carrying the test statistic, p-value, and degrees of
6
- freedom.
7
-
8
- ## 1. Descriptive statistics
9
-
10
- ```python
11
- from cds.stats import mean, median, variance, stdev
12
-
13
- data = [23.1, 27.5, 19.8, 31.2, 25.6, 28.3, 22.0, 30.1]
14
- print(f"Mean={mean(data):.2f} Median={median(data):.2f}") # 25.95 26.55
15
- print(f"Var={variance(data):.2f} StdDev={stdev(data):.2f}") # 16.34 4.04
16
- ```
17
-
18
- ## 2. Correlation and linear regression
19
-
20
- Pearson correlation between two samples, and ordinary least-squares regression.
21
- The `RegressionResult` exposes `slope`, `intercept`, `r_squared`, and a
22
- `predict(x)` helper.
23
-
24
- ```python
25
- from cds.stats import correlation, linear_regression
26
-
27
- x = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0]
28
- y = [2.1, 4.3, 5.8, 8.1, 9.7, 12.2, 13.8, 16.1]
29
-
30
- print(f"r = {correlation(x, y):.4f}") # r = 0.9991
31
-
32
- reg = linear_regression(x, y)
33
- print(f"y = {reg.slope:.2f}x + {reg.intercept:.2f}") # y = 1.98x + 0.10
34
- print(f"R² = {reg.r_squared:.4f}") # R² = 0.9981
35
- print(f"predict(10) = {reg.predict(10):.2f}") # 19.90
36
- ```
37
-
38
- ## 3. Hypothesis tests
39
-
40
- All tests return a `TestResult` with `.statistic`, `.p_value`, and `.df`.
41
-
42
- ### One-sample t-test
43
-
44
- Is the sample mean different from a hypothesized population mean?
45
-
46
- ```python
47
- from cds.stats import one_sample_ttest
48
-
49
- r = one_sample_ttest([2.1, 2.4, 1.9, 2.2, 2.0, 2.3], popmean=2.0)
50
- print(f"t={r.statistic:.4f}, p={r.p_value:.4f}, df={r.df}") # t=1.9640, p=0.1067, df=5
51
- # p > 0.05 → do not reject H0 (mean ≈ 2.0)
52
- ```
53
-
54
- ### Two-sample t-test
55
-
56
- Do two independent samples have equal means?
57
-
58
- ```python
59
- from cds.stats import two_sample_ttest
60
-
61
- r = two_sample_ttest([1.0, 2.0, 3.0, 4.0], [2.0, 3.0, 4.0, 5.0])
62
- print(f"t={r.statistic:.4f}, p={r.p_value:.4f}") # t=-1.0954, p=0.3153
63
- ```
64
-
65
- ### One-way ANOVA
66
-
67
- Do three or more groups share the same mean? Pass each group as a positional
68
- argument.
69
-
70
- ```python
71
- from cds.stats import one_way_anova
72
-
73
- r = one_way_anova([1.0, 2.0, 3.0], [2.0, 3.0, 4.0], [3.0, 4.0, 5.0])
74
- print(f"F={r.statistic:.4f}, p={r.p_value:.4f}") # F=3.0000, p=0.1250
75
- ```
76
-
77
- ### Chi-square tests
78
-
79
- Goodness-of-fit (observed vs expected counts) and independence (a 2-D
80
- contingency table).
81
-
82
- ```python
83
- from cds.stats import chi_square_gof, chi_square_independence
84
-
85
- r = chi_square_gof([10.0, 20.0, 30.0], [15.0, 20.0, 25.0])
86
- print(f"chi2={r.statistic:.4f}, p={r.p_value:.4f}") # chi2=2.6667, p=0.2636
87
-
88
- r = chi_square_independence([[10.0, 20.0], [30.0, 40.0]])
89
- print(f"chi2={r.statistic:.4f}, p={r.p_value:.4f}") # chi2=0.7937, p=0.3730
90
- ```
91
-
92
- ---
93
-
94
- Run the full demo with `python examples/stats_demo.py`.
@@ -1,84 +0,0 @@
1
- # Stiff ODE Solvers Tutorial
2
-
3
- `cds.diffeq._implicit` adds two A-stable implicit methods to the explicit
4
- solvers: **backward Euler** (θ = 1) and the **trapezoidal / Crank–Nicolson
5
- method** (θ = ½). Both solve their implicit stage equation with Newton
6
- iteration, using an analytic Jacobian when you supply one and central
7
- differences otherwise.
8
-
9
- ## 1. Why implicit? The stiff decay problem
10
-
11
- For `dy/dt = -1000·(y − 1)` any explicit method diverges unless
12
- `dt < 2/1000`. Backward Euler stays stable at the same step:
13
-
14
- ```python
15
- from cds.diffeq import backward_euler
16
-
17
- k = 1000.0
18
- sol = backward_euler(lambda t, y: -k * (y - 1.0), t0=0.0, y0=0.0, t_end=0.05, dt=0.001)
19
- print(f"{sol.y[-1]:.6f}") # ≈ 1.000000 — exact is 1 − e⁻⁵⁰ ≈ 1.0
20
- ```
21
-
22
- ## 2. Trapezoid (Crank–Nicolson): stable AND second-order
23
-
24
- Backward Euler buys stability with only first-order accuracy. The trapezoidal
25
- rule averages the explicit and implicit slopes for O(dt²) error while staying
26
- A-stable, on smooth problems its error shrinks ~4× when you halve `dt`.
27
-
28
- ```python
29
- import math
30
- from cds.diffeq import backward_euler, trapezoid_method
31
-
32
- f = lambda t, y: -y
33
- be = backward_euler(f, 0.0, 1.0, 2.0, dt=0.05).y[-1]
34
- cn = trapezoid_method(f, 0.0, 1.0, 2.0, dt=0.05).y[-1]
35
- exact = math.exp(-2.0)
36
- print(abs(cn - exact) < abs(be - exact)) # True
37
- ```
38
-
39
- ## 3. Systems: the harmonic oscillator
40
-
41
- The `_system` variants take vector states and return `(t_values, y_values)`
42
- just like :func:`cds.diffeq.solve_system`.
43
-
44
- ```python
45
- import math
46
- from cds.diffeq import trapezoid_method_system
47
-
48
-
49
- def harmonic(t, y):
50
- return [y[1], -y[0]] # x'' = -x as a system
51
-
52
-
53
- ts, ys = trapezoid_method_system(harmonic, 0.0, [1.0, 0.0], t_end=4 * math.pi, dt=0.01)
54
- amplitude = math.hypot(ys[-1][0], ys[-1][1])
55
- print(abs(amplitude - 1.0) < 0.01) # True — energy nearly conserved
56
- ```
57
-
58
- ## 4. Supplying an analytic Jacobian
59
-
60
- Newton converges in one step on linear problems either way, but a Jacobian
61
- removes the finite-difference evaluations:
62
-
63
- ```python
64
- from cds.diffeq import backward_euler_system
65
-
66
- jac = lambda t, y: [[-1000.0]] # df/dy
67
- ts, ys = backward_euler_system(
68
- lambda t, y: [-1000.0 * (y[0] - 1.0)],
69
- t0=0.0,
70
- y0=[0.0],
71
- t_end=0.05,
72
- dt=0.001,
73
- jac=jac,
74
- )
75
- ```
76
-
77
- ## Notes
78
-
79
- - Direction follows `sign(t_end - t0)` exactly like the explicit solvers;
80
- `dt` is always a magnitude.
81
- - Newton failures raise `ValueError` with a clear message ("singular
82
- Jacobian" / "did not converge within max_iter") instead of returning
83
- garbage.
84
- - Rule of thumb: use RK45 until stiffness hurts, then reach for these.
@@ -1,145 +0,0 @@
1
- # Time-Series Analysis Tutorial
2
-
3
- `cds.stats` provides a classical toolkit for ordered, equally-spaced
4
- observations: autocorrelation, partial autocorrelation, moving-average
5
- smoothing, differencing, a KPSS-style stationarity test, seasonal
6
- decomposition, and the Ljung-Box portmanteau test. All routines are pure
7
- Python with no external dependencies.
8
-
9
- ```python
10
- from cds.stats import (
11
- autocorrelation,
12
- autocorrelation_function,
13
- partial_autocorrelation,
14
- moving_average,
15
- exponential_smoothing,
16
- difference,
17
- kpss_statistic,
18
- seasonal_decompose,
19
- ljung_box,
20
- )
21
- ```
22
-
23
- ## 1. Autocorrelation (ACF)
24
-
25
- The sample autocorrelation at lag `k` measures how correlated a series is
26
- with a delayed copy of itself. A trending series shows high positive
27
- autocorrelation; an alternating series shows strong negative autocorrelation.
28
-
29
- ```python
30
- # A linear ramp: each point is close to its predecessor -> r_1 near 1.
31
- trend = [float(i) for i in range(20)]
32
- print(f"r_1 = {autocorrelation(trend, lag=1):.3f}") # ~0.95
33
- print(f"r_5 = {autocorrelation(trend, lag=5):.3f}") # still high
34
-
35
- # Full ACF for lags 0..4 (r_0 is always 1.0).
36
- acf = autocorrelation_function(trend, max_lag=4)
37
- print(acf) # [1.0, 0.95, 0.90, 0.85, 0.79]
38
- ```
39
-
40
- ## 2. Partial autocorrelation (PACF)
41
-
42
- The PACF isolates the *direct* correlation at each lag, removing the effect
43
- of intermediate lags via the Durbin-Levinson recursion. For a pure AR(1)
44
- process `x_t = 0.8·x_{t-1}`, the PACF spikes at lag 1 then cuts off to ~0,
45
- the hallmark signature for choosing ARIMA order `p`.
46
-
47
- ```python
48
- # Deterministic AR(1) with phi = 0.8.
49
- ar1 = [1.0]
50
- for _ in range(200):
51
- ar1.append(0.8 * ar1[-1])
52
-
53
- pacf = partial_autocorrelation(ar1, max_lag=4)
54
- print(f"phi_11 = {pacf[1]:.3f}") # ~0.80
55
- print(f"phi_22 = {pacf[2]:.3f}") # ~0.00 (cutoff)
56
- ```
57
-
58
- ## 3. Smoothing: moving average & exponential smoothing
59
-
60
- Smoothing reveals the underlying signal in noisy data. The centered moving
61
- average uses a fixed window; exponential smoothing weights recent
62
- observations more heavily via `alpha ∈ (0, 1]`.
63
-
64
- ```python
65
- noisy = [10.0, 0.0, 10.0, 0.0, 10.0, 0.0, 10.0, 0.0]
66
-
67
- ma = moving_average(noisy, window=2) # centered SMA
68
- ses = exponential_smoothing(noisy, alpha=0.3) # weight recent points
69
- print(f"SMA variance = {sum((x - 5) ** 2 for x in ma) / len(ma):.2f}")
70
- print(f"SES variance = {sum((x - 5) ** 2 for x in ses) / len(ses):.2f}")
71
- ```
72
-
73
- ## 4. Differencing
74
-
75
- Differencing removes trend and seasonality, the standard Box-Jenkins
76
- preprocessing step before fitting ARIMA models. `order=k` applies the
77
- difference repeatedly.
78
-
79
- ```python
80
- ramp = [1.0, 3.0, 5.0, 7.0, 9.0] # y = 2t + 1
81
- print(difference(ramp, lag=1, order=1)) # [2.0, 2.0, 2.0, 2.0] (constant)
82
-
83
- quad = [float(i * i) for i in range(6)] # 0,1,4,9,16,25
84
- print(difference(quad, lag=1, order=2)) # [2.0, 2.0, 2.0, 2.0] (2nd diff constant)
85
-
86
- seasonal = [1.0, 2.0, 3.0, 1.0, 2.0, 3.0] # period 3
87
- print(difference(seasonal, lag=3, order=1)) # [0.0, 0.0, 0.0]
88
- ```
89
-
90
- ## 5. Stationarity test (KPSS-style)
91
-
92
- The KPSS statistic tests the **null of stationarity** (the opposite of the
93
- ADF test). A small statistic means the series looks stationary; a large one
94
- suggests a unit root. `kpss_statistic` returns a heuristic decision and an
95
- approximate p-value, for formal inference consult the published asymptotic
96
- critical values.
97
-
98
- ```python
99
- # Oscillating around a mean -> stationary.
100
- stationary = [0.1, -0.2, 0.15, -0.1, 0.2, -0.15] * 4
101
- res = kpss_statistic(stationary)
102
- print(f"eta = {res.statistic:.4f}, stationary = {res.is_stationary}") # True
103
-
104
- # A random walk (cumulative sum) -> non-stationary.
105
- rw = [0.0]
106
- for _ in range(200):
107
- rw.append(rw[-1] + (1.0 if _ % 2 else -1.0) + 0.3)
108
- res2 = kpss_statistic(rw)
109
- print(f"eta = {res2.statistic:.4f}") # large
110
- ```
111
-
112
- ## 6. Seasonal decomposition
113
-
114
- Classical additive decomposition splits a series into **trend + seasonal +
115
- residual**. Pass the seasonal `period` (e.g. 12 for monthly data with annual
116
- cycle). The seasonal component is normalized to sum to zero over one period.
117
-
118
- ```python
119
- base = [10.0, 20.0, 30.0, 40.0] # one seasonal period
120
- data = base * 5 # 5 full periods
121
- trend, seasonal, residual = seasonal_decompose(data, period=4)
122
-
123
- print(f"seasonal sums to ~0: {sum(seasonal[:4]):.2f}") # 0.00
124
- print(f"max |residual| = {max(abs(r) for r in residual):.2f}")
125
- ```
126
-
127
- ## 7. Ljung-Box test for autocorrelation
128
-
129
- The Ljung-Box Q statistic tests whether *any* of the first `lags`
130
- autocorrelations differ from zero. A low p-value rejects independence,
131
- useful for checking whether ARIMA residuals are white noise.
132
-
133
- ```python
134
- # A clean trend has strong autocorrelation.
135
- strong = [float(i) for i in range(100)]
136
- lb = ljung_box(strong, lags=10)
137
- print(f"Q = {lb.statistic:.2f}, p = {lb.p_value:.4f}")
138
- print(f"autocorrelated? {lb.has_autocorrelation}") # True
139
- ```
140
-
141
- ---
142
-
143
- These tools compose naturally: smooth a noisy signal, difference away a
144
- trend, test the result for stationarity, then decompose any remaining
145
- seasonality, all from `cds.stats`, no NumPy required.
@@ -1,40 +0,0 @@
1
- """Core data-models demo — Domain, Hypothesis, HypothesisStatus."""
2
-
3
- # Import directly from the defining module (not the cds.core re-export) to
4
- # give static analyzers the clearest possible view of these types.
5
- from cds.core.models import Domain, Hypothesis, HypothesisStatus
6
-
7
-
8
- def main() -> None:
9
- print("=== Domains ===")
10
- # __members__.values() is the Enum API's explicit member-collection view
11
- # (a Mapping's ValuesView). Functionally identical to iterating the
12
- # EnumType itself (same 6 members, same order), but the return type is an
13
- # unambiguously iterable mapping view — CodeQL's non-iterable-in-for-loop
14
- # query can resolve it where the EnumType iterator could not.
15
- for d in Domain.__members__.values():
16
- print(f" {d.name} = {d.value}")
17
-
18
- print("\n=== Constructing a Hypothesis ===")
19
- h = Hypothesis(
20
- id="H-001",
21
- domain=Domain.COSMOLOGY,
22
- research_question="Why is the Hubble expansion accelerating?",
23
- statement="A cosmological constant (Λ) drives late-time acceleration.",
24
- status=HypothesisStatus.TESTABLE,
25
- confidence=0.62,
26
- rationale="Type Ia supernova data favours accelerated expansion.",
27
- assumptions=["GR holds on cosmological scales", "Λ > 0"],
28
- predictions=["(m-M) vs z curve bends downward vs matter-only"],
29
- tags=["dark-energy", "lambda"],
30
- )
31
- print(repr(h))
32
- print("\n--- Markdown render ---")
33
- print(h.to_markdown())
34
-
35
- print("\n--- JSON serialisation ---")
36
- print(h.model_dump_json(indent=2)[:200] + " ...")
37
-
38
-
39
- if __name__ == "__main__":
40
- main()
@@ -1,60 +0,0 @@
1
- """Data analysis demo — loading, transforming, and plotting tabular data."""
2
-
3
- import os
4
- import tempfile
5
-
6
- from cds.data_analysis import (
7
- DataSet,
8
- load_csv,
9
- moving_average,
10
- normalize,
11
- plot_bar,
12
- plot_line,
13
- z_score,
14
- )
15
- from cds.data_analysis.dataset import Scalar
16
-
17
-
18
- def main() -> None:
19
- # Build a tiny CSV in a temp file so the demo needs no fixtures.
20
- csv_text = "day,temperature,sales\n1,18.0,100\n2,19.5,110\n3,22.0,140\n4,21.5,135\n5,23.0,160\n"
21
- path = os.path.join(tempfile.gettempdir(), "_cds_demo.csv")
22
- with open(path, "w", encoding="utf-8") as f:
23
- f.write(csv_text)
24
-
25
- print("=== Loading CSV ===")
26
- table = load_csv(path)
27
- print(f"headers: {table.headers}")
28
- print(f"rows: {len(table.rows)}")
29
-
30
- # Extract numeric columns (DataTable stores everything as strings).
31
- temps = [float(row[1]) for row in table.rows]
32
- sales = [float(row[2]) for row in table.rows]
33
-
34
- print("\n=== Normalisation ===")
35
- norm = normalize(temps)
36
- z = z_score(temps)
37
- print(f"normalized temps: {[round(v, 3) for v in norm]}")
38
- print(f"z-score temps : {[round(v, 3) for v in z]}")
39
-
40
- print("\n=== Smoothing ===")
41
- ma = moving_average(sales, window=2)
42
- print(f"2-day moving avg of sales: {[round(v, 3) for v in ma]}")
43
-
44
- print("\n=== ASCII Visualisation ===")
45
- plot_line(temps, title="temperature")
46
- plot_bar({"Mon": 100.0, "Tue": 110.0, "Wed": 140.0, "Thu": 135.0, "Fri": 160.0})
47
-
48
- print("\n=== DataSet helper ===")
49
- # DataSet expects a list of row-dicts; annotate so mypy widens the
50
- # value type to Scalar (int | float | str | bool | None) instead of
51
- # narrowing it to float, which would clash with the invariant list.
52
- data: list[dict[str, Scalar]] = [{"day": i, "temp": float(t)} for i, t in enumerate(temps)]
53
- ds = DataSet(data=data)
54
- print(f"columns: {ds.columns}")
55
- print(f"shape: {ds.shape}")
56
- print(ds.head(3))
57
-
58
-
59
- if __name__ == "__main__":
60
- main()
@@ -1,34 +0,0 @@
1
- """Ordinary differential equation solver demo."""
2
-
3
- from cds.diffeq import euler_method, midpoint_method, rk4, rk45, solve_system
4
-
5
-
6
- def main() -> None:
7
- # dy/dt = -y -> exact solution y(t) = e^-t, so y(1) = e^-1 ≈ 0.3679
8
- f = lambda t, y: -y # noqa: E731
9
- t0, y0, t_end = 0.0, 1.0, 1.0
10
-
11
- print("=== Solving dy/dt = -y, y(0)=1, evaluate at t=1 (exact = e^-1 ≈ 0.3679) ===")
12
- sol_euler = euler_method(f, t0=t0, y0=y0, t_end=t_end, dt=0.01)
13
- sol_mid = midpoint_method(f, t0=t0, y0=y0, t_end=t_end, dt=0.01)
14
- sol_rk4 = rk4(f, t0=t0, y0=y0, t_end=t_end, dt=0.1)
15
- sol_rk45 = rk45(f, t0=t0, y0=y0, t_end=t_end, rtol=1e-6)
16
- print(f"Euler (dt=0.01): {sol_euler.y[-1]:.6f}")
17
- print(f"Midpoint(dt=0.01): {sol_mid.y[-1]:.6f}")
18
- print(f"RK4 (dt=0.1) : {sol_rk4.y[-1]:.6f}")
19
- print(f"RK45 adaptive : {sol_rk45.y[-1]:.6f}")
20
-
21
- print("\n=== System: predator-prey (Lotka-Volterra) ===")
22
- alpha, beta, gamma, delta = 1.1, 0.4, 0.4, 0.1
23
-
24
- def lotka(t: float, state: list[float]) -> list[float]:
25
- x, y = state
26
- return [alpha * x - beta * x * y, delta * x * y - gamma * y]
27
-
28
- ts, ys = solve_system(lotka, t0=0.0, y0=[10.0, 5.0], t_end=15.0, dt=0.05)
29
- print(f"Final prey/predator state: {ys[-1]}")
30
- print(f"Trajectory length: {len(ts)} points")
31
-
32
-
33
- if __name__ == "__main__":
34
- main()
@@ -1,57 +0,0 @@
1
- """Discovery pipeline demo — mine correlation hypotheses, then evaluate one statistically."""
2
-
3
- import random
4
-
5
- from cds.hypothesis import EvaluationData, HypothesisEvaluator, mine_correlations
6
-
7
-
8
- def main() -> None:
9
- # --- Synthetic dataset: one strong relationship plus pure-noise columns ---
10
- rng = random.Random(42)
11
- n_rows = 120
12
- dose = [rng.uniform(0.0, 10.0) for _ in range(n_rows)]
13
- response = [2.0 * d + rng.gauss(0.0, 1.5) for d in dose]
14
- data: dict[str, list[float]] = {
15
- "dose": dose,
16
- "response": response,
17
- "lab_temperature": [rng.gauss(21.0, 1.0) for _ in range(n_rows)],
18
- "instrument_drift": [rng.gauss(0.0, 2.0) for _ in range(n_rows)],
19
- }
20
-
21
- print("=== Mining correlation hypotheses ===")
22
- mined = mine_correlations(data)
23
- print(f"{len(mined)} hypothesis(ies) survived the |r| >= 0.3 and p < 0.05 filters:\n")
24
- for hit in mined:
25
- print(
26
- f"[{hit.strength}] {hit.feature_a} ~ {hit.feature_b}: "
27
- f"r={hit.correlation:+.4f}, p={hit.p_value:.3e}"
28
- )
29
- print(f" {hit.hypothesis.statement}")
30
- print(f" confidence: {hit.hypothesis.confidence:.2f}\n")
31
-
32
- # --- Evaluate the strongest mined hypothesis ---
33
- print("=== Evaluating the strongest mined hypothesis ===")
34
- print("The evaluator runs classical tests (t-test/ANOVA/chi-square), so the")
35
- print("association is translated into a group comparison: mean response below")
36
- print("vs above the median dose.")
37
- top = mined[0]
38
- doses = data[top.feature_a]
39
- responses = data[top.feature_b]
40
- median_dose = sorted(doses)[len(doses) // 2]
41
- low_group = [r for d, r in zip(doses, responses) if d <= median_dose]
42
- high_group = [r for d, r in zip(doses, responses) if d > median_dose]
43
-
44
- evaluator = HypothesisEvaluator(alpha=0.05)
45
- payload: EvaluationData = {"groups": [low_group, high_group]}
46
- result = evaluator.evaluate(top.hypothesis, payload)
47
- print(f"Test : {result.test_name}")
48
- print(f"Statistic : {result.statistic:.4f}")
49
- print(f"p-value : {result.p_value:.3e}")
50
- print(f"Effect size : {result.effect_size_label} = {result.effect_size:.3f}")
51
- print(f"Significant : {result.is_significant}")
52
- print(f"Conclusion : {result.conclusion}")
53
- print(f"Hypothesis status after evaluation: {top.hypothesis.status.value}")
54
-
55
-
56
- if __name__ == "__main__":
57
- main()
@@ -1,81 +0,0 @@
1
- """Ensemble showcase — forest, boosting, naive Bayes and voting on seeded blobs."""
2
-
3
- import random
4
-
5
- from cds.ml import (
6
- GaussianNaiveBayes,
7
- GradientBoostingClassifier,
8
- RandomForestClassifier,
9
- accuracy,
10
- )
11
- from cds.ml.model_selection import SupervisedModel
12
- from cds.ml.voting import VotingClassifier
13
-
14
-
15
- def make_dataset(n_per_class: int, seed: int) -> tuple[list[list[float]], list[str]]:
16
- """Two Gaussian blobs in 2-D: class A around (-1, -1), class B around (1, 1)."""
17
- rng = random.Random(seed)
18
- X: list[list[float]] = []
19
- y: list[str] = []
20
- for _ in range(n_per_class):
21
- X.append([rng.gauss(-1.0, 0.9), rng.gauss(-1.0, 0.9)])
22
- y.append("A")
23
- X.append([rng.gauss(1.0, 0.9), rng.gauss(1.0, 0.9)])
24
- y.append("B")
25
- return X, y
26
-
27
-
28
- def report(name: str, model: SupervisedModel, X_test: list[list[float]], y_test: list[str]) -> None:
29
- y_pred = [model.predict(row) for row in X_test]
30
- acc = accuracy(y_test, y_pred)
31
- print(f" {name:<28} accuracy = {acc:.3f}")
32
-
33
-
34
- def main() -> None:
35
- X, y = make_dataset(n_per_class=60, seed=42)
36
-
37
- indices = list(range(len(X)))
38
- random.Random(7).shuffle(indices)
39
- split = 80
40
- train_idx = indices[:split]
41
- test_idx = indices[split:]
42
- X_train = [X[i] for i in train_idx]
43
- y_train = [y[i] for i in train_idx]
44
- X_test = [X[i] for i in test_idx]
45
- y_test = [y[i] for i in test_idx]
46
-
47
- print(f"=== Ensemble showcase on {len(X_train)} train / {len(X_test)} test samples ===\n")
48
- print("Individual models:")
49
-
50
- forest = RandomForestClassifier(n_trees=30, max_depth=4, seed=42)
51
- boost = GradientBoostingClassifier(n_estimators=40, learning_rate=0.3, max_depth=2)
52
- bayes = GaussianNaiveBayes()
53
- individuals: list[tuple[str, SupervisedModel]] = [
54
- ("RandomForest", forest),
55
- ("GradientBoosting", boost),
56
- ("GaussianNaiveBayes", bayes),
57
- ]
58
- for name, model in individuals:
59
- model.fit(X_train, y_train)
60
- report(name, model, X_test, y_test)
61
-
62
- # --- Voting ensembles over fresh members with the same hyperparameters ---
63
- print("\nVoting ensembles:")
64
- hard_members: list[tuple[str, SupervisedModel]] = [
65
- ("forest", RandomForestClassifier(n_trees=30, max_depth=4, seed=42)),
66
- ("boost", GradientBoostingClassifier(n_estimators=40, learning_rate=0.3, max_depth=2)),
67
- ("bayes", GaussianNaiveBayes()),
68
- ]
69
- soft_members: list[tuple[str, SupervisedModel]] = [
70
- ("forest", RandomForestClassifier(n_trees=30, max_depth=4, seed=42)),
71
- ("boost", GradientBoostingClassifier(n_estimators=40, learning_rate=0.3, max_depth=2)),
72
- ("bayes", GaussianNaiveBayes()),
73
- ]
74
- hard_vote = VotingClassifier(hard_members, voting="hard").fit(X_train, y_train)
75
- soft_vote = VotingClassifier(soft_members, voting="soft").fit(X_train, y_train)
76
- report("VotingClassifier (hard)", hard_vote, X_test, y_test)
77
- report("VotingClassifier (soft)", soft_vote, X_test, y_test)
78
-
79
-
80
- if __name__ == "__main__":
81
- main()
@@ -1,32 +0,0 @@
1
- """2-D FFT demo (row-column Cooley-Tukey)."""
2
-
3
- from cds.signals import fft2, ifft2
4
-
5
- # A small 4x4 "image"
6
-
7
-
8
- def main() -> None:
9
- image: list[list[float | complex]] = [
10
- [1.0, 2.0, 3.0, 4.0],
11
- [2.0, 3.0, 4.0, 5.0],
12
- [3.0, 4.0, 5.0, 6.0],
13
- [4.0, 5.0, 6.0, 7.0],
14
- ]
15
-
16
- print("=== 2-D FFT ===")
17
- spectrum = fft2(image)
18
- print("DC component (sum of all pixels):")
19
- print(f" F[0][0] = {spectrum[0][0].real:.1f} (expected {sum(sum(r) for r in image):.1f})")
20
-
21
- print("\nMagnitude spectrum |F[u][v]|:")
22
- for row in spectrum:
23
- print(" " + " ".join(f"{abs(x):6.2f}" for x in row))
24
-
25
- print("\n=== Inverse 2-D FFT (round-trip) ===")
26
- recovered = ifft2(spectrum)
27
- max_err = max(abs(recovered[i][j].real - image[i][j]) for i in range(4) for j in range(4))
28
- print(f"Max reconstruction error: {max_err:.2e}")
29
-
30
-
31
- if __name__ == "__main__":
32
- main()
@@ -1,49 +0,0 @@
1
- """Graph algorithms demo — BFS/DFS, Dijkstra, Kruskal MST, topo sort, cycle detection."""
2
-
3
- from cds.graph import (
4
- Graph,
5
- bfs,
6
- dfs,
7
- dijkstra,
8
- has_cycle,
9
- kruskal_mst,
10
- topological_sort,
11
- )
12
-
13
-
14
- def main() -> None:
15
- # Undirected weighted graph (integer nodes).
16
- g = Graph(n_vertices=6, directed=False)
17
- edges = [(0, 1, 4), (0, 2, 2), (1, 2, 1), (1, 3, 5), (2, 3, 8), (2, 4, 10), (3, 4, 2)]
18
- for u, v, w in edges:
19
- g.add_edge(u, v, weight=w)
20
-
21
- print("=== Traversal ===")
22
- print(f"BFS from 0: {bfs(g, 0)}")
23
- print(f"DFS from 0: {dfs(g, 0)}")
24
-
25
- print("\n=== Shortest Paths (Dijkstra) ===")
26
- dists, prev = dijkstra(g, 0)
27
- for node in sorted(dists):
28
- print(f" dist(0 -> {node}) = {dists[node]:.1f}")
29
-
30
- print("\n=== Minimum Spanning Tree (Kruskal) ===")
31
- mst_edges, total = kruskal_mst(g)
32
- for e in mst_edges:
33
- print(f" {e.src} -- {e.dst} (w={e.weight})")
34
- print(f" MST total weight = {total}")
35
-
36
- print("\n=== Cycle Detection (undirected) ===")
37
- print(f"has_cycle: {has_cycle(g)}")
38
-
39
- print("\n=== Topological Sort (DAG) ===")
40
- dag = Graph(n_vertices=3, directed=True)
41
- dag.add_edge(0, 1, weight=1)
42
- dag.add_edge(1, 2, weight=1)
43
- dag.add_edge(0, 2, weight=1)
44
- order = topological_sort(dag)
45
- print(f"order: {order}")
46
-
47
-
48
- if __name__ == "__main__":
49
- main()