CUQIpy 1.3.0.post0.dev58__tar.gz → 1.3.0.post0.dev86__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.

Potentially problematic release.


This version of CUQIpy might be problematic. Click here for more details.

Files changed (128) hide show
  1. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/CUQIpy.egg-info/PKG-INFO +5 -3
  2. cuqipy-1.3.0.post0.dev86/CUQIpy.egg-info/requires.txt +10 -0
  3. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/PKG-INFO +5 -3
  4. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/_version.py +3 -3
  5. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/distribution/__init__.py +1 -1
  6. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/distribution/_truncated_normal.py +1 -1
  7. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/distribution/_uniform.py +36 -2
  8. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/implicitprior/_regularizedGaussian.py +8 -2
  9. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/utilities/_utilities.py +1 -1
  10. cuqipy-1.3.0.post0.dev86/requirements.txt +6 -0
  11. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/tests/test_bayesian_inversion.py +10 -0
  12. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/tests/test_distribution.py +13 -1
  13. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/tests/test_distributions_shape.py +1 -0
  14. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/tests/test_implicit_priors.py +3 -0
  15. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/tests/test_model.py +1 -1
  16. cuqipy-1.3.0.post0.dev58/CUQIpy.egg-info/requires.txt +0 -5
  17. cuqipy-1.3.0.post0.dev58/requirements.txt +0 -5
  18. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/CUQIpy.egg-info/SOURCES.txt +0 -0
  19. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/CUQIpy.egg-info/dependency_links.txt +0 -0
  20. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/CUQIpy.egg-info/top_level.txt +0 -0
  21. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/LICENSE +0 -0
  22. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/README.md +0 -0
  23. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/__init__.py +0 -0
  24. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/_messages.py +0 -0
  25. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/array/__init__.py +0 -0
  26. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/array/_array.py +0 -0
  27. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/config.py +0 -0
  28. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/data/__init__.py +0 -0
  29. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/data/_data.py +0 -0
  30. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/data/astronaut.npz +0 -0
  31. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/data/camera.npz +0 -0
  32. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/data/cat.npz +0 -0
  33. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/data/cookie.png +0 -0
  34. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/data/satellite.mat +0 -0
  35. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/density/__init__.py +0 -0
  36. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/density/_density.py +0 -0
  37. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/diagnostics.py +0 -0
  38. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/distribution/_beta.py +0 -0
  39. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/distribution/_cauchy.py +0 -0
  40. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/distribution/_cmrf.py +0 -0
  41. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/distribution/_custom.py +0 -0
  42. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/distribution/_distribution.py +0 -0
  43. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/distribution/_gamma.py +0 -0
  44. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/distribution/_gaussian.py +0 -0
  45. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/distribution/_gmrf.py +0 -0
  46. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/distribution/_inverse_gamma.py +0 -0
  47. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/distribution/_joint_distribution.py +0 -0
  48. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/distribution/_laplace.py +0 -0
  49. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/distribution/_lmrf.py +0 -0
  50. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/distribution/_lognormal.py +0 -0
  51. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/distribution/_modifiedhalfnormal.py +0 -0
  52. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/distribution/_normal.py +0 -0
  53. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/distribution/_posterior.py +0 -0
  54. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/distribution/_smoothed_laplace.py +0 -0
  55. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/experimental/__init__.py +0 -0
  56. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/experimental/algebra/__init__.py +0 -0
  57. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/experimental/algebra/_ast.py +0 -0
  58. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/experimental/algebra/_orderedset.py +0 -0
  59. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/experimental/algebra/_randomvariable.py +0 -0
  60. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/experimental/geometry/__init__.py +0 -0
  61. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/experimental/geometry/_productgeometry.py +0 -0
  62. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/experimental/mcmc/__init__.py +0 -0
  63. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/experimental/mcmc/_conjugate.py +0 -0
  64. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/experimental/mcmc/_conjugate_approx.py +0 -0
  65. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/experimental/mcmc/_cwmh.py +0 -0
  66. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/experimental/mcmc/_direct.py +0 -0
  67. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/experimental/mcmc/_gibbs.py +0 -0
  68. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/experimental/mcmc/_hmc.py +0 -0
  69. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/experimental/mcmc/_langevin_algorithm.py +0 -0
  70. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/experimental/mcmc/_laplace_approximation.py +0 -0
  71. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/experimental/mcmc/_mh.py +0 -0
  72. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/experimental/mcmc/_pcn.py +0 -0
  73. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/experimental/mcmc/_rto.py +0 -0
  74. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/experimental/mcmc/_sampler.py +0 -0
  75. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/experimental/mcmc/_utilities.py +0 -0
  76. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/geometry/__init__.py +0 -0
  77. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/geometry/_geometry.py +0 -0
  78. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/implicitprior/__init__.py +0 -0
  79. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/implicitprior/_regularizedGMRF.py +0 -0
  80. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/implicitprior/_regularizedUnboundedUniform.py +0 -0
  81. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/implicitprior/_restorator.py +0 -0
  82. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/likelihood/__init__.py +0 -0
  83. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/likelihood/_likelihood.py +0 -0
  84. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/model/__init__.py +0 -0
  85. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/model/_model.py +0 -0
  86. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/operator/__init__.py +0 -0
  87. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/operator/_operator.py +0 -0
  88. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/pde/__init__.py +0 -0
  89. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/pde/_pde.py +0 -0
  90. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/problem/__init__.py +0 -0
  91. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/problem/_problem.py +0 -0
  92. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/sampler/__init__.py +0 -0
  93. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/sampler/_conjugate.py +0 -0
  94. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/sampler/_conjugate_approx.py +0 -0
  95. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/sampler/_cwmh.py +0 -0
  96. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/sampler/_gibbs.py +0 -0
  97. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/sampler/_hmc.py +0 -0
  98. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/sampler/_langevin_algorithm.py +0 -0
  99. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/sampler/_laplace_approximation.py +0 -0
  100. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/sampler/_mh.py +0 -0
  101. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/sampler/_pcn.py +0 -0
  102. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/sampler/_rto.py +0 -0
  103. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/sampler/_sampler.py +0 -0
  104. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/samples/__init__.py +0 -0
  105. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/samples/_samples.py +0 -0
  106. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/solver/__init__.py +0 -0
  107. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/solver/_solver.py +0 -0
  108. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/testproblem/__init__.py +0 -0
  109. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/testproblem/_testproblem.py +0 -0
  110. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/utilities/__init__.py +0 -0
  111. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/cuqi/utilities/_get_python_variable_name.py +0 -0
  112. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/pyproject.toml +0 -0
  113. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/setup.cfg +0 -0
  114. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/setup.py +0 -0
  115. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/tests/test_MRFs.py +0 -0
  116. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/tests/test_abstract_distribution_density.py +0 -0
  117. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/tests/test_density.py +0 -0
  118. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/tests/test_geometry.py +0 -0
  119. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/tests/test_joint_distribution.py +0 -0
  120. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/tests/test_likelihood.py +0 -0
  121. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/tests/test_pde.py +0 -0
  122. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/tests/test_posterior.py +0 -0
  123. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/tests/test_problem.py +0 -0
  124. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/tests/test_sampler.py +0 -0
  125. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/tests/test_samples.py +0 -0
  126. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/tests/test_solver.py +0 -0
  127. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/tests/test_testproblem.py +0 -0
  128. {cuqipy-1.3.0.post0.dev58 → cuqipy-1.3.0.post0.dev86}/tests/test_utilities.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: CUQIpy
