derivkit 1.0.0__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 (268) hide show
  1. derivkit-1.0.0/.github/ISSUE_TEMPLATE/derivkit-adoption.yml +73 -0
  2. derivkit-1.0.0/.github/scripts/adoption_from_issue.py +155 -0
  3. derivkit-1.0.0/.github/workflows/adoption-issue-to-pr.yml +50 -0
  4. derivkit-1.0.0/.github/workflows/ci.yml +59 -0
  5. derivkit-1.0.0/.github/workflows/docs.yml +35 -0
  6. derivkit-1.0.0/.github/workflows/publish.yml +26 -0
  7. derivkit-1.0.0/.gitignore +20 -0
  8. derivkit-1.0.0/CITATION.cff +19 -0
  9. derivkit-1.0.0/LICENSE +21 -0
  10. derivkit-1.0.0/PKG-INFO +50 -0
  11. derivkit-1.0.0/README.md +14 -0
  12. derivkit-1.0.0/docs/Makefile +24 -0
  13. derivkit-1.0.0/docs/_ext/adoption.py +144 -0
  14. derivkit-1.0.0/docs/_static/derivkit.css +196 -0
  15. derivkit-1.0.0/docs/_static/logos/logo-black.png +0 -0
  16. derivkit-1.0.0/docs/_static/logos/logo-blue.png +0 -0
  17. derivkit-1.0.0/docs/_templates/pages_redirect.html +10 -0
  18. derivkit-1.0.0/docs/_templates/sidebar/variant-selector.html +16 -0
  19. derivkit-1.0.0/docs/about/index.rst +34 -0
  20. derivkit-1.0.0/docs/about/kits/calculus_kit.rst +163 -0
  21. derivkit-1.0.0/docs/about/kits/derivative_kit.rst +329 -0
  22. derivkit-1.0.0/docs/about/kits/forecast_kit.rst +597 -0
  23. derivkit-1.0.0/docs/about/kits/index.rst +57 -0
  24. derivkit-1.0.0/docs/about/kits/likelihood_kit.rst +135 -0
  25. derivkit-1.0.0/docs/about/overview.rst +32 -0
  26. derivkit-1.0.0/docs/adoption/software/augur.yml +7 -0
  27. derivkit-1.0.0/docs/adoption/software/cocoa.yml +11 -0
  28. derivkit-1.0.0/docs/api/derivkit.calculus.calculus_core.rst +7 -0
  29. derivkit-1.0.0/docs/api/derivkit.calculus.gradient.rst +7 -0
  30. derivkit-1.0.0/docs/api/derivkit.calculus.hessian.rst +7 -0
  31. derivkit-1.0.0/docs/api/derivkit.calculus.hyper_hessian.rst +7 -0
  32. derivkit-1.0.0/docs/api/derivkit.calculus.jacobian.rst +7 -0
  33. derivkit-1.0.0/docs/api/derivkit.calculus.rst +22 -0
  34. derivkit-1.0.0/docs/api/derivkit.calculus_kit.rst +7 -0
  35. derivkit-1.0.0/docs/api/derivkit.derivative_kit.rst +7 -0
  36. derivkit-1.0.0/docs/api/derivkit.derivatives.adaptive.adaptive_fit.rst +7 -0
  37. derivkit-1.0.0/docs/api/derivkit.derivatives.adaptive.batch_eval.rst +7 -0
  38. derivkit-1.0.0/docs/api/derivkit.derivatives.adaptive.diagnostics.rst +7 -0
  39. derivkit-1.0.0/docs/api/derivkit.derivatives.adaptive.grid.rst +7 -0
  40. derivkit-1.0.0/docs/api/derivkit.derivatives.adaptive.polyfit_utils.rst +7 -0
  41. derivkit-1.0.0/docs/api/derivkit.derivatives.adaptive.rst +24 -0
  42. derivkit-1.0.0/docs/api/derivkit.derivatives.adaptive.spacing.rst +7 -0
  43. derivkit-1.0.0/docs/api/derivkit.derivatives.adaptive.transforms.rst +7 -0
  44. derivkit-1.0.0/docs/api/derivkit.derivatives.autodiff.jax_autodiff.rst +7 -0
  45. derivkit-1.0.0/docs/api/derivkit.derivatives.autodiff.jax_core.rst +7 -0
  46. derivkit-1.0.0/docs/api/derivkit.derivatives.autodiff.jax_utils.rst +7 -0
  47. derivkit-1.0.0/docs/api/derivkit.derivatives.autodiff.rst +20 -0
  48. derivkit-1.0.0/docs/api/derivkit.derivatives.finite.batch_eval.rst +7 -0
  49. derivkit-1.0.0/docs/api/derivkit.derivatives.finite.core.rst +7 -0
  50. derivkit-1.0.0/docs/api/derivkit.derivatives.finite.extrapolators.rst +7 -0
  51. derivkit-1.0.0/docs/api/derivkit.derivatives.finite.finite_difference.rst +7 -0
  52. derivkit-1.0.0/docs/api/derivkit.derivatives.finite.rst +22 -0
  53. derivkit-1.0.0/docs/api/derivkit.derivatives.finite.stencil.rst +7 -0
  54. derivkit-1.0.0/docs/api/derivkit.derivatives.fornberg.rst +7 -0
  55. derivkit-1.0.0/docs/api/derivkit.derivatives.local_polynomial_derivative.diagnostics.rst +7 -0
  56. derivkit-1.0.0/docs/api/derivkit.derivatives.local_polynomial_derivative.fit.rst +7 -0
  57. derivkit-1.0.0/docs/api/derivkit.derivatives.local_polynomial_derivative.local_poly_config.rst +7 -0
  58. derivkit-1.0.0/docs/api/derivkit.derivatives.local_polynomial_derivative.local_polynomial_derivative.rst +7 -0
  59. derivkit-1.0.0/docs/api/derivkit.derivatives.local_polynomial_derivative.rst +22 -0
  60. derivkit-1.0.0/docs/api/derivkit.derivatives.local_polynomial_derivative.sampling.rst +7 -0
  61. derivkit-1.0.0/docs/api/derivkit.derivatives.rst +30 -0
  62. derivkit-1.0.0/docs/api/derivkit.derivatives.tabulated_model.one_d.rst +7 -0
  63. derivkit-1.0.0/docs/api/derivkit.derivatives.tabulated_model.rst +18 -0
  64. derivkit-1.0.0/docs/api/derivkit.forecast_kit.rst +7 -0
  65. derivkit-1.0.0/docs/api/derivkit.forecasting.dali.rst +7 -0
  66. derivkit-1.0.0/docs/api/derivkit.forecasting.expansions.rst +7 -0
  67. derivkit-1.0.0/docs/api/derivkit.forecasting.fisher.rst +7 -0
  68. derivkit-1.0.0/docs/api/derivkit.forecasting.fisher_gaussian.rst +7 -0
  69. derivkit-1.0.0/docs/api/derivkit.forecasting.fisher_xy.rst +7 -0
  70. derivkit-1.0.0/docs/api/derivkit.forecasting.forecast_core.rst +7 -0
  71. derivkit-1.0.0/docs/api/derivkit.forecasting.getdist_dali_samples.rst +7 -0
  72. derivkit-1.0.0/docs/api/derivkit.forecasting.getdist_fisher_samples.rst +7 -0
  73. derivkit-1.0.0/docs/api/derivkit.forecasting.laplace.rst +7 -0
  74. derivkit-1.0.0/docs/api/derivkit.forecasting.priors_core.rst +7 -0
  75. derivkit-1.0.0/docs/api/derivkit.forecasting.rst +28 -0
  76. derivkit-1.0.0/docs/api/derivkit.forecasting.sampling_utils.rst +7 -0
  77. derivkit-1.0.0/docs/api/derivkit.likelihood_kit.rst +7 -0
  78. derivkit-1.0.0/docs/api/derivkit.likelihoods.gaussian.rst +7 -0
  79. derivkit-1.0.0/docs/api/derivkit.likelihoods.poisson.rst +7 -0
  80. derivkit-1.0.0/docs/api/derivkit.likelihoods.rst +19 -0
  81. derivkit-1.0.0/docs/api/derivkit.rst +33 -0
  82. derivkit-1.0.0/docs/api/derivkit.utils.concurrency.rst +7 -0
  83. derivkit-1.0.0/docs/api/derivkit.utils.extrapolation.rst +7 -0
  84. derivkit-1.0.0/docs/api/derivkit.utils.linalg.rst +7 -0
  85. derivkit-1.0.0/docs/api/derivkit.utils.logger.rst +7 -0
  86. derivkit-1.0.0/docs/api/derivkit.utils.numerics.rst +7 -0
  87. derivkit-1.0.0/docs/api/derivkit.utils.rst +25 -0
  88. derivkit-1.0.0/docs/api/derivkit.utils.sandbox.rst +7 -0
  89. derivkit-1.0.0/docs/api/derivkit.utils.types.rst +7 -0
  90. derivkit-1.0.0/docs/api/derivkit.utils.validate.rst +7 -0
  91. derivkit-1.0.0/docs/api/index.rst +7 -0
  92. derivkit-1.0.0/docs/assets/favicon.png +0 -0
  93. derivkit-1.0.0/docs/assets/logos/logo-black.png +0 -0
  94. derivkit-1.0.0/docs/assets/logos/logo-blue.png +0 -0
  95. derivkit-1.0.0/docs/assets/logos/logo-red.png +0 -0
  96. derivkit-1.0.0/docs/assets/logos/logo-yellow.png +0 -0
  97. derivkit-1.0.0/docs/assets/plots/adaptive_demo_linear_noisy_order1.png +0 -0
  98. derivkit-1.0.0/docs/assets/plots/dali_vs_fisher_2d_1and2sigma.png +0 -0
  99. derivkit-1.0.0/docs/assets/plots/dali_vs_fisher_exact_1d.png +0 -0
  100. derivkit-1.0.0/docs/assets/plots/fisher_bias_demo_1and2sigma.png +0 -0
  101. derivkit-1.0.0/docs/citation.rst +52 -0
  102. derivkit-1.0.0/docs/conf.py +193 -0
  103. derivkit-1.0.0/docs/contributing.rst +125 -0
  104. derivkit-1.0.0/docs/examples/calculus/gradient.rst +133 -0
  105. derivkit-1.0.0/docs/examples/calculus/hessian.rst +165 -0
  106. derivkit-1.0.0/docs/examples/calculus/hyperhessian.rst +146 -0
  107. derivkit-1.0.0/docs/examples/calculus/index.rst +47 -0
  108. derivkit-1.0.0/docs/examples/calculus/jacobian.rst +125 -0
  109. derivkit-1.0.0/docs/examples/derivatives/adaptive_fit.rst +217 -0
  110. derivkit-1.0.0/docs/examples/derivatives/finite_differences.rst +236 -0
  111. derivkit-1.0.0/docs/examples/derivatives/index.rst +53 -0
  112. derivkit-1.0.0/docs/examples/derivatives/local_poly.rst +162 -0
  113. derivkit-1.0.0/docs/examples/derivatives/multiple_points.rst +110 -0
  114. derivkit-1.0.0/docs/examples/derivatives/tabulated.rst +106 -0
  115. derivkit-1.0.0/docs/examples/forecasting/dali.rst +155 -0
  116. derivkit-1.0.0/docs/examples/forecasting/dali_contours.rst +554 -0
  117. derivkit-1.0.0/docs/examples/forecasting/fisher.rst +156 -0
  118. derivkit-1.0.0/docs/examples/forecasting/fisher_bias.rst +274 -0
  119. derivkit-1.0.0/docs/examples/forecasting/fisher_contours.rst +378 -0
  120. derivkit-1.0.0/docs/examples/forecasting/fisher_gauss.rst +212 -0
  121. derivkit-1.0.0/docs/examples/forecasting/fisher_xy.rst +266 -0
  122. derivkit-1.0.0/docs/examples/forecasting/index.rst +85 -0
  123. derivkit-1.0.0/docs/examples/forecasting/laplace_approx.rst +140 -0
  124. derivkit-1.0.0/docs/examples/forecasting/laplace_contours.rst +298 -0
  125. derivkit-1.0.0/docs/examples/index.rst +51 -0
  126. derivkit-1.0.0/docs/examples/likelihoods/gaussian.rst +142 -0
  127. derivkit-1.0.0/docs/examples/likelihoods/index.rst +32 -0
  128. derivkit-1.0.0/docs/examples/likelihoods/poissonian.rst +118 -0
  129. derivkit-1.0.0/docs/index.rst +56 -0
  130. derivkit-1.0.0/docs/installation.rst +34 -0
  131. derivkit-1.0.0/docs/license.rst +11 -0
  132. derivkit-1.0.0/docs/make.bat +35 -0
  133. derivkit-1.0.0/docs/team.rst +65 -0
  134. derivkit-1.0.0/docs/workflows.rst +627 -0
  135. derivkit-1.0.0/pyproject.toml +229 -0
  136. derivkit-1.0.0/setup.cfg +4 -0
  137. derivkit-1.0.0/src/derivkit/__init__.py +22 -0
  138. derivkit-1.0.0/src/derivkit/calculus/__init__.py +17 -0
  139. derivkit-1.0.0/src/derivkit/calculus/calculus_core.py +152 -0
  140. derivkit-1.0.0/src/derivkit/calculus/gradient.py +97 -0
  141. derivkit-1.0.0/src/derivkit/calculus/hessian.py +528 -0
  142. derivkit-1.0.0/src/derivkit/calculus/hyper_hessian.py +296 -0
  143. derivkit-1.0.0/src/derivkit/calculus/jacobian.py +156 -0
  144. derivkit-1.0.0/src/derivkit/calculus_kit.py +128 -0
  145. derivkit-1.0.0/src/derivkit/derivative_kit.py +315 -0
  146. derivkit-1.0.0/src/derivkit/derivatives/__init__.py +6 -0
  147. derivkit-1.0.0/src/derivkit/derivatives/adaptive/__init__.py +5 -0
  148. derivkit-1.0.0/src/derivkit/derivatives/adaptive/adaptive_fit.py +238 -0
  149. derivkit-1.0.0/src/derivkit/derivatives/adaptive/batch_eval.py +179 -0
  150. derivkit-1.0.0/src/derivkit/derivatives/adaptive/diagnostics.py +325 -0
  151. derivkit-1.0.0/src/derivkit/derivatives/adaptive/grid.py +333 -0
  152. derivkit-1.0.0/src/derivkit/derivatives/adaptive/polyfit_utils.py +513 -0
  153. derivkit-1.0.0/src/derivkit/derivatives/adaptive/spacing.py +66 -0
  154. derivkit-1.0.0/src/derivkit/derivatives/adaptive/transforms.py +245 -0
  155. derivkit-1.0.0/src/derivkit/derivatives/autodiff/__init__.py +1 -0
  156. derivkit-1.0.0/src/derivkit/derivatives/autodiff/jax_autodiff.py +95 -0
  157. derivkit-1.0.0/src/derivkit/derivatives/autodiff/jax_core.py +217 -0
  158. derivkit-1.0.0/src/derivkit/derivatives/autodiff/jax_utils.py +146 -0
  159. derivkit-1.0.0/src/derivkit/derivatives/finite/__init__.py +5 -0
  160. derivkit-1.0.0/src/derivkit/derivatives/finite/batch_eval.py +91 -0
  161. derivkit-1.0.0/src/derivkit/derivatives/finite/core.py +84 -0
  162. derivkit-1.0.0/src/derivkit/derivatives/finite/extrapolators.py +511 -0
  163. derivkit-1.0.0/src/derivkit/derivatives/finite/finite_difference.py +247 -0
  164. derivkit-1.0.0/src/derivkit/derivatives/finite/stencil.py +206 -0
  165. derivkit-1.0.0/src/derivkit/derivatives/fornberg.py +245 -0
  166. derivkit-1.0.0/src/derivkit/derivatives/local_polynomial_derivative/__init__.py +1 -0
  167. derivkit-1.0.0/src/derivkit/derivatives/local_polynomial_derivative/diagnostics.py +90 -0
  168. derivkit-1.0.0/src/derivkit/derivatives/local_polynomial_derivative/fit.py +199 -0
  169. derivkit-1.0.0/src/derivkit/derivatives/local_polynomial_derivative/local_poly_config.py +95 -0
  170. derivkit-1.0.0/src/derivkit/derivatives/local_polynomial_derivative/local_polynomial_derivative.py +205 -0
  171. derivkit-1.0.0/src/derivkit/derivatives/local_polynomial_derivative/sampling.py +72 -0
  172. derivkit-1.0.0/src/derivkit/derivatives/tabulated_model/__init__.py +1 -0
  173. derivkit-1.0.0/src/derivkit/derivatives/tabulated_model/one_d.py +247 -0
  174. derivkit-1.0.0/src/derivkit/forecast_kit.py +783 -0
  175. derivkit-1.0.0/src/derivkit/forecasting/__init__.py +1 -0
  176. derivkit-1.0.0/src/derivkit/forecasting/dali.py +78 -0
  177. derivkit-1.0.0/src/derivkit/forecasting/expansions.py +486 -0
  178. derivkit-1.0.0/src/derivkit/forecasting/fisher.py +298 -0
  179. derivkit-1.0.0/src/derivkit/forecasting/fisher_gaussian.py +171 -0
  180. derivkit-1.0.0/src/derivkit/forecasting/fisher_xy.py +357 -0
  181. derivkit-1.0.0/src/derivkit/forecasting/forecast_core.py +313 -0
  182. derivkit-1.0.0/src/derivkit/forecasting/getdist_dali_samples.py +429 -0
  183. derivkit-1.0.0/src/derivkit/forecasting/getdist_fisher_samples.py +235 -0
  184. derivkit-1.0.0/src/derivkit/forecasting/laplace.py +259 -0
  185. derivkit-1.0.0/src/derivkit/forecasting/priors_core.py +860 -0
  186. derivkit-1.0.0/src/derivkit/forecasting/sampling_utils.py +388 -0
  187. derivkit-1.0.0/src/derivkit/likelihood_kit.py +114 -0
  188. derivkit-1.0.0/src/derivkit/likelihoods/__init__.py +1 -0
  189. derivkit-1.0.0/src/derivkit/likelihoods/gaussian.py +136 -0
  190. derivkit-1.0.0/src/derivkit/likelihoods/poisson.py +176 -0
  191. derivkit-1.0.0/src/derivkit/utils/__init__.py +13 -0
  192. derivkit-1.0.0/src/derivkit/utils/concurrency.py +213 -0
  193. derivkit-1.0.0/src/derivkit/utils/extrapolation.py +254 -0
  194. derivkit-1.0.0/src/derivkit/utils/linalg.py +513 -0
  195. derivkit-1.0.0/src/derivkit/utils/logger.py +26 -0
  196. derivkit-1.0.0/src/derivkit/utils/numerics.py +262 -0
  197. derivkit-1.0.0/src/derivkit/utils/sandbox.py +74 -0
  198. derivkit-1.0.0/src/derivkit/utils/types.py +15 -0
  199. derivkit-1.0.0/src/derivkit/utils/validate.py +811 -0
  200. derivkit-1.0.0/src/derivkit.egg-info/PKG-INFO +50 -0
  201. derivkit-1.0.0/src/derivkit.egg-info/SOURCES.txt +266 -0
  202. derivkit-1.0.0/src/derivkit.egg-info/dependency_links.txt +1 -0
  203. derivkit-1.0.0/src/derivkit.egg-info/requires.txt +24 -0
  204. derivkit-1.0.0/src/derivkit.egg-info/top_level.txt +1 -0
  205. derivkit-1.0.0/tests/conftest.py +83 -0
  206. derivkit-1.0.0/tests/test_adaptive_fit.py +246 -0
  207. derivkit-1.0.0/tests/test_adaptive_fit_batch_eval.py +75 -0
  208. derivkit-1.0.0/tests/test_adaptive_fit_batch_eval_speed.py +91 -0
  209. derivkit-1.0.0/tests/test_adaptive_fit_grid.py +67 -0
  210. derivkit-1.0.0/tests/test_adaptive_fit_polyfit_utils.py +138 -0
  211. derivkit-1.0.0/tests/test_adaptive_fit_spacing.py +49 -0
  212. derivkit-1.0.0/tests/test_adaptive_fit_transforms.py +139 -0
  213. derivkit-1.0.0/tests/test_autodiff_jax_autodiff.py +77 -0
  214. derivkit-1.0.0/tests/test_autodiff_jax_core.py +140 -0
  215. derivkit-1.0.0/tests/test_autodiff_jax_utils.py +76 -0
  216. derivkit-1.0.0/tests/test_caclulus_kit.py +222 -0
  217. derivkit-1.0.0/tests/test_calculus_calculus_core.py +183 -0
  218. derivkit-1.0.0/tests/test_calculus_gradient.py +136 -0
  219. derivkit-1.0.0/tests/test_calculus_hessian.py +206 -0
  220. derivkit-1.0.0/tests/test_calculus_hyper_hessian.py +99 -0
  221. derivkit-1.0.0/tests/test_calculus_jacobian.py +288 -0
  222. derivkit-1.0.0/tests/test_derivative_kit.py +380 -0
  223. derivkit-1.0.0/tests/test_derivative_kit_methods_grid.py +187 -0
  224. derivkit-1.0.0/tests/test_derivative_kit_output_layout.py +124 -0
  225. derivkit-1.0.0/tests/test_finite_diff.py +246 -0
  226. derivkit-1.0.0/tests/test_finite_diff_core.py +184 -0
  227. derivkit-1.0.0/tests/test_finite_diff_extrapolators.py +472 -0
  228. derivkit-1.0.0/tests/test_finite_diff_fornberg.py +212 -0
  229. derivkit-1.0.0/tests/test_finite_diff_richardson.py +335 -0
  230. derivkit-1.0.0/tests/test_finite_diff_threads.py +133 -0
  231. derivkit-1.0.0/tests/test_finite_diff_validation.py +107 -0
  232. derivkit-1.0.0/tests/test_forecast_expansions.py +419 -0
  233. derivkit-1.0.0/tests/test_forecast_fisher_gaussian.py +223 -0
  234. derivkit-1.0.0/tests/test_forecast_fisher_xy.py +212 -0
  235. derivkit-1.0.0/tests/test_forecast_forecast_core.py +703 -0
  236. derivkit-1.0.0/tests/test_forecast_getdist_dali_samples.py +369 -0
  237. derivkit-1.0.0/tests/test_forecast_getdist_fisher_samples.py +205 -0
  238. derivkit-1.0.0/tests/test_forecast_integration_sampling_utils.py +297 -0
  239. derivkit-1.0.0/tests/test_forecast_kit.py +936 -0
  240. derivkit-1.0.0/tests/test_forecast_kit_dali.py +313 -0
  241. derivkit-1.0.0/tests/test_forecast_kit_fisher.py +277 -0
  242. derivkit-1.0.0/tests/test_forecast_kit_fisher_bias.py +617 -0
  243. derivkit-1.0.0/tests/test_forecast_kit_parallel.py +391 -0
  244. derivkit-1.0.0/tests/test_forecast_laplace.py +164 -0
  245. derivkit-1.0.0/tests/test_forecast_priors_core.py +309 -0
  246. derivkit-1.0.0/tests/test_forecast_sampling_utils.py +297 -0
  247. derivkit-1.0.0/tests/test_forecasting_fisher_xy.py +212 -0
  248. derivkit-1.0.0/tests/test_known_derivatives.py +159 -0
  249. derivkit-1.0.0/tests/test_likelihood_kit.py +99 -0
  250. derivkit-1.0.0/tests/test_likelihoods_gaussian.py +198 -0
  251. derivkit-1.0.0/tests/test_likelihoods_poisson.py +199 -0
  252. derivkit-1.0.0/tests/test_local_poly_deriv.py +245 -0
  253. derivkit-1.0.0/tests/test_local_poly_deriv_config.py +82 -0
  254. derivkit-1.0.0/tests/test_local_poly_deriv_fit.py +265 -0
  255. derivkit-1.0.0/tests/test_local_poly_deriv_sampling.py +130 -0
  256. derivkit-1.0.0/tests/test_local_poly_deriv_vs_finite_adaptive.py +148 -0
  257. derivkit-1.0.0/tests/test_tabulated_one_d.py +285 -0
  258. derivkit-1.0.0/tests/test_tabulated_one_d_calculus.py +138 -0
  259. derivkit-1.0.0/tests/test_tabulated_one_d_derivatives.py +136 -0
  260. derivkit-1.0.0/tests/test_tabulated_one_d_forecasting.py +185 -0
  261. derivkit-1.0.0/tests/test_utils_concurrency.py +239 -0
  262. derivkit-1.0.0/tests/test_utils_extrapolation.py +212 -0
  263. derivkit-1.0.0/tests/test_utils_linalg.py +415 -0
  264. derivkit-1.0.0/tests/test_utils_numerics.py +95 -0
  265. derivkit-1.0.0/tests/test_utils_sandbox.py +44 -0
  266. derivkit-1.0.0/tests/test_utils_validate_pt1.py +196 -0
  267. derivkit-1.0.0/tests/test_utils_validate_pt2.py +577 -0
  268. derivkit-1.0.0/uv.lock +2832 -0
