CUQIpy 1.3.0.post0.dev292__py3-none-any.whl → 1.3.0.post0.dev298__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.
cuqi/_version.py CHANGED
@@ -8,11 +8,11 @@ import json
8
8
 
9
9
  version_json = '''
10
10
  {
11
- "date": "2025-07-04T09:41:59+0300",
11
+ "date": "2025-09-04T09:48:37+0300",
12
12
  "dirty": false,
13
13
  "error": null,
14
- "full-revisionid": "7536b0d728d704a7ab46bca7ff4756075ba0e573",
15
- "version": "1.3.0.post0.dev292"
14
+ "full-revisionid": "a0d227d0981362a09d24dc976ad65459ba8bf798",
15
+ "version": "1.3.0.post0.dev298"
16
16
  }
17
17
  ''' # END VERSION_JSON
18
18
 
@@ -283,7 +283,7 @@ class JointDistribution:
283
283
  msg += f"\t{density.name} ~ {density}\n"
284
284
 
285
285
  # Wrap up
286
- msg += ")"
286
+ msg += " )"
287
287
 
288
288
  return msg
289
289
 
@@ -17,6 +17,24 @@ class SamplerRecommender(object):
17
17
 
18
18
  exceptions: list[cuqi.experimental.mcmc.Sampler], *optional*
19
19
  Samplers not to be recommended.
20
+
21
+ Example
22
+ -------
23
+ .. code-block:: python
24
+ import numpy as np
25
+ from cuqi.distribution import Gamma, Gaussian, JointDistribution
26
+ from cuqi.experimental import SamplerRecommender
27
+
28
+ x = Gamma(1, 1)
29
+ y = Gaussian(np.zeros(2), cov=lambda x: 1 / x)
30
+ target = JointDistribution(y, x)(y=1)
31
+
32
+ recommender = SamplerRecommender(target)
33
+ valid_samplers = recommender.valid_samplers()
34
+ recommended_sampler = recommender.recommend()
35
+ print("Valid samplers:", valid_samplers)
36
+ print("Recommended sampler:\n", recommended_sampler)
37
+
20
38
  """
21
39
 
22
40
  def __init__(self, target:cuqi.density.Density, exceptions = []):
@@ -28,7 +46,7 @@ class SamplerRecommender(object):
28
46
  def target(self) -> cuqi.density.Density:
29
47
  """ Return the target Distribution. """
30
48
  return self._target
31
-
49
+
32
50
  @target.setter
33
51
  def target(self, value:cuqi.density.Density):
34
52
  """ Set the target Distribution. Runs validation of the target. """
@@ -73,7 +91,7 @@ class SamplerRecommender(object):
73
91
  def ordering(self):
74
92
  """ Returns the ordered list of recommendation rules used by the recommender. """
75
93
  return self._ordering
76
-
94
+
77
95
  def valid_samplers(self, as_string = True):
78
96
  """
79
97
  Finds all possible samplers that can be used for sampling from the target distribution.
@@ -101,7 +119,6 @@ class SamplerRecommender(object):
101
119
  valid_samplers += [cuqi.experimental.mcmc.HybridGibbs.__name__ if as_string else cuqi.experimental.mcmc.HybridGibbs]
102
120
 
103
121
  return valid_samplers
104
-
105
122
 
106
123
  def valid_HybridGibbs_sampling_strategy(self, as_string = True):
107
124
  """
@@ -131,11 +148,10 @@ class SamplerRecommender(object):
131
148
  samplers = recommender.valid_samplers(as_string)
132
149
  if len(samplers) == 0:
133
150
  return None
134
-
151
+
135
152
  valid_samplers[par_name] = samplers
136
153
 
137
154
  return valid_samplers
138
-
139
155
 
140
156
  def recommend(self, as_string = False):
141
157
  """
@@ -194,7 +210,7 @@ class SamplerRecommender(object):
194
210
 
195
211
  if sampler is None:
196
212
  return None
197
-
213
+
198
214
  suggested_samplers[par_name] = sampler
199
215
 