3
- Version: 1.3.0.post0.dev58
3
+ Version: 1.3.0.post0.dev86
4
4
  Summary: Computational Uncertainty Quantification for Inverse problems in Python
5
5
  Maintainer-email: "Nicolai A. B. Riis" <nabr@dtu.dk>, "Jakob S. Jørgensen" <jakj@dtu.dk>, "Amal M. Alghamdi" <amaal@dtu.dk>, Chao Zhang <chaz@dtu.dk>
6
6
  License: Apache License
@@ -202,9 +202,11 @@ Description-Content-Type: text/markdown
202
202
  License-File: LICENSE
203
203
  Requires-Dist: matplotlib
204
204
  Requires-Dist: numpy>=1.17.0
205
- Requires-Dist: scipy<1.13
205
+ Requires-Dist: scipy==1.12.0; python_version <= "3.9"
206
+ Requires-Dist: scipy; python_version > "3.9"
206
207
  Requires-Dist: arviz
207
208
  Requires-Dist: tqdm
209
+ Dynamic: license-file
208
210
 
209
211
  <div align="center">
210
212
  <img src="https://cuqi-dtu.github.io/CUQIpy/_static/logo.png" alt="CUQIpy logo" width="250"/>
@@ -0,0 +1,10 @@
1
+ matplotlib
2
+ numpy>=1.17.0
3
+ arviz
4
+ tqdm
5
+
6
+ [:python_version <= "3.9"]
7
+ scipy==1.12.0
8
+
9
+ [:python_version > "3.9"]
10
+ scipy
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: CUQIpy
3
- Version: 1.3.0.post0.dev58
3
+ Version: 1.3.0.post0.dev86
4
4
  Summary: Computational Uncertainty Quantification for Inverse problems in Python
