CUQIpy 1.2.0.post0.dev380__tar.gz → 1.2.0.post0.dev400__tar.gz

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.

Files changed (126) hide show
  1. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/CUQIpy.egg-info/PKG-INFO +2 -2
  2. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/CUQIpy.egg-info/SOURCES.txt +2 -0
  3. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/PKG-INFO +2 -2
  4. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/_version.py +3 -3
  5. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/experimental/__init__.py +1 -0
  6. cuqipy-1.2.0.post0.dev400/cuqi/experimental/geometry/__init__.py +1 -0
  7. cuqipy-1.2.0.post0.dev400/cuqi/experimental/geometry/_productgeometry.py +181 -0
  8. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/CUQIpy.egg-info/dependency_links.txt +0 -0
  9. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/CUQIpy.egg-info/requires.txt +0 -0
  10. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/CUQIpy.egg-info/top_level.txt +0 -0
  11. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/LICENSE +0 -0
  12. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/README.md +0 -0
  13. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/__init__.py +0 -0
  14. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/_messages.py +0 -0
  15. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/array/__init__.py +0 -0
  16. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/array/_array.py +0 -0
  17. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/config.py +0 -0
  18. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/data/__init__.py +0 -0
  19. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/data/_data.py +0 -0
  20. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/data/astronaut.npz +0 -0
  21. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/data/camera.npz +0 -0
  22. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/data/cat.npz +0 -0
  23. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/data/cookie.png +0 -0
  24. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/data/satellite.mat +0 -0
  25. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/density/__init__.py +0 -0
  26. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/density/_density.py +0 -0
  27. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/diagnostics.py +0 -0
  28. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/distribution/__init__.py +0 -0
  29. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/distribution/_beta.py +0 -0
  30. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/distribution/_cauchy.py +0 -0
  31. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/distribution/_cmrf.py +0 -0
  32. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/distribution/_custom.py +0 -0
  33. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/distribution/_distribution.py +0 -0
  34. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/distribution/_gamma.py +0 -0
  35. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/distribution/_gaussian.py +0 -0
  36. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/distribution/_gmrf.py +0 -0
  37. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/distribution/_inverse_gamma.py +0 -0
  38. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/distribution/_joint_distribution.py +0 -0
  39. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/distribution/_laplace.py +0 -0
  40. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/distribution/_lmrf.py +0 -0
  41. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/distribution/_lognormal.py +0 -0
  42. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/distribution/_modifiedhalfnormal.py +0 -0
  43. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/distribution/_normal.py +0 -0
  44. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/distribution/_posterior.py +0 -0
  45. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/distribution/_smoothed_laplace.py +0 -0
  46. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/distribution/_truncated_normal.py +0 -0
  47. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/distribution/_uniform.py +0 -0
  48. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/experimental/algebra/__init__.py +0 -0
  49. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/experimental/algebra/_ast.py +0 -0
  50. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/experimental/algebra/_orderedset.py +0 -0
  51. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/experimental/algebra/_randomvariable.py +0 -0
  52. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/experimental/mcmc/__init__.py +0 -0
  53. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/experimental/mcmc/_conjugate.py +0 -0
  54. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/experimental/mcmc/_conjugate_approx.py +0 -0
  55. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/experimental/mcmc/_cwmh.py +0 -0
  56. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/experimental/mcmc/_direct.py +0 -0
  57. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/experimental/mcmc/_gibbs.py +0 -0
  58. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/experimental/mcmc/_hmc.py +0 -0
  59. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/experimental/mcmc/_langevin_algorithm.py +0 -0
  60. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/experimental/mcmc/_laplace_approximation.py +0 -0
  61. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/experimental/mcmc/_mh.py +0 -0
  62. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/experimental/mcmc/_pcn.py +0 -0
  63. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/experimental/mcmc/_rto.py +0 -0
  64. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/experimental/mcmc/_sampler.py +0 -0
  65. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/experimental/mcmc/_utilities.py +0 -0
  66. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/geometry/__init__.py +0 -0
  67. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/geometry/_geometry.py +0 -0
  68. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/implicitprior/__init__.py +0 -0
  69. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/implicitprior/_regularizedGMRF.py +0 -0
  70. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/implicitprior/_regularizedGaussian.py +0 -0
  71. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/implicitprior/_regularizedUnboundedUniform.py +0 -0
  72. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/implicitprior/_restorator.py +0 -0
  73. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/likelihood/__init__.py +0 -0
  74. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/likelihood/_likelihood.py +0 -0
  75. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/model/__init__.py +0 -0
  76. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/model/_model.py +0 -0
  77. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/operator/__init__.py +0 -0
  78. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/operator/_operator.py +0 -0
  79. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/pde/__init__.py +0 -0
  80. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/pde/_pde.py +0 -0
  81. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/problem/__init__.py +0 -0
  82. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/problem/_problem.py +0 -0
  83. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/sampler/__init__.py +0 -0
  84. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/sampler/_conjugate.py +0 -0
  85. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/sampler/_conjugate_approx.py +0 -0
  86. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/sampler/_cwmh.py +0 -0
  87. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/sampler/_gibbs.py +0 -0
  88. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/sampler/_hmc.py +0 -0
  89. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/sampler/_langevin_algorithm.py +0 -0
  90. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/sampler/_laplace_approximation.py +0 -0
  91. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/sampler/_mh.py +0 -0
  92. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/sampler/_pcn.py +0 -0
  93. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/sampler/_rto.py +0 -0
  94. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/sampler/_sampler.py +0 -0
  95. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/samples/__init__.py +0 -0
  96. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/samples/_samples.py +0 -0
  97. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/solver/__init__.py +0 -0
  98. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/solver/_solver.py +0 -0
  99. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/testproblem/__init__.py +0 -0
  100. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/testproblem/_testproblem.py +0 -0
  101. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/utilities/__init__.py +0 -0
  102. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/utilities/_get_python_variable_name.py +0 -0
  103. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/cuqi/utilities/_utilities.py +0 -0
  104. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/pyproject.toml +0 -0
  105. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/requirements.txt +0 -0
  106. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/setup.cfg +0 -0
  107. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/setup.py +0 -0
  108. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/tests/test_MRFs.py +0 -0
  109. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/tests/test_abstract_distribution_density.py +0 -0
  110. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/tests/test_bayesian_inversion.py +0 -0
  111. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/tests/test_density.py +0 -0
  112. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/tests/test_distribution.py +0 -0
  113. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/tests/test_distributions_shape.py +0 -0
  114. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/tests/test_geometry.py +0 -0
  115. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/tests/test_implicit_priors.py +0 -0
  116. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/tests/test_joint_distribution.py +0 -0
  117. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/tests/test_likelihood.py +0 -0
  118. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/tests/test_model.py +0 -0
  119. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/tests/test_pde.py +0 -0
  120. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/tests/test_posterior.py +0 -0
  121. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/tests/test_problem.py +0 -0
  122. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/tests/test_sampler.py +0 -0
  123. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/tests/test_samples.py +0 -0
  124. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/tests/test_solver.py +0 -0
  125. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/tests/test_testproblem.py +0 -0
  126. {cuqipy-1.2.0.post0.dev380 → cuqipy-1.2.0.post0.dev400}/tests/test_utilities.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: CUQIpy
