CUQIpy 1.0.0.post0.dev352__py3-none-any.whl → 1.0.0.post0.dev360__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.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: CUQIpy
3
- Version: 1.0.0.post0.dev352
3
+ Version: 1.0.0.post0.dev360
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=g8tnztVUpVATX40RuxhlLPkPxb_ZLhy-dHUYqyHVXs8,510
3
+ cuqi/_version.py,sha256=cS-WO8xKjlj6I1M1dMYpxgIX4PiSHuwIh3aCZqcJy_8,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
@@ -33,19 +33,20 @@ cuqi/distribution/_normal.py,sha256=UeoTtGDT7YSf4ZNo2amlVF9K-YQpYbf8q76jcRJTVFw,
33
33
  cuqi/distribution/_posterior.py,sha256=zAfL0GECxekZ2lBt1W6_LN0U_xskMwK4VNce5xAF7ig,5018
34
34
  cuqi/distribution/_uniform.py,sha256=7xJmCZH_LPhuGkwEDGh-_CTtzcWKrXMOxtTJUFb7Ydo,1607
35
35
  cuqi/experimental/__init__.py,sha256=vhZvyMX6rl8Y0haqCzGLPz6PSUKyu75XMQbeDHqTTrw,83
36
- cuqi/experimental/mcmc/__init__.py,sha256=TyN_CASRnTcUBQYxoYUeSUBhorLzVwgPQaY72-6hXm8,537
36
+ cuqi/experimental/mcmc/__init__.py,sha256=0Vk_MzfE_9tvqQRgR6_3nkjSe_D3vgFqVM9pFrXN2iQ,581
37
37
  cuqi/experimental/mcmc/_conjugate.py,sha256=qYrBvZ9wNK4oBz0c0RRUtQkbpPIHI3BvBYSLRw8ok5k,3757
38
38
  cuqi/experimental/mcmc/_conjugate_approx.py,sha256=JQe9gmnNespCxSP6vaZWfizFvUWUh8Jn-jRqsJYyNeM,2839
39
- cuqi/experimental/mcmc/_cwmh.py,sha256=dbvmy6Fyr_xszbO3YmYcRsDaRRtQfPimLo6rbp0II6M,6898
39
+ cuqi/experimental/mcmc/_cwmh.py,sha256=-TM_S_UtD5ljEfXGEUpYImxNx3JXppIKTSpoWen7kP8,7142
40
40
  cuqi/experimental/mcmc/_direct.py,sha256=E3UevdJ_DLk2wL0lid1TTKkdmgnIMJ5Ihr7iM1jU8KI,738
41
41
  cuqi/experimental/mcmc/_gibbs.py,sha256=z6YOCiBM1YuZbQHfdmsArR-pT61dsS14F_O4kUxsNYM,10638
42
42
  cuqi/experimental/mcmc/_hmc.py,sha256=0sZMHtnNFGGtQdzpx-cgqA0xyfvGy7r4K62RH3AQNa4,19285
43
43
  cuqi/experimental/mcmc/_langevin_algorithm.py,sha256=n6WRQooKuUDjmqF-CtpcSNFDvaHCgLKhWxX-hi7h_ZA,8224
44
44
  cuqi/experimental/mcmc/_laplace_approximation.py,sha256=VVLOKQWZViT1CZg5RDiycG6trpKdQg94aQCKrAdSl2g,5707
45
- cuqi/experimental/mcmc/_mh.py,sha256=6yQjdpx3fMKvescRFL94Ik-ALTKi0BwBRXbTsIsck-I,2630
45
+ cuqi/experimental/mcmc/_mh.py,sha256=r1RNQLuOaT_WlHvCwS2StsgNAOeTD36z2fOzUtbGhHk,2842
46
46
  cuqi/experimental/mcmc/_pcn.py,sha256=T4T32mfoii3k6Jfz0qxPQbwdh6wdVOxttiEP7NWaZzg,3386
47
47
  cuqi/experimental/mcmc/_rto.py,sha256=wzlqm8waT6mB-3RFtMz-PlSUa1Yy3dfUoyKKahTaey4,10086
48
48
  cuqi/experimental/mcmc/_sampler.py,sha256=4dh9XVALkD3Ro9vkLZkNoFNge7Xv8QRbjh4LB7NY0HI,20073
49
+ cuqi/experimental/mcmc/_utilities.py,sha256=qrSq8hvK_G2rSxYYfR5psk4sbTe7098TS5QNu13THeE,528
49
50
  cuqi/geometry/__init__.py,sha256=Tz1WGzZBY-QGH3c0GiyKm9XHN8MGGcnU6TUHLZkzB3o,842
