CUQIpy 1.3.0.post0.dev86__py3-none-any.whl → 1.3.0.post0.dev237__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/experimental/geometry/_productgeometry.py +3 -3
- cuqi/experimental/mcmc/_rto.py +23 -15
- cuqi/model/_model.py +1051 -347
- cuqi/pde/_pde.py +14 -10
- cuqi/solver/_solver.py +6 -2
- cuqi/testproblem/_testproblem.py +2 -3
- {cuqipy-1.3.0.post0.dev86.dist-info → cuqipy-1.3.0.post0.dev237.dist-info}/METADATA +1 -1
- {cuqipy-1.3.0.post0.dev86.dist-info → cuqipy-1.3.0.post0.dev237.dist-info}/RECORD +12 -12
- {cuqipy-1.3.0.post0.dev86.dist-info → cuqipy-1.3.0.post0.dev237.dist-info}/WHEEL +1 -1
- {cuqipy-1.3.0.post0.dev86.dist-info → cuqipy-1.3.0.post0.dev237.dist-info}/licenses/LICENSE +0 -0
- {cuqipy-1.3.0.post0.dev86.dist-info → cuqipy-1.3.0.post0.dev237.dist-info}/top_level.txt +0 -0
cuqi/pde/_pde.py
CHANGED
|
@@ -4,6 +4,7 @@ from inspect import getsource
|
|
|
4
4
|
from scipy.interpolate import interp1d
|
|
5
5
|
import numpy as np
|
|
6
6
|
|
|
7
|
+
|
|
7
8
|
class PDE(ABC):
|
|
8
9
|
"""
|
|
9
10
|
Parametrized PDE abstract base class
|
|
@@ -30,7 +31,7 @@ class PDE(ABC):
|
|
|
30
31
|
self.observation_map = observation_map
|
|
31
32
|
|
|
32
33
|
@abstractmethod
|
|
33
|
-
def assemble(self,
|
|
34
|
+
def assemble(self, *args, **kwargs):
|
|
34
35
|
pass
|
|
35
36
|
|
|
36
37
|
@abstractmethod
|
|
@@ -155,9 +156,9 @@ class SteadyStateLinearPDE(LinearPDE):
|
|
|
155
156
|
def __init__(self, PDE_form, **kwargs):
|
|
156
157
|
super().__init__(PDE_form, **kwargs)
|
|
157
158
|
|
|
158
|
-
def assemble(self,
|
|
159
|
+
def assemble(self, *args, **kwargs):
|
|
159
160
|
"""Assembles differential operator and rhs according to PDE_form"""
|
|
160
|
-
self.diff_op, self.rhs = self.PDE_form(
|
|
161
|
+
self.diff_op, self.rhs = self.PDE_form(*args, **kwargs)
|
|
161
162
|
|
|
162
163
|
def solve(self):
|
|
163
164
|
"""Solve the PDE and returns the solution and an information variable `info` which is a tuple of all variables returned by the function `linalg_solve` after the solution."""
|
|
@@ -178,7 +179,7 @@ class SteadyStateLinearPDE(LinearPDE):
|
|
|
178
179
|
solution_obs = self.observation_map(solution_obs)
|
|
179
180
|
|
|
180
181
|
return solution_obs
|
|
181
|
-
|
|
182
|
+
|
|
182
183
|
class TimeDependentLinearPDE(LinearPDE):
|
|
183
184
|
"""Time Dependent Linear PDE with fixed time stepping using Euler method (backward or forward).
|
|
184
185
|
|
|
@@ -234,13 +235,16 @@ class TimeDependentLinearPDE(LinearPDE):
|
|
|
234
235
|
"method can be set to either `forward_euler` or `backward_euler`")
|
|
235
236
|
self._method = value
|
|
236
237
|
|
|
237
|
-
def assemble(self,
|
|
238
|
+
def assemble(self, *args, **kwargs):
|
|
238
239
|
"""Assemble PDE"""
|
|
239
|
-
self.
|
|
240
|
+
self._parameter_kwargs = kwargs
|
|
241
|
+
self._parameter_args = args
|
|
240
242
|
|
|
241
243
|
def assemble_step(self, t):
|
|
242
244
|
"""Assemble time step at time t"""
|
|
243
|
-
self.diff_op, self.rhs, self.initial_condition = self.PDE_form(
|
|
245
|
+
self.diff_op, self.rhs, self.initial_condition = self.PDE_form(
|
|
246
|
+
*self._parameter_args, **self._parameter_kwargs, t=t
|
|
247
|
+
)
|
|
244
248
|
|
|
245
249
|
def solve(self):
|
|
246
250
|
"""Solve PDE by time-stepping"""
|
|
@@ -279,7 +283,7 @@ class TimeDependentLinearPDE(LinearPDE):
|
|
|
279
283
|
# Interpolate solution in time and space to the observation
|
|
280
284
|
# time and space
|
|
281
285
|
else:
|
|
282
|
-
# Raise error if solution is 2D or 3D in space
|
|
286
|
+
# Raise error if solution is 2D or 3D in space
|
|
283
287
|
if len(solution.shape) > 2:
|
|
284
288
|
raise ValueError("Interpolation of solutions of 2D and 3D "+
|
|
285
289
|
"space dimensions based on the provided "+
|
|
@@ -287,7 +291,7 @@ class TimeDependentLinearPDE(LinearPDE):
|
|
|
287
291
|
"You can, instead, pass a custom "+
|
|
288
292
|
"observation_map and pass grid_obs and "+
|
|
289
293
|
"time_obs as None.")
|
|
290
|
-
|
|
294
|
+
|
|
291
295
|
# Interpolate solution in space and time to the observation
|
|
292
296
|
# time and space
|
|
293
297
|
solution_obs = scipy.interpolate.RectBivariateSpline(
|
|
@@ -297,7 +301,7 @@ class TimeDependentLinearPDE(LinearPDE):
|
|
|
297
301
|
# Apply observation map
|
|
298
302
|
if self.observation_map is not None:
|
|
299
303
|
solution_obs = self.observation_map(solution_obs)
|
|
300
|
-
|
|
304
|
+
|
|
301
305
|
# squeeze if only one time observation
|
|
302
306
|
if len(self._time_obs) == 1:
|
|
303
307
|
solution_obs = solution_obs.squeeze()
|
cuqi/solver/_solver.py
CHANGED
|
@@ -196,8 +196,11 @@ class ScipyLSQ(object):
|
|
|
196
196
|
'trf', Trust Region Reflective algorithm: for large sparse problems with bounds.
|
|
197
197
|
'dogbox', dogleg algorithm with rectangular trust regions, for small problems with bounds.
|
|
198
198
|
'lm', Levenberg-Marquardt algorithm as implemented in MINPACK. Doesn't handle bounds and sparse Jacobians.
|
|
199
|
+
tol : The numerical tolerance for convergence checks.
|
|
200
|
+
maxit : The maximum number of iterations.
|
|
201
|
+
kwargs : Additional keyword arguments passed to scipy's least_squares. Empty by default. See documentation for scipy.optimize.least_squares
|
|
199
202
|
"""
|
|
200
|
-
def __init__(self, func, x0, jacfun='2-point', method='trf', loss='linear', tol=1e-6, maxit=1e4):
|
|
203
|
+
def __init__(self, func, x0, jacfun='2-point', method='trf', loss='linear', tol=1e-6, maxit=1e4, **kwargs):
|
|
201
204
|
self.func = func
|
|
202
205
|
self.x0 = x0
|
|
203
206
|
self.jacfun = jacfun
|
|
@@ -205,6 +208,7 @@ class ScipyLSQ(object):
|
|
|
205
208
|
self.loss = loss
|
|
206
209
|
self.tol = tol
|
|
207
210
|
self.maxit = int(maxit)
|
|
211
|
+
self.kwargs = kwargs
|
|
208
212
|
|
|
209
213
|
def solve(self):
|
|
210
214
|
"""Runs optimization algorithm and returns solution and info.
|
|
@@ -215,7 +219,7 @@ class ScipyLSQ(object):
|
|
|
215
219
|
Solution found (array_like) and optimization information (dictionary).
|
|
216
220
|
"""
|
|
217
221
|
solution = least_squares(self.func, self.x0, jac=self.jacfun, \
|
|
218
|
-
method=self.method, loss=self.loss, xtol=self.tol, max_nfev=self.maxit)
|
|
222
|
+
method=self.method, loss=self.loss, xtol=self.tol, max_nfev=self.maxit, **self.kwargs)
|
|
219
223
|
info = {"success": solution['success'],
|
|
220
224
|
"message": solution['message'],
|
|
221
225
|
"func": solution['fun'],
|
cuqi/testproblem/_testproblem.py
CHANGED
|
@@ -863,10 +863,9 @@ class Heat1D(BayesianProblem):
|
|
|
863
863
|
# Bayesian model
|
|
864
864
|
x = cuqi.distribution.Gaussian(np.zeros(model.domain_dim), 1)
|
|
865
865
|
y = cuqi.distribution.Gaussian(model(x), sigma2)
|
|
866
|
-
|
|
867
|
-
# Initialize Deconvolution as BayesianProblem problem
|
|
868
|
-
super().__init__(y, x, y=data)
|
|
869
866
|
|
|
867
|
+
# Initialize Heat1D as BayesianProblem problem
|
|
868
|
+
super().__init__(y, x, y=data)
|
|
870
869
|
# Store exact values
|
|
871
870
|
self.exactSolution = x_exact
|
|
872
871
|
self.exactData = y_exact
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: CUQIpy
|
|
3
|
-
Version: 1.3.0.post0.
|
|
3
|
+
Version: 1.3.0.post0.dev237
|
|
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
|
|
@@ -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=T-xOiDXchZq_KrCheA_86YhVx3HMHSXQflIX3VRywVQ,510
|
|
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
|
|
@@ -40,7 +40,7 @@ cuqi/experimental/algebra/_ast.py,sha256=PdPz19cJMjvnMx4KEzhn4gvxIZX_UViE33Mbttj
|
|
|
40
40
|
cuqi/experimental/algebra/_orderedset.py,sha256=fKysh4pmI4xF7Y5Z6O86ABzg20o4uBs-v8jmLBMrdpo,2849
|
|
41
41
|
cuqi/experimental/algebra/_randomvariable.py,sha256=isbFtIWsWXF-yF5Vb56nLy4MCkQM6akjd-dQau4wfbE,19725
|
|
42
42
|
cuqi/experimental/geometry/__init__.py,sha256=kgoKegfz3Jhr7fpORB_l55z9zLZRtloTLyXFDh1oF2o,47
|
|
43
|
-
cuqi/experimental/geometry/_productgeometry.py,sha256=
|
|
43
|
+
cuqi/experimental/geometry/_productgeometry.py,sha256=IlBmmKsWE-aRZHp6no9gUXGRfkHlgM0CdPBx1hax9HI,7199
|
|
44
44
|
cuqi/experimental/mcmc/__init__.py,sha256=zSqLZmxOqQ-F94C9-gPv7g89TX1XxlrlNm071Eb167I,4487
|
|
45
45
|
cuqi/experimental/mcmc/_conjugate.py,sha256=vqucxC--pihBCUcupdcIo4ymDPPjmMKGb7OL1THjaKE,22059
|
|
46
46
|
cuqi/experimental/mcmc/_conjugate_approx.py,sha256=jmxe2FEbO9fwpc8opyjJ2px0oed3dGyj0qDwyHo4aOk,3545
|
|
@@ -52,7 +52,7 @@ cuqi/experimental/mcmc/_langevin_algorithm.py,sha256=1UunuocpzG1h6GiYefEHFOMykEM
|
|
|
52
52
|
cuqi/experimental/mcmc/_laplace_approximation.py,sha256=I5ZLtU0lA34YflRbqxKi5UgJBhhHzxqUyVW5JE5-l2w,5916
|
|
53
53
|
cuqi/experimental/mcmc/_mh.py,sha256=MXo0ahXP4KGFkaY4HtvcBE-TMQzsMlTmLKzSvpz7drU,2941
|
|
54
54
|
cuqi/experimental/mcmc/_pcn.py,sha256=wqJBZLuRFSwxihaI53tumAg6AWVuceLMOmXssTetd1A,3374
|
|
55
|
-
cuqi/experimental/mcmc/_rto.py,sha256=
|
|
55
|
+
cuqi/experimental/mcmc/_rto.py,sha256=BY55Njw3-dcmjd-V1vQ58CisEDllQ8zaEj92pWB6LCM,15158
|
|
56
56
|
cuqi/experimental/mcmc/_sampler.py,sha256=VK-VsPRaYET43C5quhu2f1OstEX5DKYKVyjKABTRHZE,20288
|
|
57
57
|
cuqi/experimental/mcmc/_utilities.py,sha256=kUzHbhIS3HYZRbneNBK41IogUYX5dS_bJxqEGm7TQBI,525
|
|
58
58
|
cuqi/geometry/__init__.py,sha256=Tz1WGzZBY-QGH3c0GiyKm9XHN8MGGcnU6TUHLZkzB3o,842
|
|
@@ -65,11 +65,11 @@ cuqi/implicitprior/_restorator.py,sha256=Z350XUJEt7N59Qw-SIUaBljQNDJk4Zb0i_KRFrt
|
|
|
65
65
|
cuqi/likelihood/__init__.py,sha256=QXif382iwZ5bT3ZUqmMs_n70JVbbjxbqMrlQYbMn4Zo,1776
|
|
66
66
|
cuqi/likelihood/_likelihood.py,sha256=PuW8ufRefLt6w40JQWqNnEh3YCLxu4pz0h0PcpT8inc,7075
|
|
67
67
|
cuqi/model/__init__.py,sha256=jgY2-jyxEMC79vkyH9BpfowW7_DbMRjqedOtO5fykXQ,62
|
|
68
|
-
cuqi/model/_model.py,sha256=
|
|
68
|
+
cuqi/model/_model.py,sha256=0f9GhgW_Xxe8BGG8Re3dtx5c5uxpv37S71c0MJ0q-EY,66598
|
|
69
69
|
cuqi/operator/__init__.py,sha256=0pc9p-KPyl7KtPV0noB0ddI0CP2iYEHw5rbw49D8Njk,136
|
|
70
70
|
cuqi/operator/_operator.py,sha256=yNwPTh7jR07AiKMbMQQ5_54EgirlKFsbq9JN1EODaQI,8856
|
|
71
71
|
cuqi/pde/__init__.py,sha256=NyS_ZYruCvy-Yg24qKlwm3ZIX058kLNQX9bqs-xg4ZM,99
|
|
72
|
-
cuqi/pde/_pde.py,sha256=
|
|
72
|
+
cuqi/pde/_pde.py,sha256=cVQobuCaGI4Hur7ho7kIIW0LPzj44RayhVQf2n7FCLk,12665
|
|
73
73
|
cuqi/problem/__init__.py,sha256=JxJty4JqHTOqSG6NeTGiXRQ7OLxiRK9jvVq3lXLeIRw,38
|
|
74
74
|
cuqi/problem/_problem.py,sha256=p1UO04GKv5BmdcPR5-xcP-idBsqShBxKJ3WC5qNSMDs,38588
|
|
75
75
|
cuqi/sampler/__init__.py,sha256=D-dYa0gFgIwQukP8_VKhPGmlGKXbvVo7YqaET4SdAeQ,382
|
|
@@ -87,14 +87,14 @@ cuqi/sampler/_sampler.py,sha256=TkZ_WAS-5Q43oICa-Elc2gftsRTBd7PEDUMDZ9tTGmU,5712
|
|
|
87
87
|
cuqi/samples/__init__.py,sha256=vCs6lVk-pi8RBqa6cIN5wyn6u-K9oEf1Na4k1ZMrYv8,44
|
|
88
88
|
cuqi/samples/_samples.py,sha256=hUc8OnCF9CTCuDTrGHwwzv3wp8mG_6vsJAFvuQ-x0uA,35832
|
|
89
89
|
cuqi/solver/__init__.py,sha256=KYgAi_8VoAwljTB3S2I87YnJkRtedskLee7hQp_-zp8,220
|
|
90
|
-
cuqi/solver/_solver.py,sha256=
|
|
90
|
+
cuqi/solver/_solver.py,sha256=X3EWD-26o9UOBsWRuy0ktYsJiUXwpCGm0lvTdQM6dRI,30964
|
|
91
91
|
cuqi/testproblem/__init__.py,sha256=DWTOcyuNHMbhEuuWlY5CkYkNDSAqhvsKmJXBLivyblU,202
|
|
92
|
-
cuqi/testproblem/_testproblem.py,sha256=
|
|
92
|
+
cuqi/testproblem/_testproblem.py,sha256=EJWG_zXUtmo6GlHBZFqHlRpDC_48tE0XZEu0_C66NS8,52524
|
|
93
93
|
cuqi/utilities/__init__.py,sha256=d5QXRzmI6EchS9T4b7eTezSisPWuWklO8ey4YBx9kI0,569
|
|
94
94
|
cuqi/utilities/_get_python_variable_name.py,sha256=wxpCaj9f3ZtBNqlGmmuGiITgBaTsY-r94lUIlK6UAU4,2043
|
|
95
95
|
cuqi/utilities/_utilities.py,sha256=as8cFswoxROS0Z7WUKzLIE-ZtEKCXes5M3Gdmmb47No,18414
|
|
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.
|
|
96
|
+
cuqipy-1.3.0.post0.dev237.dist-info/licenses/LICENSE,sha256=kJWRPrtRoQoZGXyyvu50Uc91X6_0XRaVfT0YZssicys,10799
|
|
97
|
+
cuqipy-1.3.0.post0.dev237.dist-info/METADATA,sha256=ZXvYGwj_lUbv3_vDiKRWtkRpjlAH5PfpaZqx-aMgwJg,18624
|
|
98
|
+
cuqipy-1.3.0.post0.dev237.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
|
|
99
|
+
cuqipy-1.3.0.post0.dev237.dist-info/top_level.txt,sha256=AgmgMc6TKfPPqbjV0kvAoCBN334i_Lwwojc7HE3ZwD0,5
|
|
100
|
+
cuqipy-1.3.0.post0.dev237.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|