Skip to content

Commit a2c15c3

Browse files
committed
Add utils unit-tests.
1 parent 6b40cf1 commit a2c15c3

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

ProxNest/tests/test_utils.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import ProxNest.utils as utils
2+
import pytest
3+
4+
5+
def test_parameter_dict_creation():
6+
7+
y = 0
8+
epsilon = 1e-3
9+
tight = True
10+
nu = 1
11+
tol = 1e-3
12+
max_iter = 200
13+
verbose = 1
14+
u = 0
15+
pos = False
16+
reality = False
17+
rel_obj = 0
18+
19+
params = utils.create_parameters_dict(
20+
y=y,
21+
epsilon=epsilon,
22+
tight=tight,
23+
nu=nu,
24+
tol=tol,
25+
max_iter=max_iter,
26+
verbose=verbose,
27+
u=u,
28+
pos=pos,
29+
reality=reality,
30+
rel_obj=rel_obj,
31+
)
32+
33+
assert params["y"] == y
34+
assert params["epsilon"] == epsilon
35+
assert params["tight"] == tight
36+
assert params["nu"] == nu
37+
assert params["tol"] == tol
38+
assert params["max_iter"] == max_iter
39+
assert params["verbose"] == verbose
40+
assert params["u"] == u
41+
assert params["reality"] == reality
42+
assert params["pos"] == pos
43+
assert params["rel_obj"] == rel_obj
44+
45+
46+
def test_options_dict_creation():
47+
48+
samplesL = 1e3
49+
samplesD = 1e4
50+
thinning = 1e2
51+
delta = 1e-8
52+
burn = 1e2
53+
sigma = 1
54+
55+
options = utils.create_options_dict(
56+
samplesL=samplesL,
57+
samplesD=samplesD,
58+
thinning=thinning,
59+
delta=delta,
60+
burn=burn,
61+
sigma=sigma,
62+
)
63+
64+
assert options["samplesL"] == samplesL
65+
assert options["samplesD"] == samplesD
66+
assert options["thinning"] == thinning
67+
assert options["delta"] == delta
68+
assert options["burn"] == burn
69+
assert options["sigma"] == sigma

ProxNest/utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ def create_parameters_dict(
6464
params["u"] = u
6565
params["pos"] = pos
6666
params["reality"] = reality
67+
params["l1weights"] = l1weights
68+
params["rel_obj"] = rel_obj
6769

6870
return params
6971

0 commit comments

Comments
 (0)