CUQIpy 1.1.0.post0.dev17__py3-none-any.whl → 1.1.0.post0.dev21__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: CUQIpy
3
- Version: 1.1.0.post0.dev17
3
+ Version: 1.1.0.post0.dev21
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=0JqlX-Uo--FUa91E6xcFA4Juiov_j5hkWtMvkSXhjGU,509
3
+ cuqi/_version.py,sha256=pquuWWNWYDJTUFSDbH_S09M9kXQmP_DnjYFj4pEcm7k,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
@@ -37,16 +37,16 @@ cuqi/experimental/__init__.py,sha256=vhZvyMX6rl8Y0haqCzGLPz6PSUKyu75XMQbeDHqTTrw
37
37
  cuqi/experimental/mcmc/__init__.py,sha256=8Ce1mHvfbKPe0A5gCDl5Bj4ok8bvbn90LEDvfePfNT4,536
38
38
  cuqi/experimental/mcmc/_conjugate.py,sha256=VNPQkGity0mposcqxrx4UIeXm35EvJvZED4p2stffvA,9924
39
39
  cuqi/experimental/mcmc/_conjugate_approx.py,sha256=uEnY2ea9su5ivcNagyRAwpQP2gBY98sXU7N0y5hTADo,3653
40
- cuqi/experimental/mcmc/_cwmh.py,sha256=VoSTfdDbKKLKb5XyOq8xplrrGTK-8IQESdQDZ8PFp2I,7121
40
+ cuqi/experimental/mcmc/_cwmh.py,sha256=BQE7-4kbiC32TJ38rlVtfSQieoKBK5GDca3HCqHJ7zE,7135
41
41
  cuqi/experimental/mcmc/_direct.py,sha256=9pQS_2Qk2-ybt6m8WTfPoKetcxQ00WaTRN85-Z0FrBY,777
42
- cuqi/experimental/mcmc/_gibbs.py,sha256=tMrAy1c_d9G9fOrr8SvuDVCSKjWrYvnI8znPM3GBPqc,10608
42
+ cuqi/experimental/mcmc/_gibbs.py,sha256=IxZLDeRGZUhZMDCRyDoII67kcuClIeJoMoYKoICAaSU,10619
43
43
  cuqi/experimental/mcmc/_hmc.py,sha256=h63KT0jYq86H541hQzhHHzuLEn7vrRE_2r1o1mTEcZo,19261
44
44
  cuqi/experimental/mcmc/_langevin_algorithm.py,sha256=GKC_mlix3si_3J8E6I58ozh3ErB0XPmHMjV7sFyKLEQ,8200
45
- cuqi/experimental/mcmc/_laplace_approximation.py,sha256=4vRc0h7iLrbs2UrptQN5SDAaAq-RpXlnx569OqHmmuE,5698
46
- cuqi/experimental/mcmc/_mh.py,sha256=7KpM7RFVDQ13SD3uGStPJAHZdsX5mO_fzJLkXK90YgI,2827
45
+ cuqi/experimental/mcmc/_laplace_approximation.py,sha256=rdiE3cMQFq6FLQcOQwPpuGIxrTAp3aoGPxMDSdeopV0,5688
46
+ cuqi/experimental/mcmc/_mh.py,sha256=W5hOraHqfEW4_havtC9Ib2SinJtNV-NvxcOAENeTYUY,2841
47
47
  cuqi/experimental/mcmc/_pcn.py,sha256=wqJBZLuRFSwxihaI53tumAg6AWVuceLMOmXssTetd1A,3374
48
- cuqi/experimental/mcmc/_rto.py,sha256=P1AV1tgnRMXLatkayb2O-OiE5Cta3S_yA9arSAoBkdw,10071
49
- cuqi/experimental/mcmc/_sampler.py,sha256=6BRq3cQFG-NjUpHWpLA7EisX0Vjxu4MhpWA6Z1nFpos,20049
48
+ cuqi/experimental/mcmc/_rto.py,sha256=OtzgiYCxDoTdXp7y4mkLa2upj74qadesoqHYpr11ZCg,10061
49
+ cuqi/experimental/mcmc/_sampler.py,sha256=_ZE0kJZYlo8heolAA0rTgO1sQZ7uwV-lNqCYHxnihFk,20067
50
50
  cuqi/experimental/mcmc/_utilities.py,sha256=kUzHbhIS3HYZRbneNBK41IogUYX5dS_bJxqEGm7TQBI,525