@@ -0,0 +1,73 @@
1
+ name: DerivKit adoption entry
2
+ description: Request that a software project or publication using DerivKit be listed in the docs.
3
+ title: "[Adoption] "
4
+ labels: ["adoption"]
5
+ body:
6
+ - type: dropdown
7
+ id: entry_type
8
+ attributes:
9
+ label: Entry type
10
+ description: Where should this be listed on the Citation page?
11
+ options:
12
+ - Software / pipeline
13
+ - Publication
14
+ validations:
15
+ required: true
16
+
17
+ - type: input
18
+ id: name
19
+ attributes:
20
+ label: Name
21
+ placeholder: "e.g. Augur, COCOA, or Paper title"
22
+ validations:
23
+ required: true
24
+
25
+ - type: textarea
26
+ id: description
27
+ attributes:
28
+ label: Description
29
+ description: >
30
+ Required. This text will appear on the Citation page. Please write 2–5 lines.
31
+ placeholder: |
32
+ Software example:
33
+ A short description of what the package/pipeline does, and how DerivKit is used
34
+ (e.g. Fisher forecasts, DALI expansion, numerical derivatives for likelihoods).
35
+
36
+ Publication example:
37
+ A short description of what the paper does, and where DerivKit enters the analysis
38
+ (e.g. derivative evaluation, forecasting, validation, etc.).
39
+ validations:
40
+ required: true
41
+
42
+ - type: input
43
+ id: link
44
+ attributes:
45
+ label: Link (required)
46
+ description: >
47
+ Required. For software: repository URL. For publications: arXiv or DOI URL.
48
+ placeholder: |
49
+ Software: https://github.com/org/repo
50
+ Publication: https://arxiv.org/abs/XXXX.XXXXX (or https://doi.org/...)
51
+ validations:
52
+ required: true
53
+
54
+ - type: textarea
55
+ id: citation
56
+ attributes:
57
+ label: Citation (publications only)
58
+ description: >
59
+ Optional but recommended for publications. Free-form reference text (journal/venue + DOI/arXiv).
60
+ BibTeX is fine too.
61
+ placeholder: |
62
+ Author A., Author B. (YEAR), Journal/venue, DOI or arXiv:XXXX.XXXXX
63
+ validations:
64
+ required: true
65
+
66
+ - type: input
67
+ id: contact
68
+ attributes:
69
+ label: Contact (optional)
70
+ description: Email or GitHub handle in case maintainers need clarification.
71
+ placeholder: "@username or name@example.com"
72
+ validations:
73
+ required: true
@@ -0,0 +1,155 @@
1
+ """Create adoption YAML entries from GitHub adoption issues.
2
+
3
+ This script is used by a GitHub Action. It parses the issue form body and writes a
4
+ YAML file into ``docs/adoption/`` so the docs can render the adoption list.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ import os
10
+ import re
11
+ from dataclasses import dataclass
12
+ from pathlib import Path
13
+
14
+
15
+ @dataclass(frozen=True)
16
+ class AdoptionIssue:
17
+ """Structured fields extracted from a DerivKit adoption issue."""
18
+ entry_type: str # "software" or "publication"
19
+ name: str
20
+ description: str
21
+ link: str | None
22
+ citation: str | None
23
+ contact: str | None
24
+ issue_number: int
25
+ issue_url: str
26
+
27
+
28
+ _FIELD_RE = re.compile(r"^###\s+(?P<label>.+?)\s*$")
29
+
30
+
31
+ def _normalize_type(s: str) -> str:
32
+ """Normalize entry type string to lowercase and remove "software" / "publication"."""
33
+ s = s.strip().lower()
34
+ if "software" in s:
35
+ return "software"
36
+ if "publication" in s:
37
+ return "publication"
38
+ raise ValueError(f"Unrecognized entry type: {s!r}")
39
+
40
+
41
+ def _slugify(name: str) -> str:
42
+ """Generate a slug for a given entry name."""
43
+ slug = name.strip().lower()
44
+ slug = re.sub(r"[^a-z0-9]+", "-", slug).strip("-")
45
+ return slug or "adoption-entry"
46
+
47
+
48
+ def _parse_issue_form(body: str) -> dict[str, str]:
49
+ """Parse a GitHub issue-form body into a mapping of field labels to values.
50
+
51
+ The issue form is rendered as markdown sections of the form:
52
+
53
+ ### Field label
54
+ value
55
+ """
56
+ out: dict[str, str] = {}
57
+ current: str | None = None
58
+ lines: list[str] = []
59
+ for raw in body.splitlines():
60
+ m = _FIELD_RE.match(raw)
61
+ if m:
62
+ if current is not None:
63
+ out[current] = "\n".join(lines).strip()
64
+ current = m.group("label").strip()
65
+ lines = []
66
+ continue
67
+ if current is not None:
68
+ lines.append(raw)
69
+ if current is not None:
70
+ out[current] = "\n".join(lines).strip()
71
+ return out
72
+
73
+
74
+ def _yaml_quote_block(s: str) -> str:
75
+ # use YAML folded style
76
+ s = s.rstrip()
77
+ # indent by two spaces under key
78
+ return ">\n" + "\n".join(f" {line}".rstrip() for line in s.splitlines())
79
+
80
+
81
+ def build_yaml(issue: AdoptionIssue) -> str:
82
+ """Render a single adoption entry as YAML text."""
83
+ if issue.entry_type == "software":
84
+ if not issue.link:
85
+ raise ValueError("Software entry requires a repository URL (repo).")
86
+ if issue.entry_type == "publication":
87
+ if not issue.citation:
88
+ raise ValueError("Publication entries require a citation line.")
89
+
90
+ reference = [
91
+ f"name: {issue.name}",
92
+ f"kind: {issue.entry_type}",
93
+ "description: " + _yaml_quote_block(issue.description),
94
+ f"link: {issue.link}",
95
+ f"source_issue: {issue.issue_url}",
96
+ ]
97
+
98
+ if issue.citation:
99
+ reference.append("citation: " + _yaml_quote_block(issue.citation))
100
+ reference.append("")
101
+ return "\n".join(reference)
102
+
103
+
104
+ def main() -> None:
105
+ """Entry point for GitHub Actions to generate the adoption YAML file."""
106
+ issue_body = os.environ["ISSUE_BODY"]
107
+ issue_number = int(os.environ["ISSUE_NUMBER"])
108
+ issue_url = os.environ["ISSUE_URL"]
109
+
110
+ fields = _parse_issue_form(issue_body)
111
+
112
+ entry_type = _normalize_type(fields.get("Entry type", ""))
113
+ name = fields.get("Name", "").strip()
114
+ description = fields.get("Description", "").strip()
115
+ link = fields.get("Link (required)", "").strip() or None
116
+ citation = fields.get("Citation (publications only)", "").strip() or None
117
+ contact = fields.get("Contact (optional)", "").strip() or None
118
+
119
+ if not name:
120
+ raise ValueError("Missing required field: Name")
121
+ if not description:
122
+ raise ValueError("Missing required field: Description")
123
+
124
+ issue = AdoptionIssue(
125
+ entry_type=entry_type,
126
+ name=name,
127
+ description=description,
128
+ link=link,
129
+ citation=citation,
130
+ contact=contact,
131
+ issue_number=issue_number,
132
+ issue_url=issue_url,
133
+ )
134
+
135
+ slug = _slugify(name)
136
+ suffix = f"-{issue_number}"
137
+
138
+ if entry_type == "software":
139
+ base = Path("docs/adoption/software") / slug
140
+ elif entry_type == "publication":
141
+ base = Path("docs/adoption/publications") / slug
142
+ else:
143
+ raise ValueError("Unsupported adoption type")
144
+
145
+ out = base.with_suffix(".yml")
146
+ if out.exists():
147
+ out = Path(f"{base}{suffix}.yml")
148
+
149
+ out.parent.mkdir(parents=True, exist_ok=True)
150
+ out.write_text(build_yaml(issue), encoding="utf-8")
151
+ print(str(out))
152
+
153
+
154
+ if __name__ == "__main__":
155
+ main()
@@ -0,0 +1,50 @@
1
+ name: Adoption issue -> PR
2
+
3
+ "on":
4
+ issues:
5
+ types: [labeled]
6
+
7
+ permissions:
8
+ contents: write
9
+ pull-requests: write
10
+
11
+ jobs:
12
+ create_pr:
13
+ # Safer gate: only run when a maintainer adds this label
14
+ if: github.event.label.name == 'adoption-approved'
15
+ runs-on: ubuntu-latest
16
+
17
+ steps:
18
+ - name: Checkout
19
+ uses: actions/checkout@v4
20
+
21
+ - name: Set up Python
22
+ uses: actions/setup-python@v5
23
+ with:
24
+ python-version: "3.12"
25
+
26
+ - name: Install dependencies
27
+ run: |
28
+ python -m pip install --upgrade pip
29
+ python -m pip install pyyaml
30
+
31
+ - name: Generate adoption YAML from issue
32
+ env:
33
+ ISSUE_BODY: ${{ github.event.issue.body }}
34
+ ISSUE_NUMBER: ${{ github.event.issue.number }}
35
+ ISSUE_URL: ${{ github.event.issue.html_url }}
36
+ run: |
37
+ python .github/scripts/adoption_from_issue.py
38
+
39
+ - name: Create PR
40
+ uses: peter-evans/create-pull-request@v6
41
+ with:
42
+ branch: automation/adoption-${{ github.event.issue.number }}
43
+ title: "docs: add adoption entry (#${{ github.event.issue.number }})"
44
+ commit-message: "docs: add adoption entry (#${{ github.event.issue.number }})"
45
+ body: |
46
+ Auto-generated from adoption issue #${{ github.event.issue.number }}.
47
+ add-paths: |
48
+ docs/adoption/**
49
+ labels: |
50
+ adoption
@@ -0,0 +1,59 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+ branches:
7
+ - main
8
+ schedule:
9
+ - cron: '23 1 * * 0'
10
+ workflow_dispatch:
11
+
12
+ jobs:
13
+ testing:
14
+ runs-on: ${{ matrix.os }}
15
+ strategy:
16
+ matrix:
17
+ os: [ubuntu-latest]
18
+ python-version: ["3.10", "3.11", "3.12", "3.13"]
19
+ steps:
20
+ - uses: actions/checkout@v4
21
+
22
+ - name: Set up uv with Python ${{ matrix.python-version }}
23
+ uses: astral-sh/setup-uv@v7
24
+ with:
25
+ version: "0.8.22" # Fix the version of uv
26
+ python-version: ${{ matrix.python-version }}
27
+
28
+ - name: Install dependencies
29
+ run: uv sync --extra test
30
+
31
+ - name: Run tests
32
+ run: uv run tox -m test
33
+
34
+ linting:
35
+ runs-on: ${{ matrix.os }}
36
+ strategy:
37
+ matrix:
38
+ os: [ubuntu-latest]
39
+ python-version: ["3.12"]
40
+ steps:
41
+ - uses: actions/checkout@v4
42
+
43
+ - name: Set up uv with Python 3.12
44
+ uses: astral-sh/setup-uv@v7
45
+ with:
46
+ version: "0.8.22" # Fix the version of uv
47
+
48
+ - name: Install dependencies
49
+ run: uv sync --extra lint
50
+
51
+ - name: Run ruff
52
+ run: uv run tox -e lint -- --output-format github
53
+
54
+ finalise:
55
+ runs-on: ubuntu-latest
56
+ needs: [testing, linting]
57
+ steps:
58
+ - name: finalise
59
+ run: echo "All done"
@@ -0,0 +1,35 @@
1
+ name: Deploy Sphinx Documentation
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ jobs:
9
+ publish_sphinx_docs:
10
+ runs-on: ubuntu-latest
11
+ permissions:
12
+ contents: write
13
+ steps:
14
+ - uses: actions/checkout@v3
15
+
16
+ - uses: actions/setup-python@v3
17
+ with:
18
+ python-version: "3.13"
19
+
20
+ - name: Install dependencies
21
+ run: |
22
+ pip install -e .
23
+
24
+ - name: Sphinx build
25
+ run: |
26
+ tox -e docs-releases
27
+
28
+ - name: Deploy
29
+ uses: peaceiris/actions-gh-pages@v3
30
+ with:
31
+ publish_branch: gh-pages
32
+ github_token: ${{ secrets.GITHUB_TOKEN }}
33
+ publish_dir: docs/_build/html
34
+ cname: docs.derivkit.org
35
+ force_orphan: true
@@ -0,0 +1,26 @@
1
+ name: "Publish new versions of DerivKit to PyPI"
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - v*
7
+
8
+ jobs:
9
+ run:
10
+ runs-on: ubuntu-latest
11
+ environment:
12
+ name: pypi
13
+ permissions:
14
+ id-token: write
15
+ contents: read
16
+ steps:
17
+ - name: Checkout
18
+ uses: actions/checkout@v6
19
+ - name: Install uv
20
+ uses: astral-sh/setup-uv@v7
21
+ - name: Install Python 3.13
22
+ run: uv python install 3.13
23
+ - name: Build
24
+ run: uv build
25
+ - name: Publish
26
+ run: uv publish
@@ -0,0 +1,20 @@
1
+ .idea
2
+ *__pycache__
3
+ logs/
4
+ plots_tests/
5
+ *.egg-info
6
+ venv
7
+ build
8
+ dist
9
+ .tox
10
+ .cache
11
+ docs/_build
12
+
13
+ # Notebooks
14
+ *.ipynb
15
+ .ipynb_checkpoints/
16
+ notebooks/
17
+ notebooks/plots/*.png
18
+ notebooks/plots/*.pdf
19
+ notebooks/logs/
20
+ docs/_generated/
@@ -0,0 +1,19 @@
1
+ cff-version: 1.2.0
2
+ message: "If you use DerivKit, please cite it as below."
3
+ title: "DerivKit"
4
+ type: software
5
+ authors:
6
+ - given-names: "Nikolina"
7
+ family-names: "Šarčević"
8
+ email: "nikolina.sarcevic@gmail.com"
9
+ orcid: 0000-0001-7301-6415
10
+ - given-names: "Matthijs"
11
+ family-names: "van der Wild"
12
+ email: "matthijs@vanderwild.com"
13
+ orcid: 0000-0002-3949-3063
14
+ - given-names: "Cynthia"
15
+ family-names: "Trendafilova"
16
+ email: "cyntrendafilova@gmail.com"
17
+ orcid: 0000-0001-5500-4058
18
+ license: "MIT"
19
+ repository-code: "https://github.com/derivkit/derivkit"
derivkit-1.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Nikolina Šarčević
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,50 @@
1
+ Metadata-Version: 2.4
2
+ Name: derivkit
3
+ Version: 1.0.0
4
+ Summary: A robust toolkit for stable numerical derivatives
5
+ Author-email: Nikolina Šarčević <nikolina.sarcevic@gmail.com>, Matthijs van der Wild <matthijs@vanderwild.com>, Cynthia Trendafilova <cyntrendafilova@gmail.com>
6
+ License-Expression: MIT
7
+ Classifier: Intended Audience :: Science/Research
8
+ Classifier: Operating System :: OS Independent
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Topic :: Scientific/Engineering :: Astronomy
11
+ Classifier: Topic :: Scientific/Engineering :: Physics
12
+ Requires-Python: >=3.10
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Requires-Dist: numdifftools
16
+ Requires-Dist: numpy
17
+ Requires-Dist: multiprocess
18
+ Requires-Dist: scipy
19
+ Requires-Dist: tox
20
+ Requires-Dist: getdist
21
+ Requires-Dist: emcee
22
+ Provides-Extra: test
23
+ Requires-Dist: pytest; extra == "test"
24
+ Provides-Extra: docs
25
+ Requires-Dist: sphinx<9; extra == "docs"
26
+ Requires-Dist: sphinx-design; extra == "docs"
27
+ Requires-Dist: sphinx-multiversion; extra == "docs"
28
+ Requires-Dist: furo; extra == "docs"
29
+ Requires-Dist: sphinx-copybutton; extra == "docs"
30
+ Provides-Extra: lint
31
+ Requires-Dist: ruff; extra == "lint"
32
+ Provides-Extra: jax
33
+ Requires-Dist: jax>=0.4; extra == "jax"
34
+ Requires-Dist: jaxlib>=0.4; extra == "jax"
35
+ Dynamic: license-file
36
+
37
+ # derivkit
38
+
39
+ [![CI](https://github.com/derivkit/derivkit/actions/workflows/ci.yml/badge.svg)](https://github.com/derivkit/derivkit/actions/workflows/ci.yml)
40
+ [![Deploy Sphinx Documentation](https://github.com/derivkit/derivkit/actions/workflows/docs.yml/badge.svg)](https://github.com/derivkit/derivkit/actions/workflows/docs.yml)
41
+ [![License](https://img.shields.io/github/license/derivkit/derivkit)](LICENSE)
42
+
43
+
44
+ **DerivKit** is a robust Python toolkit for stable numerical derivatives, built for scientific computing, cosmology, and any domain requiring accurate gradients or higher-order expansions.
45
+
46
+ Detailed documentation, examples, and API reference can be found at the [derivkit documentation](https://docs.derivkit.org).
47
+
48
+
49
+ ## License
50
+ MIT License © 2025 Niko Šarčević, Matthijs van der Wild, Cynthia Trendafilova and contributors.
@@ -0,0 +1,14 @@
1
+ # derivkit
2
+
3
+ [![CI](https://github.com/derivkit/derivkit/actions/workflows/ci.yml/badge.svg)](https://github.com/derivkit/derivkit/actions/workflows/ci.yml)
4
+ [![Deploy Sphinx Documentation](https://github.com/derivkit/derivkit/actions/workflows/docs.yml/badge.svg)](https://github.com/derivkit/derivkit/actions/workflows/docs.yml)
5
+ [![License](https://img.shields.io/github/license/derivkit/derivkit)](LICENSE)
6
+
7
+
8
+ **DerivKit** is a robust Python toolkit for stable numerical derivatives, built for scientific computing, cosmology, and any domain requiring accurate gradients or higher-order expansions.
9
+
10
+ Detailed documentation, examples, and API reference can be found at the [derivkit documentation](https://docs.derivkit.org).
11
+
12
+
13
+ ## License
14
+ MIT License © 2025 Niko Šarčević, Matthijs van der Wild, Cynthia Trendafilova and contributors.
@@ -0,0 +1,24 @@
1
+ # Minimal makefile for Sphinx documentation
2
+ #
3
+
4
+ # You can set these variables from the command line, and also
5
+ # from the environment for the first two.
6
+ SPHINXOPTS ?=
7
+ SPHINXBUILD ?= sphinx-build
8
+ SOURCEDIR = .
9
+ BUILDDIR = _build
10
+
11
+ # Put it first so that "make" without argument is like "make help".
12
+ help:
13
+ @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14
+
15
+ clean:
16
+ @$(SPHINXBUILD) -M clean "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O);
17
+ cd _build; git worktree add -f html gh-pages
18
+
19
+ .PHONY: help Makefile
20
+
21
+ # Catch-all target: route all unknown targets to Sphinx using the new
22
+ # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
23
+ %: Makefile
24
+ @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)