5
5
  Maintainer-email: "Nicolai A. B. Riis" <nabr@dtu.dk>, "Jakob S. Jørgensen" <jakj@dtu.dk>, "Amal M. Alghamdi" <amaal@dtu.dk>, Chao Zhang <chaz@dtu.dk>
6
6
  License: Apache License
@@ -202,9 +202,11 @@ Description-Content-Type: text/markdown
202
202
  License-File: LICENSE
203
203
  Requires-Dist: matplotlib
204
204
  Requires-Dist: numpy>=1.17.0
205
- Requires-Dist: scipy<1.13
205
+ Requires-Dist: scipy==1.12.0; python_version <= "3.9"
206
+ Requires-Dist: scipy; python_version > "3.9"
206
207
  Requires-Dist: arviz
207
208
  Requires-Dist: tqdm
209
+ Dynamic: license-file
208
210
 
209
211
  <div align="center">
210
212
  <img src="https://cuqi-dtu.github.io/CUQIpy/_static/logo.png" alt="CUQIpy logo" width="250"/>
@@ -8,11 +8,11 @@ import json
8
8
 
9
9
  version_json = '''
10
10
  {
11
- "date": "2025-03-19T09:20:29+0100",
11
+ "date": "2025-04-10T10:50:04+0200",
12
12
  "dirty": false,
13
13
  "error": null,
14
- "full-revisionid": "0b4dcbc57fa9d6e7e9844b42d0434f9e335c572a",
15
- "version": "1.3.0.post0.dev58"
14
+ "full-revisionid": "fe056d15f6ff918511cf7ee579dc8e7689c1dbc4",
15
+ "version": "1.3.0.post0.dev86"
16
16
  }
17
17
  ''' # END VERSION_JSON
18
18
 
@@ -14,6 +14,6 @@ from ._lognormal import Lognormal
14
14
  from ._normal import Normal
15
15
  from ._truncated_normal import TruncatedNormal
16
16
  from ._posterior import Posterior
17
- from ._uniform import Uniform
17
+ from ._uniform import Uniform, UnboundedUniform
18
18
  from ._custom import UserDefinedDistribution, DistributionGallery
19
19
  from ._joint_distribution import JointDistribution, _StackedJointDistribution, MultipleLikelihoodPosterior
@@ -107,7 +107,7 @@ class TruncatedNormal(Distribution):
107
107
  """
108
108
  # check if x falls in the range between np.array a and b
109
109
  if np.any(x < self.low) or np.any(x > self.high):
110
- return np.NaN*np.ones_like(x)
110
+ return np.nan*np.ones_like(x)
111
111
  else:
112
112
  return self._normal.gradient(x, *args, **kwargs)
113
113
 
@@ -1,5 +1,6 @@
1
1
  import numpy as np
2
2
  from cuqi.distribution import Distribution
3
+ from cuqi.geometry import Geometry
3
4
 
4
5
  class Uniform(Distribution):
5
6
 
@@ -46,7 +47,7 @@ class Uniform(Distribution):
46
47
  Computes the gradient of logpdf at the given values of x.
47
48
  """
48
49
  if np.any(x < self.low) or np.any(x > self.high):
49
- return np.NaN*np.ones_like(x)
50
+ return np.nan*np.ones_like(x)
50
51
  else:
51
52
  return np.zeros_like(x)
52
53
 
@@ -57,4 +58,37 @@ class Uniform(Distribution):
57
58
  else:
58
59
  s = np.random.uniform(self.low, self.high, (N,self.dim)).T
59
60
 
