CUQIpy 1.1.0.post0.dev21__py3-none-any.whl → 1.1.0.post0.dev39__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.
- {CUQIpy-1.1.0.post0.dev21.dist-info → CUQIpy-1.1.0.post0.dev39.dist-info}/METADATA +1 -1
- {CUQIpy-1.1.0.post0.dev21.dist-info → CUQIpy-1.1.0.post0.dev39.dist-info}/RECORD +9 -9
- {CUQIpy-1.1.0.post0.dev21.dist-info → CUQIpy-1.1.0.post0.dev39.dist-info}/WHEEL +1 -1
- cuqi/_version.py +3 -3
- cuqi/samples/_samples.py +8 -0
- cuqi/utilities/__init__.py +2 -0
- cuqi/utilities/_utilities.py +116 -0
- {CUQIpy-1.1.0.post0.dev21.dist-info → CUQIpy-1.1.0.post0.dev39.dist-info}/LICENSE +0 -0
- {CUQIpy-1.1.0.post0.dev21.dist-info → CUQIpy-1.1.0.post0.dev39.dist-info}/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: CUQIpy
|
|
3
|
-
Version: 1.1.0.post0.
|
|
3
|
+
Version: 1.1.0.post0.dev39
|
|
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=
|
|
3
|
+
cuqi/_version.py,sha256=SFVwuROZ7PjMxlopbxtd_O7tlfLQi9nwgd9r4SLXD7o,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
|
|
@@ -77,16 +77,16 @@ cuqi/sampler/_pcn.py,sha256=F0h9-nUFtkqn-o-1s8BCsmr8V7u6R7ycoCOeeV1uhj0,8601
|
|
|
77
77
|
cuqi/sampler/_rto.py,sha256=-AtMiYq4fh7pF9zVqfYjYtQbIIEGayrWyRGTj8KecfE,11518
|
|
78
78
|
cuqi/sampler/_sampler.py,sha256=TkZ_WAS-5Q43oICa-Elc2gftsRTBd7PEDUMDZ9tTGmU,5712
|
|
79
79
|
cuqi/samples/__init__.py,sha256=E7B9IBUsiOBr-HAKH9o3_Lqhq4KeWO87hmesHkdbwTY,30
|
|
80
|
-
cuqi/samples/_samples.py,sha256=
|
|
80
|
+
cuqi/samples/_samples.py,sha256=Pfy2piHmvZ3_fxh3c3BsQtX3mryIsDqRrqJ-Q7zw4Zo,35161
|
|
81
81
|
cuqi/solver/__init__.py,sha256=DGl8IdUnochRXHNDEy_13o_VT0vLFY6FjMmmSH6YUkY,169
|
|
82
82
|
cuqi/solver/_solver.py,sha256=TgezixCVf8nKGtEF9ZrkaTtAfxSs1Z8CR_cmhdTMqRw,22776
|
|
83
83
|
cuqi/testproblem/__init__.py,sha256=DWTOcyuNHMbhEuuWlY5CkYkNDSAqhvsKmJXBLivyblU,202
|
|
84
84
|
cuqi/testproblem/_testproblem.py,sha256=x769LwwRdJdzIiZkcQUGb_5-vynNTNALXWKato7sS0Q,52540
|
|
85
|
-
cuqi/utilities/__init__.py,sha256=
|
|
85
|
+
cuqi/utilities/__init__.py,sha256=H7xpJe2UinjZftKvE2JuXtTi4DqtkR6uIezStAXwfGg,428
|
|
86
86
|
cuqi/utilities/_get_python_variable_name.py,sha256=QwlBVj2koJRA8s8pWd554p7-ElcI7HUwY32HknaR92E,1827
|
|
87
|
-
cuqi/utilities/_utilities.py,sha256=
|
|
88
|
-
CUQIpy-1.1.0.post0.
|
|
89
|
-
CUQIpy-1.1.0.post0.
|
|
90
|
-
CUQIpy-1.1.0.post0.
|
|
91
|
-
CUQIpy-1.1.0.post0.
|
|
92
|
-
CUQIpy-1.1.0.post0.
|
|
87
|
+
cuqi/utilities/_utilities.py,sha256=Jc4knn80vLoA7kgw9FzXwKVFGaNBOXiA9kgvltZU3Ao,11777
|
|
88
|
+
CUQIpy-1.1.0.post0.dev39.dist-info/LICENSE,sha256=kJWRPrtRoQoZGXyyvu50Uc91X6_0XRaVfT0YZssicys,10799
|
|
89
|
+
CUQIpy-1.1.0.post0.dev39.dist-info/METADATA,sha256=tPkKE5LGWKpgvgM1zkAfKPq4tV0kLGVpbdZSz5ZCn3E,18390
|
|
90
|
+
CUQIpy-1.1.0.post0.dev39.dist-info/WHEEL,sha256=UvcQYKBHoFqaQd6LKyqHw9fxEolWLQnlzP0h_LgJAfI,91
|
|
91
|
+
CUQIpy-1.1.0.post0.dev39.dist-info/top_level.txt,sha256=AgmgMc6TKfPPqbjV0kvAoCBN334i_Lwwojc7HE3ZwD0,5
|
|
92
|
+
CUQIpy-1.1.0.post0.dev39.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-
|
|
11
|
+
"date": "2024-08-29T10:46:43+0300",
|
|
12
12
|
"dirty": false,
|
|
13
13
|
"error": null,
|
|
14
|
-
"full-revisionid": "
|
|
15
|
-
"version": "1.1.0.post0.
|
|
14
|
+
"full-revisionid": "9d8920342c73b1bd8e7a47a216eb34056ea2f5d6",
|
|
15
|
+
"version": "1.1.0.post0.dev39"
|
|
16
16
|
}
|
|
17
17
|
''' # END VERSION_JSON
|
|
18
18
|
|
cuqi/samples/_samples.py
CHANGED
|
@@ -873,3 +873,11 @@ class Samples(object):
|
|
|
873
873
|
ax = arviz.plot_violin(datadict, **kwargs)
|
|
874
874
|
|
|
875
875
|
return ax
|
|
876
|
+
|
|
877
|
+
def __repr__(self) -> str:
|
|
878
|
+
return "CUQIpy Samples:\n" + \
|
|
879
|
+
"---------------\n\n" + \
|
|
880
|
+
"Ns (number of samples):\n {}\n\n".format(self.Ns) + \
|
|
881
|
+
"Geometry:\n {}\n\n".format(self.geometry) + \
|
|
882
|
+
"Shape:\n {}\n\n".format(self.shape) + \
|
|
883
|
+
"Samples:\n {}\n\n".format(self.samples)
|
cuqi/utilities/__init__.py
CHANGED
cuqi/utilities/_utilities.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from cuqi.array import CUQIarray
|
|
2
|
+
from cuqi.density import Density
|
|
2
3
|
import numpy as np
|
|
3
4
|
import inspect
|
|
4
5
|
from numbers import Number
|
|
@@ -7,6 +8,7 @@ from scipy.sparse import linalg as spslinalg
|
|
|
7
8
|
from dataclasses import dataclass
|
|
8
9
|
from abc import ABCMeta
|
|
9
10
|
import copy
|
|
11
|
+
import matplotlib.pyplot as plt
|
|
10
12
|
|
|
11
13
|
|
|
12
14
|
def force_ndarray(value,flatten=False):
|
|
@@ -229,3 +231,117 @@ def approx_gradient(func, x, epsilon= 0.000001):
|
|
|
229
231
|
eps_vec[i] = 0.0
|
|
230
232
|
|
|
231
233
|
return FD_gradient
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
# Function for plotting 1D density functions
|
|
237
|
+
def plot_1D_density(density:Density,
|
|
238
|
+
v_min, v_max,
|
|
239
|
+
N=501, log_scale=False,
|
|
240
|
+
**kwargs):
|
|
241
|
+
""" Plot 1D density function
|
|
242
|
+
|
|
243
|
+
Parameters
|
|
244
|
+
----------
|
|
245
|
+
density : CUQIpy Density
|
|
246
|
+
The density to be plotted.
|
|
247
|
+
|
|
248
|
+
v_min : float
|
|
249
|
+
Minimum value for the variable.
|
|
250
|
+
|
|
251
|
+
v_max : float
|
|
252
|
+
Maximum value for the variable.
|
|
253
|
+
|
|
254
|
+
N : int
|
|
255
|
+
Number of grid points for the variable.
|
|
256
|
+
|
|
257
|
+
log_scale : bool
|
|
258
|
+
If True, the density is plotted in log scale.
|
|
259
|
+
|
|
260
|
+
kwargs : dict
|
|
261
|
+
Additional keyword arguments for the plot that are passed to the
|
|
262
|
+
underlying plotting method: `matplotlib.pyplot.plot` function
|
|
263
|
+
in this case.
|
|
264
|
+
|
|
265
|
+
"""
|
|
266
|
+
# Assert that the density is 1D
|
|
267
|
+
assert density.dim == 1, "The density must be for a scalar variable"
|
|
268
|
+
ls = np.linspace(v_min, v_max, N)
|
|
269
|
+
|
|
270
|
+
# Create a map to evaluate density
|
|
271
|
+
density_map = (lambda x: x) if log_scale else (lambda x: np.exp(x))
|
|
272
|
+
|
|
273
|
+
# Evaluate density on grid
|
|
274
|
+
y = [density_map(density.logd(grid_point)) for grid_point in ls]
|
|
275
|
+
p = plt.plot(ls, y, **kwargs)
|
|
276
|
+
return p
|
|
277
|
+
|
|
278
|
+
# Function for plotting 2D density functions
|
|
279
|
+
def plot_2D_density(density: Density,
|
|
280
|
+
v1_min, v1_max,
|
|
281
|
+
v2_min, v2_max,
|
|
282
|
+
N1=201, N2=201,
|
|
283
|
+
log_scale=False,
|
|
284
|
+
**kwargs):
|
|
285
|
+
""" Plot 2D density function
|
|
286
|
+
|
|
287
|
+
Parameters
|
|
288
|
+
----------
|
|
289
|
+
density : CUQIpy Density
|
|
290
|
+
The density to be plotted.
|
|
291
|
+
|
|
292
|
+
v1_min : float
|
|
293
|
+
Minimum value for the first variable.
|
|
294
|
+
|
|
295
|
+
v1_max : float
|
|
296
|
+
Maximum value for the first variable.
|
|
297
|
+
|
|
298
|
+
v2_min : float
|
|
299
|
+
Minimum value for the second variable.
|
|
300
|
+
|
|
301
|
+
v2_max : float
|
|
302
|
+
Maximum value for the second variable.
|
|
303
|
+
|
|
304
|
+
N1 : int
|
|
305
|
+
Number of grid points for the first variable.
|
|
306
|
+
|
|
307
|
+
N2 : int
|
|
308
|
+
Number of grid points for the second variable.
|
|
309
|
+
|
|
310
|
+
log_scale : bool
|
|
311
|
+
If True, the density is plotted in log scale.
|
|
312
|
+
|
|
313
|
+
kwargs : dict
|
|
314
|
+
Additional keyword arguments for the plot that are passed to the
|
|
315
|
+
underlying plotting method: `matplotlib.pyplot.imshow` function
|
|
316
|
+
in this case.
|
|
317
|
+
|
|
318
|
+
"""
|
|
319
|
+
# Assert that the density is 2D
|
|
320
|
+
assert density.dim == 2,\
|
|
321
|
+
"The density must be for a two-dimensional variable"
|
|
322
|
+
# Create grid
|
|
323
|
+
ls1 = np.linspace(v1_min, v1_max, N1)
|
|
324
|
+
ls2 = np.linspace(v2_min, v2_max, N2)
|
|
325
|
+
grid1, grid2 = np.meshgrid(ls1, ls2)
|
|
326
|
+
|
|
327
|
+
# Create a map to evaluate density
|
|
328
|
+
density_map = (lambda x: x) if log_scale else (lambda x: np.exp(x))
|
|
329
|
+
|
|
330
|
+
# Evaluate density on grid
|
|
331
|
+
evaluated_density = np.zeros((N1, N2))
|
|
332
|
+
for ii in range(N1):
|
|
333
|
+
for jj in range(N2):
|
|
334
|
+
evaluated_density[ii,jj] = density_map(
|
|
335
|
+
density.logd([grid1[ii,jj], grid2[ii,jj]]))
|
|
336
|
+
|
|
337
|
+
# Plot
|
|
338
|
+
pixelwidth_x = (v1_max-v1_min)/(N2-1)
|
|
339
|
+
pixelwidth_y = (v2_max-v2_min)/(N2-1)
|
|
340
|
+
|
|
341
|
+
hp_x = 0.5*pixelwidth_x
|
|
342
|
+
hp_y = 0.5*pixelwidth_y
|
|
343
|
+
|
|
344
|
+
extent = (v1_min-hp_x, v1_max+hp_x, v2_min-hp_y, v2_max+hp_y)
|
|
345
|
+
|
|
346
|
+
im = plt.imshow(evaluated_density, origin='lower', extent=extent, **kwargs)
|
|
347
|
+
return im
|
|
File without changes
|
|
File without changes
|