200
- return suggested_samplers
216
+ return suggested_samplers
@@ -359,3 +359,16 @@ class HybridGibbs:
359
359
  """ Store current samples at index i of samples dict """
360
360
  for par_name in self.par_names:
361
361
  self.samples[par_name].append(self.current_samples[par_name])
362
+
363
+ def __repr__(self):
364
+ """ Return a string representation of the sampler. """
365
+ msg = f"Sampler: {self.__class__.__name__} \n"
366
+ if self.target is None:
367
+ msg += f" Target: None \n"
368
+ else:
369
+ msg += f" Target: \n \t {self.target} \n\n"
370
+
371
+ for key, value in zip(self.samplers.keys(), self.samplers.values()):
372
+ msg += f" Variable '{key}' with {value} \n"
373
+
374
+ return msg
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: CUQIpy
3
- Version: 1.3.0.post0.dev292
3
+ Version: 1.3.0.post0.dev298
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=eyCoChn1zWoAnzTTYeTzXxJH16p5pz9892w601LX0lc,510
3
+ cuqi/_version.py,sha256=VwUmSwCl1TjQCoMN2OC86V-9oKtS3snnE0i5gC_KQao,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
@@ -24,7 +24,7 @@ cuqi/distribution/_gamma.py,sha256=VcvBJS51N-MxuX42r9L2j2QYRlzhdgAtQ6Wa5IFO_YE,3
24
24
  cuqi/distribution/_gaussian.py,sha256=3L1L_3W6i6YuPQ8vnFmju5QsvkLlg4VsgCnj11lYBUE,32977
25
25
  cuqi/distribution/_gmrf.py,sha256=OwId8qQWEtmC2fxVhL4iBHZnc8ZCrZzfV6yGXDE3k30,9522
26
26
  cuqi/distribution/_inverse_gamma.py,sha256=oPJuiYp3O1m547pmmIz9OWesky9YpwLTHT7-9MmcYss,3159
27
- cuqi/distribution/_joint_distribution.py,sha256=vadRTOpQh1skAgnf-f2-2e6IMvoH2d8beriDvjh236g,16709
27
+ cuqi/distribution/_joint_distribution.py,sha256=gBWDb9Aj27m74mSsm9Jj_0mSu0pcEk9Cwdxrzybiwx8,16710
28
28
  cuqi/distribution/_laplace.py,sha256=5exLvlzJm2AgfvZ3KUSkjfwlGwwbsktBxP8z0iLMik8,1401
29
29
  cuqi/distribution/_lmrf.py,sha256=rdGoQ-fPe1oW6Z29P-l3woq0NX3_RxUQ2rzm1VzemNM,3290
30
30
  cuqi/distribution/_lognormal.py,sha256=8_hOFQ3iu88ujX8vxmfVEZ0fdmlhTY98PlG5PasPjEg,2612
@@ -35,7 +35,7 @@ cuqi/distribution/_smoothed_laplace.py,sha256=p-1Y23mYA9omwiHGkEuv3T2mwcPAAoNlCr
35
35
  cuqi/distribution/_truncated_normal.py,sha256=_ez3MmO6qpBeP6BKCUlW3IgxuF7k--A7jPGPUhtYK0g,4240
36
36
  cuqi/distribution/_uniform.py,sha256=fVgj_4SBav8JMc1pNAO1l_CZ9ZwdoMIpN9iQ3i9_Z0Q,3255
37
37
  cuqi/experimental/__init__.py,sha256=9DidfQuoFPr8DnhYzI78N2J0fT4pp-jNle0Rou1fcrM,174
38
- cuqi/experimental/_recommender.py,sha256=IawSXwsaYs0T7t6SIXjchX4sj5D1rwbs3bs_nMXAxD0,7400
38
+ cuqi/experimental/_recommender.py,sha256=fSCJnlRrUZh-x8-mbVM5WhuPuh7Wmh-4bfvX5PyK_iE,7967
39
39
  cuqi/experimental/algebra/__init__.py,sha256=btRAWG58ZfdtK0afXKOg60AX7d76KMBjlZa4AWBCCgU,81