3
- Version: 1.2.0.post0.dev380
3
+ Version: 1.2.0.post0.dev400
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
@@ -49,6 +49,8 @@ cuqi/experimental/algebra/__init__.py
49
49
  cuqi/experimental/algebra/_ast.py
50
50
  cuqi/experimental/algebra/_orderedset.py
51
51
  cuqi/experimental/algebra/_randomvariable.py
52
+ cuqi/experimental/geometry/__init__.py
53
+ cuqi/experimental/geometry/_productgeometry.py
52
54
  cuqi/experimental/mcmc/__init__.py
53
55
  cuqi/experimental/mcmc/_conjugate.py
54
56
  cuqi/experimental/mcmc/_conjugate_approx.py
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: CUQIpy
3
- Version: 1.2.0.post0.dev380
3
+ Version: 1.2.0.post0.dev400
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
@@ -8,11 +8,11 @@ import json
8
8
 
9
9
  version_json = '''
10
10
  {
11
- "date": "2024-12-20T09:13:49+0100",
11
+ "date": "2025-01-10T07:03:38+0300",
12
12
  "dirty": false,
13
13
  "error": null,
14
- "full-revisionid": "7405af566d2a50ba59fc861865d41c08f8dcf160",
15
- "version": "1.2.0.post0.dev380"
14
+ "full-revisionid": "4ef35e31b8a7b894a879a6e8c22487ab96989b95",
15
+ "version": "1.2.0.post0.dev400"
16
16
  }
17
17
  ''' # END VERSION_JSON