60
- return s
61
+ return s
62
+
63
+ class UnboundedUniform(Distribution):
64
+ """
65
+ Unbounded uniform distribution. This is a special case of the
66
+ Uniform distribution, where the lower and upper bounds are set to
67
+ -inf and inf, respectively. This distribution is not normalizable,
68
+ and therefore cannot be sampled from. It is mainly used for
69
+ initializing non-informative priors.
70
+ Parameters
71
+ ----------
72
+ geometry : int or Geometry
73
+ The geometry of the distribution. If an integer is given, it is
74
+ interpreted as the dimension of the distribution. If a
75
+ Geometry object is given, its par_dim attribute is used.
76
+ """
77
+ def __init__(self, geometry, is_symmetric=True, **kwargs):
78
+ super().__init__(geometry=geometry, is_symmetric=is_symmetric, **kwargs)
79
+
80
+ def logpdf(self, x):
81
+ """
82
+ Evaluate the logarithm of the unnormalized PDF at the given values of x.
83
+ """
84
+ # Always return 1.0 (the unnormalized log PDF)
85
+ return 1.0
86
+
87
+ def gradient(self, x):
88
+ """
89
+ Computes the gradient of logpdf at the given values of x.
90
+ """
91
+ return np.zeros_like(x)
92
+
93
+ def _sample(self, N=1, rng=None):
94
+ raise NotImplementedError("Cannot sample from UnboundedUniform distribution")
@@ -189,12 +189,18 @@ class RegularizedGaussian(Distribution):
189
189
  elif c_lower == "increasing":
190
190
  if not isinstance(self.geometry, Continuous1D):
191
191
  raise ValueError("Geometry not supported for " + c_lower)
192
- self._constraint_prox = lambda z, _: spoptimize.isotonic_regression(z, increasing=True).x
192
+ if hasattr(spoptimize, 'isotonic_regression'):
193
+ self._constraint_prox = lambda z, _: spoptimize.isotonic_regression(z, increasing=True).x
194
+ else:
195
+ raise AttributeError(f"The function 'isotonic_regression' does not exist in scipy.optimize. Installed scipy version: {spoptimize.__version__}. You need to install a scipy >= 1.12.0")
193
196
  self._preset["constraint"] = "increasing"
194
197
  elif c_lower == "decreasing":
195
198
  if not isinstance(self.geometry, Continuous1D):
196
199
  raise ValueError("Geometry not supported for " + c_lower)
197
- self._constraint_prox = lambda z, _: spoptimize.isotonic_regression(z, increasing=False).x
200
+ if hasattr(spoptimize, 'isotonic_regression'):
201
+ self._constraint_prox = lambda z, _: spoptimize.isotonic_regression(z, increasing=False).x
202
+ else:
203
+ raise AttributeError(f"The function 'isotonic_regression' does not exist in scipy.optimize. Installed scipy version: {spoptimize.__version__}. You need to install a scipy >= 1.12.0")
198
204
  self._preset["constraint"] = "decreasing"
199
205
  elif c_lower == "convex":
200
206
  if not isinstance(self.geometry, Continuous1D):