50
51
  cuqi/geometry/_geometry.py,sha256=WYFC-4_VBTW73b2ldsnfGYKvdSiCE8plr89xTSmkadg,46804
51
52
  cuqi/implicitprior/__init__.py,sha256=ZRZ9fgxgEl5n0A9F7WCl1_jid-GUiC8ZLkyTmGQmFlY,100
@@ -82,8 +83,8 @@ cuqi/testproblem/_testproblem.py,sha256=x769LwwRdJdzIiZkcQUGb_5-vynNTNALXWKato7s
82
83
  cuqi/utilities/__init__.py,sha256=T4tLsC215MknBCsw_C0Qeeg_ox26aDUrCA5hbWvNQkU,387
83
84
  cuqi/utilities/_get_python_variable_name.py,sha256=QwlBVj2koJRA8s8pWd554p7-ElcI7HUwY32HknaR92E,1827
84
85
  cuqi/utilities/_utilities.py,sha256=MWAqV6L5btMpWwlUzrZYuV2VeSpfTbOaLRMRkuw2WIA,8509
85
- CUQIpy-1.0.0.post0.dev352.dist-info/LICENSE,sha256=kJWRPrtRoQoZGXyyvu50Uc91X6_0XRaVfT0YZssicys,10799
86
- CUQIpy-1.0.0.post0.dev352.dist-info/METADATA,sha256=NfPWIJpaMKeytArVU0GZCtQnlf87FNbAQkiOIdmA_ik,18393
87
- CUQIpy-1.0.0.post0.dev352.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
88
- CUQIpy-1.0.0.post0.dev352.dist-info/top_level.txt,sha256=AgmgMc6TKfPPqbjV0kvAoCBN334i_Lwwojc7HE3ZwD0,5
89
- CUQIpy-1.0.0.post0.dev352.dist-info/RECORD,,
86
+ CUQIpy-1.0.0.post0.dev360.dist-info/LICENSE,sha256=kJWRPrtRoQoZGXyyvu50Uc91X6_0XRaVfT0YZssicys,10799
87
+ CUQIpy-1.0.0.post0.dev360.dist-info/METADATA,sha256=zYqabNMLjZdQ55Z_bQyptCZ2QV-N5FLCF7G05No2jK8,18393
88
+ CUQIpy-1.0.0.post0.dev360.dist-info/WHEEL,sha256=mguMlWGMX-VHnMpKOjjQidIo1ssRlCFu4a4mBpz1s2M,91
89
+ CUQIpy-1.0.0.post0.dev360.dist-info/top_level.txt,sha256=AgmgMc6TKfPPqbjV0kvAoCBN334i_Lwwojc7HE3ZwD0,5
90
+ CUQIpy-1.0.0.post0.dev360.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.43.0)
2
+ Generator: setuptools (70.1.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
cuqi/_version.py CHANGED
@@ -8,11 +8,11 @@ import json
8
8
 
9
9
  version_json = '''
10
10
  {
11
- "date": "2024-06-19T09:05:37+0200",
11
+ "date": "2024-07-01T14:33:09+0200",
12
12
  "dirty": false,
13
13
  "error": null,
14
- "full-revisionid": "1e1deddbe7925206fdaef6a2d9bf8ce9e33ad73d",
15
- "version": "1.0.0.post0.dev352"
14
+ "full-revisionid": "4da44104c9163182cd1eeb31fb4678a2893111fe",
15
+ "version": "1.0.0.post0.dev360"
16
16
  }
17
17
  ''' # END VERSION_JSON
18
18
 
@@ -12,3 +12,4 @@ from ._gibbs import HybridGibbsNew
12
12
  from ._conjugate import ConjugateNew
13
13
  from ._conjugate_approx import ConjugateApproxNew
14
14
  from ._direct import DirectNew
15
+ from ._utilities import find_valid_samplers
@@ -100,6 +100,9 @@ class CWMHNew(ProposalBasedSamplerNew):
100
100
  raise ValueError(
101
101
  "Target should be an instance of "+\
102
102
  f"{cuqi.density.Density.__class__.__name__}")
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)):
105
+ raise ValueError("Target does not have valid logd")
103
106
 
104
107
  def validate_proposal(self):
105
108
  if not isinstance(self.proposal, cuqi.distribution.Distribution):
@@ -32,7 +32,9 @@ class MHNew(ProposalBasedSamplerNew):
32
32
  self._scale_temp = self.scale
33
33
 
34
34
  def validate_target(self):
35
- pass # All targets are valid
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)):
37
+ raise ValueError("Target does not have valid logd")
36
38
 
37
39
  def validate_proposal(self):
38
40
  if not isinstance(self.proposal, cuqi.distribution.Distribution):
@@ -0,0 +1,17 @@
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.SamplerNew)]
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