18
18
 
@@ -1,3 +1,4 @@
1
1
  """ Experimental module for testing new features and ideas. """
2
2
  from . import mcmc
3
3
  from . import algebra
4
+ from . import geometry
@@ -0,0 +1 @@
1
+ from ._productgeometry import _ProductGeometry
@@ -0,0 +1,181 @@
1
+ from cuqi.geometry import Geometry
2
+ import numpy as np
3
+
4
+ class _ProductGeometry(Geometry):
5
+ """ A class for representing a product geometry. A product geometry
6
+ represents the product space of multiple geometries of type :class:`Geometry`.
7
+ See the example below for a product geometry of two geometries.
8
+
9
+ Parameters
10
+ ----------
11
+ \*geometries : cuqi.geometry.Geometry
12
+ The geometries to be combined into a product geometry. Each geometry
13
+ is passed as a comma-separated argument.
14
+
15
+ Example
16
+ -------
17
+ .. code-block:: python
18
+ import numpy as np
19
+ from cuqi.geometry import Continuous1D, Discrete
20
+ from cuqi.experimental.geometry import _ProductGeometry
21
+ geometry1 = Continuous1D(np.linspace(0, 1, 100))
22
+ geometry2 = Discrete(["sound_speed"])
23
+ product_geometry = _ProductGeometry(geometry1, geometry2)
24
+ """
25
+
26
+ def __init__(self, *geometries):
27
+ self.geometries = geometries
28
+
29
+ @property
30
+ def geometries(self):
31
+ """List of geometries that are combined to form the product geometry."""
32
+ return self._geometries
33
+
34
+ @geometries.setter
35
+ def geometries(self, geometries):
36
+ # Check if all geometries are of type Geometry.
37
+ for g in geometries:
38
+ if not isinstance(g, Geometry):
39
+ raise TypeError(
40
+ "All geometries must be of type Geometry. "
41
+ "Received: {}".format(type(g))
42
+ )
43
+ self._geometries = geometries
44
+
45
+ @property
46
+ def fun_shape(self):
47
+ """Shape of the function representation. Returns a tuple, where
48
+ each element of the tuple is the shape of the function
49
+ representation of each geometry."""
50
+ return tuple([g.fun_shape for g in self.geometries])
51
+
52
+ @property
53
+ def fun_dim(self):
54
+ """Dimension of the function representation which is the sum of
55
+ the function representation dimensions of each geometry."""
56
+ return sum([g.fun_dim for g in self.geometries])
57
+
58
+ @property
59
+ def par_shape(self):
60
+ """Shape of the parameter representation. Returns a tuple, where
61
+ each element of the tuple is the shape of the parameter
62
+ representation of each geometry."""
63
+ return tuple([g.par_shape for g in self.geometries])
64
+
65
+ @property
66
+ def par_dim(self):
67
+ """Dimension of the parameter representation which is the sum of
68
+ the parameter representation dimensions of each geometry."""
69
+ return sum(self.par_dim_list)
70
+
71
+ @property
72
+ def par_dim_list(self):
73
+ """List of the parameter representation dimensions of each
74
+ geometry. This property is useful for indexing a stacked parameter
75
+ vector."""
76
+ return [g.par_dim for g in self.geometries]
77
+
78
+ @property
79
+ def stacked_par_split_indices(self):
80
+ """Indices at which the stacked parameter vector should be split
81
+ to obtain the parameter vectors for each geometry. For example, if
82
+ the stacked parameter vector is [1, 2, 3, 4, 5, 6] and the parameter
83
+ vectors for each geometry are [1, 2], [3, 4], and [5, 6], then the
84
+ split indices are [2, 4]"""
85
+ return np.cumsum(self.par_dim_list[:-1])
86
+
87
+ @property
88
+ def number_of_geometries(self):
89
+ """Number of geometries in the product geometry."""
90
+ return len(self.geometries)
91
+
92
+ def _split_par(self, par):
93
+ """Splits a stacked parameter vector into parameter vectors for each
94
+ geometry."""
95
+ return tuple(np.split(par, self.stacked_par_split_indices))
96
+
97
+ def _plot(self, values, **kwargs):
98
+ """Plotting function for the product geometry."""
99
+ raise NotImplementedError(
100
+ f"Plotting not implemented for {self.__class__.__name__}.")
101
+
102
+ def par2fun(self, *pars):
103
+ """Converts parameter vector(s) into function values for each
104
+ geometry. The parameter vector can be stacked (all parameters are
105
+ in one vector) or unstacked (one parameter vector corresponds to
106
+ each geometry). In all cases, the order of the parameter vectors
107
+ should follow the order of the geometries in the product, i.e., the
108
+ first parameter vector corresponds to the first geometry and so on."""
109
+
110
+ # If one argument is passed, then it is assumed that the parameter
111
+ # vector is stacked and split it.
112
+ # No effect if the parameter vector is already split and corresponds
113
+ # to one geometry.
114
+ if len(pars) == 1:
115
+ pars = self._split_par(pars[0])
116
+
117
+ # Convert parameter vectors to function values for each geometry.
118
+ funvals = []
119
+ for i, g in enumerate(self.geometries):
120
+ funval_i = g.par2fun(pars[i])
121
+ funvals.append(funval_i)
122
+ return tuple(funvals)
123
+
124
+ def fun2par(self, *funvals, stacked=False):
125
+ """Converts (multiple) function values into the corresponding
126
+ parameter vectors. If the flag stacked is set to True, then the
127
+ parameter vectors are stacked into one vector. Otherwise, the
128
+ parameter vectors are returned as a tuple. The order of function
129
+ values should follow the order of the geometries in the product,
130
+ i.e., the first function value corresponds to the first geometry
131
+ and so on."""
132
+
133
+ pars = []
134
+ for i, g in enumerate(self.geometries):
135
+ par_i = g.fun2par(funvals[i])
136
+ pars.append(par_i)
137
+
138
+ # stack parameters:
139
+ if stacked:
140
+ # if single sample
141
+ if len(pars[0].shape) == 1:
142
+ stacked_val = np.hstack(pars)
143
+ elif len(pars[0].shape) == 2:
144
+ stacked_val = np.vstack(pars)
145
+ else:
146
+ raise ValueError(
147
+ "Cannot stack parameter vectors with more than 2 dimensions."
148
+ )
149
+
150
+ return stacked_val if stacked else tuple(pars)
151
+
152
+ def vec2fun(self, *funvecs):
153
+ """Maps function vector representation, if available, to function
154
+ values. The order of the function vectors should follow the order of
155
+ the geometries in the product, i.e., the first function vector
156
+ corresponds to the first geometry and so on."""
157
+ funvals = []
158
+ for i, g in enumerate(self.geometries):
159
+ funvals.append(g.vec2fun(funvecs[i]))
160
+
161
+ return tuple(funvals)
162
+
163
+ def fun2vec(self, *funvals):
164
+ """Maps function values to a vector representation of the function
165
+ values, if available. The order of the function values should follow
166
+ the order of the geometries in the product, i.e., the first function
167
+ value corresponds to the first geometry and so on."""
168
+ funvecs = []
169
+ for i, g in enumerate(self.geometries):
170
+ funvecs.append(g.fun2vec(funvals[i]))
171
+
172
+ return tuple(funvecs)
173
+
174
+
175
+ def __repr__(self) -> str:
176
+ """Representation of the product geometry."""
177
+ string = "{}(".format(self.__class__.__name__) + "\n"
178
+ for g in self.geometries:
179
+ string += "\t{}\n".format(g.__repr__())
180
+ string += ")"
181
+ return string