@@ -188,7 +188,7 @@ def approx_derivative(func, wrt, direction=None, epsilon=np.sqrt(np.finfo(float)
188
188
  # We compute the Jacobian matrix of func using forward differences.
189
189
  # If the function is scalar-valued, we compute the gradient instead.
190
190
  # If the direction is provided, we compute the direction-Jacobian product.
191
- wrt = np.asfarray(wrt)
191
+ wrt = np.asarray(wrt)
192
192
  f0 = func(wrt)
193
193
  Matr = np.zeros([infer_len(wrt), infer_len(f0)])
194
194
  dx = np.zeros(len(wrt))
@@ -0,0 +1,6 @@
1
+ matplotlib
2
+ numpy>=1.17.0
3
+ scipy==1.12.0; python_version <= '3.9'
4
+ scipy; python_version > '3.9'
5
+ arviz
6
+ tqdm
@@ -2,7 +2,9 @@ from typing import Dict
2
2
 
3
3
  import pytest
4
4
  import numpy as np
5
+ import scipy
5
6
  import sys
7
+ from packaging import version
6
8
 
7
9
  from cuqi.testproblem import Deconvolution1D
8
10
  from cuqi.distribution import Gaussian, GMRF, CMRF, LMRF, Gamma
@@ -25,6 +27,14 @@ def test_TP_BayesianProblem_sample(copy_reference, TP_type, phantom, prior, Ns,
25
27
  # SKIP NUTS test if not windows (for now)
26
28
  if isinstance(prior, CMRF) and not sys.platform.startswith('win'):
27
29
  pytest.skip("NUTS(CMRF) regression test is not implemented for this platform")
30
+ elif (
31
+ isinstance(prior, RegularizedGaussian)
32
+ or isinstance(prior, RegularizedGMRF)
33
+ ) and version.parse(scipy.__version__) >= version.parse('1.13.0'):
34
+ pytest.skip(
35
+ "Saved reference data is not consistent with scipy>=1.13.0 "
36
+ "(due to different default behaviour of scipy.optimize)"
37
+ )
28
38
 
29
39
  np.random.seed(19937)
30
40
 
@@ -203,7 +203,6 @@ def test_Uniform_logpdf(low, high, toeval, expected):
203
203
  UD = cuqi.distribution.Uniform(low, high)
204
204
  assert np.allclose(UD.logpdf(toeval), expected)
205
205
 
206
-
207
206
  @pytest.mark.parametrize("low,high,expected",[(np.array([1, .5]),
208
207
  np.array([2, 2.5]),
209
208
  np.array([[1.5507979 , 1.29090474, 1.89294695],
@@ -217,6 +216,19 @@ def test_Uniform_sample(low, high, expected):
217
216
  print(cuqi_samples)
218
217
  assert np.allclose(cuqi_samples.samples, expected)
219
218
 
219
+ def test_UnboundedUniform_logpdf_and_gradient():
220
+ x1 = cuqi.distribution.UnboundedUniform(geometry=1)
221
+ assert np.allclose(x1.logpdf(np.array([1])), 1.0)
222
+ assert np.allclose(x1.gradient(np.array([0])), np.array([0]))
223
+ x2 = cuqi.distribution.UnboundedUniform(geometry=cuqi.geometry.Discrete(2))
224
+ assert np.allclose(x2.logpdf(np.array([1, 2])), 1.0)
225
+ assert np.allclose(x2.gradient(np.array([0, 0])), np.array([0, 0]))
226
+
227
+ def test_UnboundedUniform_sample():
228
+ x = cuqi.distribution.UnboundedUniform(geometry=2)
229
+ with pytest.raises(NotImplementedError, match="Cannot sample from UnboundedUniform distribution"):
230
+ x.sample()
231
+
220
232
  @pytest.mark.parametrize("distribution, kwargs",
221
233
  [(cuqi.distribution.Uniform,
222
234
  {'low':np.array([2, 2.5, 3,5]),
@@ -13,6 +13,7 @@ ignore_list = [
13
13
  "Posterior",
14
14
  "Distribution",
15
15
  "JointGaussianSqrtPrec",
16
+ "UnboundedUniform",
16
17
  ]
17
18
 
18
19
  # Define cases to skip (these are TODO)
@@ -1,6 +1,8 @@
1
1
  import cuqi
2
2
  import numpy as np
3
+ import scipy
3
4
  import pytest
5
+ from packaging import version
4
6
 
5
7
  def test_RegularizedGaussian_default_init():
6
8
  """ Test that the implicit regularized Gaussian requires at least 1 regularization argument """
@@ -186,6 +188,7 @@ def test_RegularizedGaussian_double_preset():
186
188
  assert len(x.proximal[0]) == 2
187
189
  assert len(x.proximal[1]) == 2
188
190
 
191
+ @pytest.mark.skipif(version.parse(scipy.__version__) < version.parse('1.12.0'), reason="isotonic_regression in not available in scipy < 1.12.0")
189
192
  def test_regression_increasing():
190
193
  """ Regression test for the increasing constraints in RegularizedGaussian"""
191
194
 
@@ -19,7 +19,7 @@ def test_LinearModel_getMatrix(seed):
19
19
  mat1 = model1.get_matrix() #Normal matrix
20
20
  mat2 = model2.get_matrix() #Sparse matrix (generated from functions)
21
21
 
22
- assert np.allclose(mat1,mat2.A)
22
+ assert np.allclose(mat1,mat2.toarray())
23
23
 
24
24
  def test_initialize_model_dim():
25
25
  model1 = cuqi.model.Model(lambda x:x, range_geometry=4, domain_geometry=4)
@@ -1,5 +0,0 @@
1
- matplotlib
2
- numpy>=1.17.0
3
- scipy<1.13
4
- arviz
5
- tqdm
@@ -1,5 +0,0 @@
1
- matplotlib
2
- numpy>=1.17.0
3
- scipy<1.13
4
- arviz
5
- tqdm