CUQIpy 1.3.0.post0.dev104__py3-none-any.whl → 1.3.0.post0.dev266__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/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,parameter):
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, parameter):
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(parameter)
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, parameter):
238
+ def assemble(self, *args, **kwargs):
238
239
  """Assemble PDE"""
239
- self._parameter = parameter
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(self._parameter, t)
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()
@@ -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.dev104
3
+ Version: 1.3.0.post0.dev266
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=guMao82iJ7XuaWXVsBLkNDaBLZLETh0C0JtSWy0RCeA,510
3
+ cuqi/_version.py,sha256=Fy9rwbT3nuGJzIHPUCFz7PEcw7IArqAqvMtmm3okneE,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
@@ -34,14 +34,15 @@ cuqi/distribution/_posterior.py,sha256=zAfL0GECxekZ2lBt1W6_LN0U_xskMwK4VNce5xAF7
34
34
  cuqi/distribution/_smoothed_laplace.py,sha256=p-1Y23mYA9omwiHGkEuv3T2mwcPAAoNlCr7T8osNkjE,2925
35
35
  cuqi/distribution/_truncated_normal.py,sha256=_ez3MmO6qpBeP6BKCUlW3IgxuF7k--A7jPGPUhtYK0g,4240
36
36
  cuqi/distribution/_uniform.py,sha256=fVgj_4SBav8JMc1pNAO1l_CZ9ZwdoMIpN9iQ3i9_Z0Q,3255
37
- cuqi/experimental/__init__.py,sha256=bIQ9OroeitHbwgNe3wI_JvzkILK0N25Tt7wpquPoU3w,129
37
+ cuqi/experimental/__init__.py,sha256=9DidfQuoFPr8DnhYzI78N2J0fT4pp-jNle0Rou1fcrM,174
38
+ cuqi/experimental/_recommender.py,sha256=IawSXwsaYs0T7t6SIXjchX4sj5D1rwbs3bs_nMXAxD0,7400
38
39
  cuqi/experimental/algebra/__init__.py,sha256=btRAWG58ZfdtK0afXKOg60AX7d76KMBjlZa4AWBCCgU,81
39
40
  cuqi/experimental/algebra/_ast.py,sha256=PdPz19cJMjvnMx4KEzhn4gvxIZX_UViE33Mbttj_5Xw,9873
40
41
  cuqi/experimental/algebra/_orderedset.py,sha256=fKysh4pmI4xF7Y5Z6O86ABzg20o4uBs-v8jmLBMrdpo,2849
41
42
  cuqi/experimental/algebra/_randomvariable.py,sha256=isbFtIWsWXF-yF5Vb56nLy4MCkQM6akjd-dQau4wfbE,19725
42
43
  cuqi/experimental/geometry/__init__.py,sha256=kgoKegfz3Jhr7fpORB_l55z9zLZRtloTLyXFDh1oF2o,47
43
- cuqi/experimental/geometry/_productgeometry.py,sha256=G-hIYnfLiRS5IWD2EPXORNBKNP2zSaCCHAeBlDC_R3I,7177
44
- cuqi/experimental/mcmc/__init__.py,sha256=zSqLZmxOqQ-F94C9-gPv7g89TX1XxlrlNm071Eb167I,4487
44
+ cuqi/experimental/geometry/_productgeometry.py,sha256=IlBmmKsWE-aRZHp6no9gUXGRfkHlgM0CdPBx1hax9HI,7199
45
+ cuqi/experimental/mcmc/__init__.py,sha256=hTAssTgtgLhdVZLFX7hpLJYtWmXrmfXb4bWee6ELqwE,4443
45
46
  cuqi/experimental/mcmc/_conjugate.py,sha256=vqucxC--pihBCUcupdcIo4ymDPPjmMKGb7OL1THjaKE,22059
46
47
  cuqi/experimental/mcmc/_conjugate_approx.py,sha256=jmxe2FEbO9fwpc8opyjJ2px0oed3dGyj0qDwyHo4aOk,3545
47
48
  cuqi/experimental/mcmc/_cwmh.py,sha256=cAvtc3tex53ZUKPMGwj2RIkHAZurpqphko8nk8_DmJs,7340
