Skip to content

Commit 97c23d7

Browse files
committed
Update package structure for pypi release
1 parent a0a72e6 commit 97c23d7

File tree

4 files changed

+19
-20
lines changed

4 files changed

+19
-20
lines changed

ProxNest/tests/test_optimisations.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import numpy as np
33
import ProxNest.utils as utils
44
import ProxNest.optimisations as opts
5+
from ProxNest.operators import sensing_operators as sense_ops
56

67

78
@pytest.mark.parametrize("tight", [True, False])
@@ -20,7 +21,8 @@ def test_l2_ball_projection(tight: bool, pos: bool):
2021
tau = -LogLikeliL(x0) * 1e-1
2122

2223
# Create a parameters structure.
23-
params = utils.create_parameters_dict(y=data, tight=tight, pos=pos, reality=True)
24+
id = sense_ops.Identity()
25+
params = utils.create_parameters_dict(y=data, Phi=id, Psi=id, tight=tight, pos=pos, reality=True)
2426

2527
# Evaluate the projection algorithm
2628
z = opts.l2_ball_proj.sopt_fast_proj_B2(x0, tau, params)
@@ -34,7 +36,8 @@ def test_l1_norm_projection_extremes(tight: bool, pos: bool):
3436
x = np.random.randn(64, 64)
3537

3638
# Create a parameters structure.
37-
params = utils.create_parameters_dict(tight=tight, pos=pos, reality=True)
39+
id = sense_ops.Identity()
40+
params = utils.create_parameters_dict(tight=tight, Phi=id, Psi=id, pos=pos, reality=True)
3841

3942
if tight:
4043
# Evaluate the l1-norm sub-iterations lambda=0
@@ -56,7 +59,8 @@ def test_l1_norm_projection_specific(tight: bool, pos: bool):
5659
obj_pred = (3 / 8) * len(x.flatten("C"))
5760

5861
# Create a parameters structure.
59-
params = utils.create_parameters_dict(tight=tight, pos=pos, reality=True)
62+
id = sense_ops.Identity()
63+
params = utils.create_parameters_dict(tight=tight, Phi=id, Psi=id, pos=pos, reality=True)
6064

6165
# Evaluate the l1-norm sub-iterations
6266
z = opts.l1_norm_prox.l1_norm_prox(x, lamb, params)

ProxNest/tests/test_sampling.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@
44
import ProxNest.utils as utils
55
import ProxNest.sampling as sampling
66
import ProxNest.optimisations as optimisations
7-
import ProxNest.operators as operators
7+
from ProxNest.operators import sensing_operators as sense_ops
88

99
def test_against_analytic_gaussian():
1010
""" Tests ProxNest against analytic Gaussian """
1111

1212
# A simple identity forward model and redundant dictionary
13-
phi = operators.sensing_operators.Identity()
14-
psi = operators.sensing_operators.Identity()
13+
id = sense_ops.Identity()
1514
sigma = 1
1615
iterations = 20
1716
delta = 1/2
@@ -22,7 +21,7 @@ def test_against_analytic_gaussian():
2221
# Parameter dictionary associated with optimisation problem of resampling from the prior subject to the likelihood iso-ball
2322
params = utils.create_parameters_dict(
2423
y = image, # Measurements i.e. data
25-
Phi = phi, # Forward model
24+
Phi = id, # Forward model
2625
epsilon = 1e-3, # Radius of L2-ball of likelihood
2726
tight = True, # Is Phi a tight frame or not?
2827
nu = 1, # Bound on the squared-norm of Phi
@@ -55,16 +54,16 @@ def test_against_analytic_gaussian():
5554
params["y"] = image
5655

5756
# Lambda functions to evaluate cost function
58-
LogLikeliL = lambda sol : - np.linalg.norm(image-phi.dir_op(sol))**2/(2*sigma**2)
57+
LogLikeliL = lambda sol : - np.linalg.norm(image-id.dir_op(sol))**2/(2*sigma**2)
5958

6059
# Lambda function for L2-norm identity prior backprojection steps
61-
proxH = lambda x, T : x - 2*T*psi.adj_op(psi.dir_op(x))*2*delta
60+
proxH = lambda x, T : x - 2*T*id.adj_op(id.dir_op(x))*2*delta
6261

6362
# Lambda function for L2-ball likelihood projection during resampling
6463
proxB = lambda x, tau: optimisations.l2_ball_proj.sopt_fast_proj_B2(x, tau, params)
6564

6665
# Select a starting position
67-
X0 = np.abs(phi.adj_op(image))
66+
X0 = np.abs(id.adj_op(image))
6867

6968
# Perform proximal nested sampling
7069
NS_BayEvi, NS_Trace = sampling.proximal_nested.ProxNestedSampling(X0, LogLikeliL, proxH, proxB, params, options)

ProxNest/utils.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
import numpy as np
2-
from ProxNest.operators import sensing_operators as sense
3-
4-
51
def create_parameters_dict(
62
y=0,
7-
Phi=sense.Identity(),
8-
Psi=sense.Identity(),
3+
Phi=None,
4+
Psi=None,
95
epsilon=1e-3,
106
tight=True,
117
nu=1,
@@ -23,9 +19,9 @@ def create_parameters_dict(
2319
Args:
2420
y (np.ndarray): Measurements (default = 0).
2521
26-
Phi (linear operator): Sensing operator (default = sense.Identity).
22+
Phi (linear operator): Sensing operator (default = None).
2723
28-
Psi (linear operator): Redundant dictionary (default = sense.Identity).
24+
Psi (linear operator): Redundant dictionary (default = None).
2925
3026
epsilon (float): Radius of the :math:`\ell_2` ball (default = 1e-3).
3127

setup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ def read_file(file):
5252
author_email="[email protected]",
5353
license="GNU General Public License v3 (GPLv3)",
5454
install_requires=required,
55-
description="Proximal nested sampling for high-dimensional Bayesian inference",
55+
description="Proximal nested sampling for high-dimensional Bayesian model selection",
5656
long_description_content_type="text/x-rst",
5757
long_description=long_description,
58-
packages=["ProxNest"],
58+
packages=["ProxNest", "ProxNest.operators", "ProxNest.optimisations", "ProxNest.sampling"],
5959
)

0 commit comments

Comments
 (0)