CUQIpy 1.3.0.post0.dev58__py3-none-any.whl → 1.3.0.post0.dev86__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of CUQIpy might be problematic. Click here for more details.
- cuqi/_version.py +3 -3
- cuqi/distribution/__init__.py +1 -1
- cuqi/distribution/_truncated_normal.py +1 -1
- cuqi/distribution/_uniform.py +36 -2
- cuqi/implicitprior/_regularizedGaussian.py +8 -2
- cuqi/utilities/_utilities.py +1 -1
- {cuqipy-1.3.0.post0.dev58.dist-info → cuqipy-1.3.0.post0.dev86.dist-info}/METADATA +5 -3
- {cuqipy-1.3.0.post0.dev58.dist-info → cuqipy-1.3.0.post0.dev86.dist-info}/RECORD +11 -11
- {cuqipy-1.3.0.post0.dev58.dist-info → cuqipy-1.3.0.post0.dev86.dist-info}/WHEEL +1 -1
- {cuqipy-1.3.0.post0.dev58.dist-info → cuqipy-1.3.0.post0.dev86.dist-info/licenses}/LICENSE +0 -0
- {cuqipy-1.3.0.post0.dev58.dist-info → cuqipy-1.3.0.post0.dev86.dist-info}/top_level.txt +0 -0
cuqi/_version.py
CHANGED
|
@@ -8,11 +8,11 @@ import json
|
|
|
8
8
|
|
|
9
9
|
version_json = '''
|
|
10
10
|
{
|
|
11
|
-
"date": "2025-
|
|
11
|
+
"date": "2025-04-10T10:50:04+0200",
|
|
12
12
|
"dirty": false,
|
|
13
13
|
"error": null,
|
|
14
|
-
"full-revisionid": "
|
|
15
|
-
"version": "1.3.0.post0.
|
|
14
|
+
"full-revisionid": "fe056d15f6ff918511cf7ee579dc8e7689c1dbc4",
|
|
15
|
+
"version": "1.3.0.post0.dev86"
|
|
16
16
|
}
|
|
17
17
|
''' # END VERSION_JSON
|
|
18
18
|
|
cuqi/distribution/__init__.py
CHANGED
|
@@ -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.
|
|
110
|
+
return np.nan*np.ones_like(x)
|
|
111
111
|
else:
|
|
112
112
|
return self._normal.gradient(x, *args, **kwargs)
|
|
113
113
|
|
cuqi/distribution/_uniform.py
CHANGED
|
@@ -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.
|
|
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
|
-
|
|
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
|
-
|
|
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):
|
cuqi/utilities/_utilities.py
CHANGED
|
@@ -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.
|
|
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))
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: CUQIpy
|
|
3
|
-
Version: 1.3.0.post0.
|
|
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
|
|
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"/>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
cuqi/__init__.py,sha256=LsGilhl-hBLEn6Glt8S_l0OJzAA1sKit_rui8h-D-p0,488
|
|
2
2
|
cuqi/_messages.py,sha256=fzEBrZT2kbmfecBBPm7spVu7yHdxGARQB4QzXhJbCJ0,415
|
|
3
|
-
cuqi/_version.py,sha256=
|
|
3
|
+
cuqi/_version.py,sha256=5BoF7RelweJtRYABv01YoLMQTIvAp9dGHYbyo9mk5u4,509
|
|
4
4
|
cuqi/config.py,sha256=wcYvz19wkeKW2EKCGIKJiTpWt5kdaxyt4imyRkvtTRA,526
|
|
5
5
|
cuqi/diagnostics.py,sha256=5OrbJeqpynqRXOe5MtOKKhe7EAVdOEpHIqHnlMW9G_c,3029
|
|
6
6
|
cuqi/array/__init__.py,sha256=-EeiaiWGNsE3twRS4dD814BIlfxEsNkTCZUc5gjOXb0,30
|
|
@@ -14,7 +14,7 @@ cuqi/data/cookie.png,sha256=mr6wUeoIUc5VC2qYj8vafOmTbcRwz0fHz4IIPK9_PnE,984680
|
|
|
14
14
|
cuqi/data/satellite.mat,sha256=a0Nz_Ak-Y0m360dH74pa_rpk-MhaQ91ftGTKhQX7I8g,16373
|
|
15
15
|
cuqi/density/__init__.py,sha256=0zfVcPgqdqiPkss5n_WP_PUt-G3ovHXjokhqEKIlLwA,48
|
|
16
16
|
cuqi/density/_density.py,sha256=BG7gtP0cbFYLVgjYQGkNAhM95PR5ocBVLKRlOVX2PyM,7253
|
|
17
|
-
cuqi/distribution/__init__.py,sha256=
|
|
17
|
+
cuqi/distribution/__init__.py,sha256=f-HM-SUrvPO66_FAJ6k4TffBq4H94OusRMDOJgcJU2w,779
|
|
18
18
|
cuqi/distribution/_beta.py,sha256=QlibnuHNcvWjl-du5aRc9QuzS3n4PsyD_8Nc47w-E0Q,2903
|
|
19
19
|
cuqi/distribution/_cauchy.py,sha256=Qwi21WkwUBnBkLbhR-yCGO0tQ_U_3mmvR0pDMPPPB5c,3296
|
|
20
20
|
cuqi/distribution/_cmrf.py,sha256=tCbEulM_O7FB3C_W-3IqZp9zGHkTofCdFF0ybHc9UZI,3745
|
|
@@ -32,8 +32,8 @@ cuqi/distribution/_modifiedhalfnormal.py,sha256=ErULXUFRjbMyCYywaOzfuxtoy-XQmC0M
|
|
|
32
32
|
cuqi/distribution/_normal.py,sha256=vhIiAseW09IKh1uy0KUq7RP1IuY7hH5aNM1W_R8Gd_Q,2912
|
|
33
33
|
cuqi/distribution/_posterior.py,sha256=zAfL0GECxekZ2lBt1W6_LN0U_xskMwK4VNce5xAF7ig,5018
|
|
34
34
|
cuqi/distribution/_smoothed_laplace.py,sha256=p-1Y23mYA9omwiHGkEuv3T2mwcPAAoNlCr7T8osNkjE,2925
|
|
35
|
-
cuqi/distribution/_truncated_normal.py,sha256=
|
|
36
|
-
cuqi/distribution/_uniform.py,sha256=
|
|
35
|
+
cuqi/distribution/_truncated_normal.py,sha256=_ez3MmO6qpBeP6BKCUlW3IgxuF7k--A7jPGPUhtYK0g,4240
|
|
36
|
+
cuqi/distribution/_uniform.py,sha256=fVgj_4SBav8JMc1pNAO1l_CZ9ZwdoMIpN9iQ3i9_Z0Q,3255
|
|
37
37
|
cuqi/experimental/__init__.py,sha256=bIQ9OroeitHbwgNe3wI_JvzkILK0N25Tt7wpquPoU3w,129
|
|
38
38
|
cuqi/experimental/algebra/__init__.py,sha256=btRAWG58ZfdtK0afXKOg60AX7d76KMBjlZa4AWBCCgU,81
|
|
39
39
|
cuqi/experimental/algebra/_ast.py,sha256=PdPz19cJMjvnMx4KEzhn4gvxIZX_UViE33Mbttj_5Xw,9873
|
|
@@ -59,7 +59,7 @@ cuqi/geometry/__init__.py,sha256=Tz1WGzZBY-QGH3c0GiyKm9XHN8MGGcnU6TUHLZkzB3o,842
|
|
|
59
59
|
cuqi/geometry/_geometry.py,sha256=W-oQTZPelVS7fN9qZj6bNBuh-yY0eqOHJ39UwB-WmQY,47562
|
|
60
60
|
cuqi/implicitprior/__init__.py,sha256=6z3lvw-tWDyjZSpB3pYzvijSMK9Zlf1IYqOVTtMD2h4,309
|
|
61
61
|
cuqi/implicitprior/_regularizedGMRF.py,sha256=BUeT4rwJzary9K56fkxCNGCeKZd-2VSgOT8XNHxFPRE,6345
|
|
62
|
-
cuqi/implicitprior/_regularizedGaussian.py,sha256=
|
|
62
|
+
cuqi/implicitprior/_regularizedGaussian.py,sha256=9BSKHGEW0OT9OIt_42strDzxBM8mB6A-blcf0kEguHw,21836
|
|
63
63
|
cuqi/implicitprior/_regularizedUnboundedUniform.py,sha256=uHGYYnTjVxdPbY-5JwocFOH0sHRfGrrLiHWahzH9R8A,3533
|
|
64
64
|
cuqi/implicitprior/_restorator.py,sha256=Z350XUJEt7N59Qw-SIUaBljQNDJk4Zb0i_KRFrt2DCg,10087
|
|
65
65
|
cuqi/likelihood/__init__.py,sha256=QXif382iwZ5bT3ZUqmMs_n70JVbbjxbqMrlQYbMn4Zo,1776
|
|
@@ -92,9 +92,9 @@ cuqi/testproblem/__init__.py,sha256=DWTOcyuNHMbhEuuWlY5CkYkNDSAqhvsKmJXBLivyblU,
|
|
|
92
92
|
cuqi/testproblem/_testproblem.py,sha256=x769LwwRdJdzIiZkcQUGb_5-vynNTNALXWKato7sS0Q,52540
|
|
93
93
|
cuqi/utilities/__init__.py,sha256=d5QXRzmI6EchS9T4b7eTezSisPWuWklO8ey4YBx9kI0,569
|
|
94
94
|
cuqi/utilities/_get_python_variable_name.py,sha256=wxpCaj9f3ZtBNqlGmmuGiITgBaTsY-r94lUIlK6UAU4,2043
|
|
95
|
-
cuqi/utilities/_utilities.py,sha256=
|
|
96
|
-
cuqipy-1.3.0.post0.
|
|
97
|
-
cuqipy-1.3.0.post0.
|
|
98
|
-
cuqipy-1.3.0.post0.
|
|
99
|
-
cuqipy-1.3.0.post0.
|
|
100
|
-
cuqipy-1.3.0.post0.
|
|
95
|
+
cuqi/utilities/_utilities.py,sha256=as8cFswoxROS0Z7WUKzLIE-ZtEKCXes5M3Gdmmb47No,18414
|
|
96
|
+
cuqipy-1.3.0.post0.dev86.dist-info/licenses/LICENSE,sha256=kJWRPrtRoQoZGXyyvu50Uc91X6_0XRaVfT0YZssicys,10799
|
|
97
|
+
cuqipy-1.3.0.post0.dev86.dist-info/METADATA,sha256=lG1Acs-TjKb60yfRHgywc3q1EQY1HuI9bjLQA5CAQNE,18623
|
|
98
|
+
cuqipy-1.3.0.post0.dev86.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
|
99
|
+
cuqipy-1.3.0.post0.dev86.dist-info/top_level.txt,sha256=AgmgMc6TKfPPqbjV0kvAoCBN334i_Lwwojc7HE3ZwD0,5
|
|
100
|
+
cuqipy-1.3.0.post0.dev86.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|