51
51
  cuqi/geometry/__init__.py,sha256=Tz1WGzZBY-QGH3c0GiyKm9XHN8MGGcnU6TUHLZkzB3o,842
52
52
  cuqi/geometry/_geometry.py,sha256=WYFC-4_VBTW73b2ldsnfGYKvdSiCE8plr89xTSmkadg,46804
@@ -85,8 +85,8 @@ cuqi/testproblem/_testproblem.py,sha256=x769LwwRdJdzIiZkcQUGb_5-vynNTNALXWKato7s
85
85
  cuqi/utilities/__init__.py,sha256=T4tLsC215MknBCsw_C0Qeeg_ox26aDUrCA5hbWvNQkU,387
86
86
  cuqi/utilities/_get_python_variable_name.py,sha256=QwlBVj2koJRA8s8pWd554p7-ElcI7HUwY32HknaR92E,1827
87
87
  cuqi/utilities/_utilities.py,sha256=MWAqV6L5btMpWwlUzrZYuV2VeSpfTbOaLRMRkuw2WIA,8509
88
- CUQIpy-1.1.0.post0.dev17.dist-info/LICENSE,sha256=kJWRPrtRoQoZGXyyvu50Uc91X6_0XRaVfT0YZssicys,10799
89
- CUQIpy-1.1.0.post0.dev17.dist-info/METADATA,sha256=9lP1DqQtrxElm70ikrRckkrZcZaYvtiZ_XatVM0KE2w,18390
90
- CUQIpy-1.1.0.post0.dev17.dist-info/WHEEL,sha256=Mdi9PDNwEZptOjTlUcAth7XJDFtKrHYaQMPulZeBCiQ,91
91
- CUQIpy-1.1.0.post0.dev17.dist-info/top_level.txt,sha256=AgmgMc6TKfPPqbjV0kvAoCBN334i_Lwwojc7HE3ZwD0,5
92
- CUQIpy-1.1.0.post0.dev17.dist-info/RECORD,,
88
+ CUQIpy-1.1.0.post0.dev21.dist-info/LICENSE,sha256=kJWRPrtRoQoZGXyyvu50Uc91X6_0XRaVfT0YZssicys,10799
89
+ CUQIpy-1.1.0.post0.dev21.dist-info/METADATA,sha256=rMz9rRNyTGpXZ9HSCjmlmKmZhBx4tp6oGXGT94UIdxE,18390
90
+ CUQIpy-1.1.0.post0.dev21.dist-info/WHEEL,sha256=Mdi9PDNwEZptOjTlUcAth7XJDFtKrHYaQMPulZeBCiQ,91
91
+ CUQIpy-1.1.0.post0.dev21.dist-info/top_level.txt,sha256=AgmgMc6TKfPPqbjV0kvAoCBN334i_Lwwojc7HE3ZwD0,5
92
+ CUQIpy-1.1.0.post0.dev21.dist-info/RECORD,,
cuqi/_version.py CHANGED
@@ -8,11 +8,11 @@ import json
8
8
 
9
9
  version_json = '''
10
10
  {
11
- "date": "2024-08-26T08:07:58+0200",
11
+ "date": "2024-08-26T11:10:44+0200",
12
12
  "dirty": false,
13
13
  "error": null,
14
- "full-revisionid": "9d87eb837ab12ccedf61101e396df2ab1cb37764",
15
- "version": "1.1.0.post0.dev17"
14
+ "full-revisionid": "d8a5799ec1e1e581a09e032cbf01bd3eab1b960d",
15
+ "version": "1.1.0.post0.dev21"
16
16
  }
17
17
  ''' # END VERSION_JSON
18
18
 
@@ -101,7 +101,7 @@ class CWMH(ProposalBasedSampler):
101
101
  "Target should be an instance of "+\
102
102
  f"{cuqi.density.Density.__class__.__name__}")
