CUQIpy 1.0.0.post0.dev200__py3-none-any.whl → 1.0.0.post0.dev215__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.dev200
3
+ Version: 1.0.0.post0.dev215
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=OMomrpoWG7dDM1G31xt8ygCpA7HDRjr2cO8HYsOyvnI,510
3
+ cuqi/_version.py,sha256=sNrHAfViy4LxInA0qKOPSSLL6RwoIRQFj5jySEVQA78,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
@@ -21,7 +21,7 @@ cuqi/distribution/_cmrf.py,sha256=tCbEulM_O7FB3C_W-3IqZp9zGHkTofCdFF0ybHc9UZI,37
21
21
  cuqi/distribution/_custom.py,sha256=uUJwGlGjcMY89mIyu9nFI3OafLOMgn8uAEMfCbTDzi0,10661
22
22
  cuqi/distribution/_distribution.py,sha256=G7BCpVueK4QLoLa_hu9h-Euh58Yp9SrgUKuudUlg-pw,18351
23
23
  cuqi/distribution/_gamma.py,sha256=9vljt5iaBDCHRhrVCMLc2RWDuBchZRQcv9buJMDYPlM,3434
24
- cuqi/distribution/_gaussian.py,sha256=Ymllxg7ZQE24ss0oVgtPII4Hx4-xy3x1tAb01_-4i_U,33026
24
+ cuqi/distribution/_gaussian.py,sha256=DmmgVxKp4iEiEYWDdDcRoh35y14Oepn-zDHex0WVaYo,33316
25
25
  cuqi/distribution/_gmrf.py,sha256=OwId8qQWEtmC2fxVhL4iBHZnc8ZCrZzfV6yGXDE3k30,9522
26
26
  cuqi/distribution/_inverse_gamma.py,sha256=XRcNGW_jzORL08V7VvtsuMUoQioBAGbN12qe8hCXJvg,3309
27
27
  cuqi/distribution/_joint_distribution.py,sha256=jRsV1Dt-pW6sG_xNqF0TugeVKDJY4Kh5aBLsIWfv394,15043
@@ -74,11 +74,11 @@ cuqi/solver/__init__.py,sha256=DGl8IdUnochRXHNDEy_13o_VT0vLFY6FjMmmSH6YUkY,169
74
74
  cuqi/solver/_solver.py,sha256=TgezixCVf8nKGtEF9ZrkaTtAfxSs1Z8CR_cmhdTMqRw,22776
75
75
  cuqi/testproblem/__init__.py,sha256=DWTOcyuNHMbhEuuWlY5CkYkNDSAqhvsKmJXBLivyblU,202
76
76
  cuqi/testproblem/_testproblem.py,sha256=x769LwwRdJdzIiZkcQUGb_5-vynNTNALXWKato7sS0Q,52540
77
- cuqi/utilities/__init__.py,sha256=EfxHLdsyDNugbmbzs43nV_AeKcycM9sVBjG9WZydagA,351
77
+ cuqi/utilities/__init__.py,sha256=T4tLsC215MknBCsw_C0Qeeg_ox26aDUrCA5hbWvNQkU,387
78
78
  cuqi/utilities/_get_python_variable_name.py,sha256=QwlBVj2koJRA8s8pWd554p7-ElcI7HUwY32HknaR92E,1827
79
- cuqi/utilities/_utilities.py,sha256=At3DOXRdF3GwLkVcM2FXooGyjAGfPkIM0bRzhTfLmWk,8046
80
- CUQIpy-1.0.0.post0.dev200.dist-info/LICENSE,sha256=kJWRPrtRoQoZGXyyvu50Uc91X6_0XRaVfT0YZssicys,10799
81
- CUQIpy-1.0.0.post0.dev200.dist-info/METADATA,sha256=Ex1df84ojAKEQALE4aX4Zxuggikfjcipg89U0w_kTwI,18393
82
- CUQIpy-1.0.0.post0.dev200.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
83
- CUQIpy-1.0.0.post0.dev200.dist-info/top_level.txt,sha256=AgmgMc6TKfPPqbjV0kvAoCBN334i_Lwwojc7HE3ZwD0,5
84
- CUQIpy-1.0.0.post0.dev200.dist-info/RECORD,,
79
+ cuqi/utilities/_utilities.py,sha256=MWAqV6L5btMpWwlUzrZYuV2VeSpfTbOaLRMRkuw2WIA,8509
80
+ CUQIpy-1.0.0.post0.dev215.dist-info/LICENSE,sha256=kJWRPrtRoQoZGXyyvu50Uc91X6_0XRaVfT0YZssicys,10799
81
+ CUQIpy-1.0.0.post0.dev215.dist-info/METADATA,sha256=pVkP3JyvDX9MurRCi3GgZxVp11N8hEyVzFV4Fu7Yxxg,18393
82
+ CUQIpy-1.0.0.post0.dev215.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
83
+ CUQIpy-1.0.0.post0.dev215.dist-info/top_level.txt,sha256=AgmgMc6TKfPPqbjV0kvAoCBN334i_Lwwojc7HE3ZwD0,5
84
+ CUQIpy-1.0.0.post0.dev215.dist-info/RECORD,,
cuqi/_version.py CHANGED
@@ -8,11 +8,11 @@ import json
8
8
 