40
40
  cuqi/experimental/algebra/_ast.py,sha256=PdPz19cJMjvnMx4KEzhn4gvxIZX_UViE33Mbttj_5Xw,9873
41
41
  cuqi/experimental/algebra/_orderedset.py,sha256=fKysh4pmI4xF7Y5Z6O86ABzg20o4uBs-v8jmLBMrdpo,2849
@@ -47,7 +47,7 @@ cuqi/experimental/mcmc/_conjugate.py,sha256=vqucxC--pihBCUcupdcIo4ymDPPjmMKGb7OL
47
47
  cuqi/experimental/mcmc/_conjugate_approx.py,sha256=jmxe2FEbO9fwpc8opyjJ2px0oed3dGyj0qDwyHo4aOk,3545
48
48
  cuqi/experimental/mcmc/_cwmh.py,sha256=cAvtc3tex53ZUKPMGwj2RIkHAZurpqphko8nk8_DmJs,7340
49
49
  cuqi/experimental/mcmc/_direct.py,sha256=9pQS_2Qk2-ybt6m8WTfPoKetcxQ00WaTRN85-Z0FrBY,777
50
- cuqi/experimental/mcmc/_gibbs.py,sha256=lvYJFh8hWD-4XTTQ1NWmn2J16jGRXYkFqCVoUcbHITg,14117
50
+ cuqi/experimental/mcmc/_gibbs.py,sha256=9Qutc60xoVTvKYRkirQhXEDiQ75mbjyxU7utblmu1C8,14567
51
51
  cuqi/experimental/mcmc/_hmc.py,sha256=LXXOb6cztfjraGIuTGpgf0ndc1xkkBW9v_PfNffu-NA,19438
52
52
  cuqi/experimental/mcmc/_langevin_algorithm.py,sha256=1UunuocpzG1h6GiYefEHFOMykEMlYady6Fmuu9CHxHQ,15059
53
53
  cuqi/experimental/mcmc/_laplace_approximation.py,sha256=I5ZLtU0lA34YflRbqxKi5UgJBhhHzxqUyVW5JE5-l2w,5916
@@ -93,8 +93,8 @@ cuqi/testproblem/_testproblem.py,sha256=EJWG_zXUtmo6GlHBZFqHlRpDC_48tE0XZEu0_C66
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=R7BdNysrE36a4D729DvfrTisWY4paP5nfqdkQxSX3Mg,18431
96
- cuqipy-1.3.0.post0.dev292.dist-info/licenses/LICENSE,sha256=kJWRPrtRoQoZGXyyvu50Uc91X6_0XRaVfT0YZssicys,10799
97
- cuqipy-1.3.0.post0.dev292.dist-info/METADATA,sha256=fb8SM5nUTaT-hHcTBZW23iAbEYSkWF92PptBQNDmvlc,18624
98
- cuqipy-1.3.0.post0.dev292.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
99
- cuqipy-1.3.0.post0.dev292.dist-info/top_level.txt,sha256=AgmgMc6TKfPPqbjV0kvAoCBN334i_Lwwojc7HE3ZwD0,5
100
- cuqipy-1.3.0.post0.dev292.dist-info/RECORD,,
96
+ cuqipy-1.3.0.post0.dev298.dist-info/licenses/LICENSE,sha256=kJWRPrtRoQoZGXyyvu50Uc91X6_0XRaVfT0YZssicys,10799
97
+ cuqipy-1.3.0.post0.dev298.dist-info/METADATA,sha256=j-lO1X4RUW9PR0B-YuJuJMl_IoUB5xrmovKuS22yfs0,18624
98
+ cuqipy-1.3.0.post0.dev298.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
99
+ cuqipy-1.3.0.post0.dev298.dist-info/top_level.txt,sha256=AgmgMc6TKfPPqbjV0kvAoCBN334i_Lwwojc7HE3ZwD0,5
100
+ cuqipy-1.3.0.post0.dev298.dist-info/RECORD,,