103
103
  # Fail when there is no log density, which is currently assumed to be the case in case NaN is returned.
104
- if np.isnan(self.target.logd(self._default_initial_point)):
104
+ if np.isnan(self.target.logd(self._get_default_initial_point(self.dim))):
105
105
  raise ValueError("Target does not have valid logd")
106
106
 
107
107
  def validate_proposal(self):
@@ -255,10 +255,11 @@ class HybridGibbs:
255
255
  """ Get initial points for each parameter """
256
256
  initial_points = {}
257
257
  for par_name in self.par_names:
258
- if hasattr(self.target.get_density(par_name), 'init_point'):
259
- initial_points[par_name] = self.target.get_density(par_name).init_point
260
- else:
261
- initial_points[par_name] = np.ones(self.target.get_density(par_name).dim)
258
+ sampler = self.samplers[par_name]
259
+ if sampler.initial_point is None:
260
+ sampler.initial_point = sampler._get_default_initial_point(self.target.get_density(par_name).dim)
261
+ initial_points[par_name] = sampler.initial_point
262
+
262
263
  return initial_points
263
264
 
264
265
  def _store_samples(self):
@@ -151,7 +151,6 @@ class UGLA(Sampler):
151
151
  if not isinstance(self.prior, cuqi.distribution.LMRF):
152
152
  raise ValueError('Unadjusted Gaussian Laplace approximation (UGLA) requires LMRF prior')
153
153
 
154
- @property
155
- def _default_initial_point(self):
154
+ def _get_default_initial_point(self, dim):
156
155
  """ Get the default initial point for the sampler. Defaults to an array of zeros. """
157
- return np.zeros(self.dim)
156
+ return np.zeros(dim)
@@ -33,7 +33,7 @@ class MH(ProposalBasedSampler):
33
33
 
34
34
  def validate_target(self):
35
35
  # Fail only when there is no log density, which is currently assumed to be the case in case NaN is returned.
36
- if np.isnan(self.target.logd(self._default_initial_point)):
36
+ if np.isnan(self.target.logd(self._get_default_initial_point(self.dim))):
37
37
  raise ValueError("Target does not have valid logd")
38
38
 
39
39
  def validate_proposal(self):
@@ -150,10 +150,9 @@ class LinearRTO(Sampler):
150
150
  if not hasattr(self.prior, "sqrtprecTimesMean"):
151
151
  raise TypeError("Prior must contain a sqrtprecTimesMean attribute")
152
152
 
153
- @property
154
- def _default_initial_point(self):
153
+ def _get_default_initial_point(self, dim):
155
154
  """ Get the default initial point for the sampler. Defaults to an array of zeros. """
156
- return np.zeros(self.dim)
155
+ return np.zeros(dim)
157
156
 
158
157
  class RegularizedLinearRTO(LinearRTO):
159
158
  """
@@ -80,7 +80,7 @@ class Sampler(ABC):
80
80
 
81
81
  # Default values
82
82
  if self.initial_point is None:
83
- self.initial_point = self._default_initial_point
83
+ self.initial_point = self._get_default_initial_point(self.dim)
84
84
 
85
85
  # State variables
86
86
  self.current_point = self.initial_point
@@ -386,10 +386,9 @@ class Sampler(ABC):
386
386
  if not self._is_initialized:
387
387
  self.initialize()
388
388
 
389
- @property
390
- def _default_initial_point(self):
389
+ def _get_default_initial_point(self, dim):
391
390
  """ Return the default initial point for the sampler. Defaults to an array of ones. """
392
- return np.ones(self.dim)
391
+ return np.ones(dim)
393
392
 
394
393
  def __repr__(self):
395
394
  """ Return a string representation of the sampler. """
@@ -452,7 +451,7 @@ class ProposalBasedSampler(Sampler, ABC):
452
451
 
453
452
  # Default values
454
453
  if self.initial_point is None:
455
- self.initial_point = self._default_initial_point
454
+ self.initial_point = self._get_default_initial_point(self.dim)
456
455
 
457
456
  if self.proposal is None:
458
457
  self.proposal = self._default_proposal