9
9
  version_json = '''
10
10
  {
11
- "date": "2024-04-26T10:35:11+0200",
11
+ "date": "2024-05-16T11:29:50+0200",
12
12
  "dirty": false,
13
13
  "error": null,
14
- "full-revisionid": "f8f57f6a84e3242f71819fd301d3892fc8fb87c9",
15
- "version": "1.0.0.post0.dev200"
14
+ "full-revisionid": "b713d6478d33977b12342e4bcb29968a95ee5973",
15
+ "version": "1.0.0.post0.dev215"
16
16
  }
17
17
  ''' # END VERSION_JSON
18
18
 
@@ -9,7 +9,7 @@ import scipy.linalg as splinalg
9
9
 
10
10
  from cuqi import config
11
11
  from cuqi.geometry import _get_identity_geometries
12
- from cuqi.utilities import force_ndarray, sparse_cholesky
12
+ from cuqi.utilities import force_ndarray, sparse_cholesky, check_if_conditional_from_attr
13
13
  from cuqi.distribution import Distribution
14
14
 
15
15
  # We potentially allow the use of sksparse.cholmod for sparse Cholesky
@@ -191,7 +191,7 @@ class Gaussian(Distribution):
191
191
  value = force_ndarray(value)
192
192
  self._sqrtcov = value
193
193
  self._cov = None # Reset covariance (in case it was computed before)
194
- if (value is not None) and (not callable(value)):
194
+ if (value is not None) and (not callable(value)):
195
195
  if self.dim > config.MIN_DIM_SPARSE:
196
196
  sparse_flag = True # do sparse computations
197
197
  else:
@@ -214,7 +214,7 @@ class Gaussian(Distribution):
214
214
  value = force_ndarray(value)
215
215
  self._sqrtprec = value
216
216
  self._cov = None # Reset covariance (in case it was computed before)
217
- if (value is not None) and (not callable(value)):
217
+ if not check_if_conditional_from_attr(value):
218
218
  if self.dim > config.MIN_DIM_SPARSE:
219
219
  sparse_flag = True # do sparse computations
220
220
  else:
@@ -631,7 +631,7 @@ def get_sqrtprec_from_sqrtprec(dim, sqrtprec, sparse_flag):
631
631
  dim : int
632
632
  Dimension of the sqrtprec matrix.
633
633
 
634
- sqrtprec : 1-d or 2-d ndarray or sparse matrix
634
+ sqrtprec : 1-d or 2-d ndarray or sparse matrix or scipy.sparse.linalg.LinearOperator
635
635
  Square root of precision matrix. If 1-dimensional, then assumed to be a diagonal matrix.
636
636
 
637
637
  sparse_flag: bool
@@ -666,6 +666,14 @@ def get_sqrtprec_from_sqrtprec(dim, sqrtprec, sparse_flag):
666
666
  logdet = np.sum(-np.log(sqrtprec.data**2))
667
667
  rank = dim
668
668
 
669
+ # sqrtprec is LinearOperator
670
+ elif isinstance(sqrtprec, spa.linalg.LinearOperator):
671
+ if hasattr(sqrtprec, 'logdet'):
672
+ logdet = sqrtprec.logdet
673
+ else:
674
+ logdet = None
675
+ rank = dim
676
+
669
677
  # sqrtprec diagonal
670
678
  elif np.count_nonzero(sqrtprec-np.diag(sqrtprec.diagonal())) == 0:
671
679
  stdinv = sqrtprec.diagonal()
@@ -10,6 +10,7 @@ from ._utilities import (
10
10
  ProblemInfo,
11
11
  sparse_cholesky,
12
12
  approx_derivative,
13
+ check_if_conditional_from_attr,
13
14
  )
14
15
 
15
16
  from ._get_python_variable_name import _get_python_variable_name
@@ -64,13 +64,27 @@ def get_indirect_variables(dist):
64
64
  attributes = []
65
65
  for attribute in dist.get_mutable_variables():
66
66
  value = getattr(dist, attribute)
67
- if callable(value):
67
+ if check_if_conditional_from_attr(value):
68
68
  keys = get_non_default_args(value)
69
69
  for key in keys:
70
70
  if key not in attributes: #Ensure we did not already find this key
71
71
  attributes.append(key)
72
72
  return attributes
73
73
 
74
+ def check_if_conditional_from_attr(value):
75
+ """
76
+ Check if a distribution is conditional from a given attribute.
77
+ So far, we assume that a distribution is conditional if
78
+ - the given attribute is a callable function and
79
+ - the given attribute is not a LinearOperator.
80
+ """
81
+ if isinstance(value, spslinalg.LinearOperator):
82
+ return False
83
+ elif callable(value):
84
+ return True
85
+ else:
86
+ return False
87
+
74
88
  def get_writeable_attributes(dist):
75
89
  """ Get writeable attributes of object instance. """
76
90
  attributes = []