@@ -54,7 +55,6 @@ cuqi/experimental/mcmc/_mh.py,sha256=MXo0ahXP4KGFkaY4HtvcBE-TMQzsMlTmLKzSvpz7drU
54
55
  cuqi/experimental/mcmc/_pcn.py,sha256=wqJBZLuRFSwxihaI53tumAg6AWVuceLMOmXssTetd1A,3374
55
56
  cuqi/experimental/mcmc/_rto.py,sha256=BY55Njw3-dcmjd-V1vQ58CisEDllQ8zaEj92pWB6LCM,15158
56
57
  cuqi/experimental/mcmc/_sampler.py,sha256=VK-VsPRaYET43C5quhu2f1OstEX5DKYKVyjKABTRHZE,20288
57
- cuqi/experimental/mcmc/_utilities.py,sha256=kUzHbhIS3HYZRbneNBK41IogUYX5dS_bJxqEGm7TQBI,525
58
58
  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
@@ -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=LqeMwOSb1oIGpT7g1cmItP_2Q4dmgg8eNPNo0joPUyg,32905
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=WRkOYyIdT_T3aZepRh0aS9C5nBbUZUcHaA80iSRvgoo,12572
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
@@ -89,12 +89,12 @@ cuqi/samples/_samples.py,sha256=hUc8OnCF9CTCuDTrGHwwzv3wp8mG_6vsJAFvuQ-x0uA,3583
89
89
  cuqi/solver/__init__.py,sha256=KYgAi_8VoAwljTB3S2I87YnJkRtedskLee7hQp_-zp8,220
90
90
  cuqi/solver/_solver.py,sha256=X3EWD-26o9UOBsWRuy0ktYsJiUXwpCGm0lvTdQM6dRI,30964
91
91
  cuqi/testproblem/__init__.py,sha256=DWTOcyuNHMbhEuuWlY5CkYkNDSAqhvsKmJXBLivyblU,202
92
- cuqi/testproblem/_testproblem.py,sha256=x769LwwRdJdzIiZkcQUGb_5-vynNTNALXWKato7sS0Q,52540
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.dev104.dist-info/licenses/LICENSE,sha256=kJWRPrtRoQoZGXyyvu50Uc91X6_0XRaVfT0YZssicys,10799
97
- cuqipy-1.3.0.post0.dev104.dist-info/METADATA,sha256=ocRbxXFZqKPsVVnPjFNgacaxLE8zeXDD71iHGk6q6j8,18624
98
- cuqipy-1.3.0.post0.dev104.dist-info/WHEEL,sha256=ck4Vq1_RXyvS4Jt6SI0Vz6fyVs4GWg7AINwpsaGEgPE,91
99
- cuqipy-1.3.0.post0.dev104.dist-info/top_level.txt,sha256=AgmgMc6TKfPPqbjV0kvAoCBN334i_Lwwojc7HE3ZwD0,5
100
- cuqipy-1.3.0.post0.dev104.dist-info/RECORD,,
96
+ cuqipy-1.3.0.post0.dev266.dist-info/licenses/LICENSE,sha256=kJWRPrtRoQoZGXyyvu50Uc91X6_0XRaVfT0YZssicys,10799
97
+ cuqipy-1.3.0.post0.dev266.dist-info/METADATA,sha256=m3jmxO185qu_BLJWaQh31JKe5alD02bvk7BIKSR0AOk,18624
98
+ cuqipy-1.3.0.post0.dev266.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
99
+ cuqipy-1.3.0.post0.dev266.dist-info/top_level.txt,sha256=AgmgMc6TKfPPqbjV0kvAoCBN334i_Lwwojc7HE3ZwD0,5
100
+ cuqipy-1.3.0.post0.dev266.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.0.0)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,17 +0,0 @@
1
- import cuqi
2
- import inspect
3
-
4
- def find_valid_samplers(target):
5
- """ Finds all samplers in the cuqi.experimental.mcmc module that accept the provided target. """
6
-
7
- all_samplers = [(name, cls) for name, cls in inspect.getmembers(cuqi.experimental.mcmc, inspect.isclass) if issubclass(cls, cuqi.experimental.mcmc.Sampler)]
8
- valid_samplers = []
9
-
10
- for name, sampler in all_samplers:
11
- try:
12
- sampler(target)
13
- valid_samplers += [name]
14
- except:
15
- pass
16
-
17
- return valid_samplers