Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
nam
ProxPython
Commits
c1513931
Commit
c1513931
authored
Mar 30, 2020
by
Matthijs
Browse files
formatting for readability, no actual change
parent
229a4f21
Changes
11
Hide whitespace changes
Inline
Side-by-side
TestSuite/testing_Algorithms/test_CAARL.py
View file @
c1513931
...
...
@@ -4,13 +4,28 @@ from proxtoolbox.Algorithms.CAARL import *
from
proxtoolbox.ProxOperators.P_binary
import
*
from
proxtoolbox.ProxOperators.P_RN
import
*
from
proxtoolbox.ProxOperators.P_M
import
*
class
test_CAARL
(
unittest
.
TestCase
):
def
test_CAARL
(
self
):
config
=
{
'proxoperators'
:[
P_binary
,
P_RN
,
P_M
],
'beta0'
:
2
,
'beta_max'
:
2
,
'beta_switch'
:
1
,
'prox_idx'
:
2
,
'iter'
:
10
,
'prox_idx'
:
2
,
'support_idx'
:
np
.
array
([
1
,
2
]),
'Nx'
:
8
,
'Ny'
:
0
,
'Nz'
:
0
,
'Prox'
:[
P_binary
,
P_RN
],
'norm_data'
:
1
,
'product_space_dimension'
:
5
,
'beta_0'
:
2
,
'M'
:
np
.
array
([
1
,
2
,
2
,
2
,
2
,
12
])}
self
.
pro
=
CAARL
(
config
)
u
=
np
.
array
([
1
,
2
,
5
,
6
,
-
5
,
-
6
])
self
.
assertEqual
(
self
.
pro
.
evaluate
(
u
).
tolist
(),
np
.
array
([
-
1.8703690419340218
+
8.437742860180073j
,
2.5477381663013103
+
8.807889679799857j
,
-
7.613529601089619
+
0.3701468196197832j
,
-
12.384068573713796
-
8.437742860180071j
,
9.483898643023636
-
8.807889679799857j
,
9.836330407412484
-
0.3701468196197823j
]).
tolist
())
config
=
{
'proxoperators'
:
[
P_binary
,
P_RN
,
P_M
],
'beta0'
:
2
,
'beta_max'
:
2
,
'beta_switch'
:
1
,
'prox_idx'
:
2
,
'iter'
:
10
,
'prox_idx'
:
2
,
'support_idx'
:
np
.
array
([
1
,
2
]),
'Nx'
:
8
,
'Ny'
:
0
,
'Nz'
:
0
,
'Prox'
:
[
P_binary
,
P_RN
],
'norm_data'
:
1
,
'product_space_dimension'
:
5
,
'beta_0'
:
2
,
'M'
:
np
.
array
([
1
,
2
,
2
,
2
,
2
,
12
])}
self
.
pro
=
CAARL
(
config
)
u
=
np
.
array
([
1
,
2
,
5
,
6
,
-
5
,
-
6
])
self
.
assertEqual
(
self
.
pro
.
evaluate
(
u
).
tolist
(),
np
.
array
(
[
-
1.8703690419340218
+
8.437742860180073j
,
2.5477381663013103
+
8.807889679799857j
,
-
7.613529601089619
+
0.3701468196197832j
,
-
12.384068573713796
-
8.437742860180071j
,
9.483898643023636
-
8.807889679799857j
,
9.836330407412484
-
0.3701468196197823j
]).
tolist
())
if
__name__
==
'__main__'
:
unittest
.
main
()
#inut:u=[1,2,5,6,-5,-6]
#output:[ -1.8703690419340218+8.437742860180073j , 2.5477381663013103+8.807889679799857j,-7.613529601089619+0.3701468196197832j, -12.384068573713796-8.437742860180071j, 9.483898643023636-8.807889679799857j, 9.836330407412484-0.3701468196197823j]
# inut:u=[1,2,5,6,-5,-6]
# output:[ -1.8703690419340218+8.437742860180073j ,
# 2.5477381663013103 + 8.807889679799857j,
# -7.613529601089619 + 0.3701468196197832j,
# -12.384068573713796 - 8.437742860180071j,
# 9.483898643023636 - 8.807889679799857j,
# 9.836330407412484 - 0.3701468196197823j]
TestSuite/testing_Algorithms/test_CADRl.py
View file @
c1513931
...
...
@@ -4,11 +4,21 @@ from proxtoolbox.Algorithms.CADRl import *
from
proxtoolbox.ProxOperators.P_binary
import
*
from
proxtoolbox.ProxOperators.P_RN
import
*
from
proxtoolbox.ProxOperators.P_M
import
*
class
test_CADRl
(
unittest
.
TestCase
):
def
test_CADRl
(
self
):
config
=
{
'proxoperators'
:[
P_RN
,
P_M
,
P_binary
],
'beta0'
:
2
,
'beta_max'
:
2
,
'beta_switch'
:
1
,
'prox_idx'
:
2
,
'iter'
:
10
,
'prox_idx'
:
2
,
'support_idx'
:
np
.
array
([
1
,
2
]),
'Nx'
:
8
,
'Ny'
:
0
,
'Nz'
:
0
,
'Prox'
:[
P_binary
,
P_RN
],
'norm_data'
:
1
,
'product_space_dimension'
:
5
,
'beta_0'
:
2
,
'M'
:
np
.
array
([
1
,
2
,
2
,
2
,
2
,
12
])}
self
.
pro
=
CADRl
(
config
)
u
=
np
.
array
([
1
,
2
,
5
,
6
,
-
5
,
-
6
])
self
.
assertEqual
(
self
.
pro
.
evaluate
(
u
).
tolist
(),
np
.
array
([
(
-
1.9356980627875102
+
3.0408182027976864j
)
,
0.8580885402990752
+
2.7029495135979418j
,
-
1.1271369416921422
-
0.3378686891997414j
,
-
1.779020587713914
-
3.0408182027976864j
,
1.062835004479652
-
2.7029495135979418j
,
1.9209320474148388
+
0.3378686891997414j
]).
tolist
())
config
=
{
'proxoperators'
:
[
P_RN
,
P_M
,
P_binary
],
'beta0'
:
2
,
'beta_max'
:
2
,
'beta_switch'
:
1
,
'prox_idx'
:
2
,
'iter'
:
10
,
'prox_idx'
:
2
,
'support_idx'
:
np
.
array
([
1
,
2
]),
'Nx'
:
8
,
'Ny'
:
0
,
'Nz'
:
0
,
'Prox'
:
[
P_binary
,
P_RN
],
'norm_data'
:
1
,
'product_space_dimension'
:
5
,
'beta_0'
:
2
,
'M'
:
np
.
array
([
1
,
2
,
2
,
2
,
2
,
12
])}
self
.
pro
=
CADRl
(
config
)
u
=
np
.
array
([
1
,
2
,
5
,
6
,
-
5
,
-
6
])
self
.
assertEqual
(
self
.
pro
.
evaluate
(
u
).
tolist
(),
np
.
array
(
[(
-
1.9356980627875102
+
3.0408182027976864j
),
0.8580885402990752
+
2.7029495135979418j
,
-
1.1271369416921422
-
0.3378686891997414j
,
-
1.779020587713914
-
3.0408182027976864j
,
1.062835004479652
-
2.7029495135979418j
,
1.9209320474148388
+
0.3378686891997414j
]).
tolist
())
if
__name__
==
'__main__'
:
unittest
.
main
()
TestSuite/testing_Algorithms/test_CDRl.py
View file @
c1513931
...
...
@@ -4,12 +4,21 @@ from proxtoolbox.Algorithms.CDRl import *
from
proxtoolbox.ProxOperators.P_binary
import
*
from
proxtoolbox.ProxOperators.P_RN
import
*
from
proxtoolbox.ProxOperators.P_M
import
*
class
test_CDRl
(
unittest
.
TestCase
):
def
test_CDRl
(
self
):
config
=
{
'proxoperators'
:[
P_binary
,
P_RN
,
P_M
],
'beta0'
:
2
,
'beta_max'
:
2
,
'beta_switch'
:
1
,
'prox_idx'
:
2
,
'iter'
:
10
,
'prox_idx'
:
2
,
'support_idx'
:
np
.
array
([
1
,
2
]),
'Nx'
:
8
,
'Ny'
:
0
,
'Nz'
:
0
,
'Prox'
:[
P_binary
,
P_RN
],
'norm_data'
:
1
,
'product_space_dimension'
:
5
,
'beta_0'
:
2
,
'M'
:
np
.
array
([
1
,
2
,
2
,
2
,
2
,
12
]),
'lambda0'
:
2
,
'lambda_max'
:
2
,
'lambda_switch'
:
1
,
'lambda_0'
:
2
}
self
.
pro
=
CDRl
(
config
)
u
=
np
.
array
([
1
,
2
,
5
,
6
,
-
5
,
-
6
])
self
.
assertEqual
(
self
.
pro
.
evaluate
(
u
).
tolist
(),
np
.
array
([
0.9510576492339013
-
2.7982183410847505j
,
1.2326217479829011
-
2.9678073314535216j
,
16.23359565239013
-
0.169588990368774j
,
19.54586980521637
+
2.798218341084751j
,
-
16.18465330162403
+
2.967807331453521j
,
-
19.778491553199267
+
0.169588990368774j
]).
tolist
())
config
=
{
'proxoperators'
:
[
P_binary
,
P_RN
,
P_M
],
'beta0'
:
2
,
'beta_max'
:
2
,
'beta_switch'
:
1
,
'prox_idx'
:
2
,
'iter'
:
10
,
'prox_idx'
:
2
,
'support_idx'
:
np
.
array
([
1
,
2
]),
'Nx'
:
8
,
'Ny'
:
0
,
'Nz'
:
0
,
'Prox'
:
[
P_binary
,
P_RN
],
'norm_data'
:
1
,
'product_space_dimension'
:
5
,
'beta_0'
:
2
,
'M'
:
np
.
array
([
1
,
2
,
2
,
2
,
2
,
12
]),
'lambda0'
:
2
,
'lambda_max'
:
2
,
'lambda_switch'
:
1
,
'lambda_0'
:
2
}
self
.
pro
=
CDRl
(
config
)
u
=
np
.
array
([
1
,
2
,
5
,
6
,
-
5
,
-
6
])
self
.
assertEqual
(
self
.
pro
.
evaluate
(
u
).
tolist
(),
np
.
array
(
[
0.9510576492339013
-
2.7982183410847505j
,
1.2326217479829011
-
2.9678073314535216j
,
16.23359565239013
-
0.169588990368774j
,
19.54586980521637
+
2.798218341084751j
,
-
16.18465330162403
+
2.967807331453521j
,
-
19.778491553199267
+
0.169588990368774j
]).
tolist
())
if
__name__
==
'__main__'
:
unittest
.
main
()
TestSuite/testing_Algorithms/test_CDRlrand.py
View file @
c1513931
...
...
@@ -4,14 +4,20 @@ from proxtoolbox.Algorithms.CDRlrand import *
from
proxtoolbox.ProxOperators.P_binary
import
*
from
proxtoolbox.ProxOperators.P_RN
import
*
from
proxtoolbox.ProxOperators.P_M
import
*
class
test_CDRlrand
(
unittest
.
TestCase
):
def
test_CDRlrand
(
self
):
config
=
{
'proxoperators'
:[
P_binary
,
P_RN
,
P_M
],
'beta0'
:
2
,
'beta_max'
:
2
,
'beta_switch'
:
1
,
'prox_idx'
:
2
,
'iter'
:
10
,
'prox_idx'
:
2
,
'support_idx'
:
np
.
array
([
1
,
2
]),
'Nx'
:
8
,
'Ny'
:
0
,
'Nz'
:
0
,
'Prox'
:[
P_binary
,
P_RN
],
'norm_data'
:
1
,
'product_space_dimension'
:
5
,
'beta_0'
:
2
,
'M'
:
np
.
array
([
1
,
2
,
2
,
2
,
2
,
12
]),
'lambda0'
:
2
,
'lambda_max'
:
2
,
'lambda_switch'
:
1
,
'lambda_0'
:
2
}
self
.
pro
=
CDRlrand
(
config
)
u
=
np
.
array
([
1
,
2
,
5
,
6
,
-
5
,
-
6
])
# self.assertEqual(self.pro.evaluate(u).tolist(),np.array([ 0.9510576492339013-2.7982183410847505j,1.2326217479829011-2.9678073314535216j ,16.23359565239013-0.169588990368774j ,19.54586980521637+2.798218341084751j ,-16.18465330162403+2.967807331453521j , -19.778491553199267+0.169588990368774j]).tolist())
config
=
{
'proxoperators'
:
[
P_binary
,
P_RN
,
P_M
],
'beta0'
:
2
,
'beta_max'
:
2
,
'beta_switch'
:
1
,
'prox_idx'
:
2
,
'iter'
:
10
,
'prox_idx'
:
2
,
'support_idx'
:
np
.
array
([
1
,
2
]),
'Nx'
:
8
,
'Ny'
:
0
,
'Nz'
:
0
,
'Prox'
:
[
P_binary
,
P_RN
],
'norm_data'
:
1
,
'product_space_dimension'
:
5
,
'beta_0'
:
2
,
'M'
:
np
.
array
([
1
,
2
,
2
,
2
,
2
,
12
]),
'lambda0'
:
2
,
'lambda_max'
:
2
,
'lambda_switch'
:
1
,
'lambda_0'
:
2
}
self
.
pro
=
CDRlrand
(
config
)
u
=
np
.
array
([
1
,
2
,
5
,
6
,
-
5
,
-
6
])
# self.assertEqual(self.pro.evaluate(u).tolist(),np.array([ 0.9510576492339013-2.7982183410847505j,1.2326217479829011-2.9678073314535216j ,16.23359565239013-0.169588990368774j ,19.54586980521637+2.798218341084751j ,-16.18465330162403+2.967807331453521j , -19.778491553199267+0.169588990368774j]).tolist())
#randomized algorithm, no deterministic result for given input
#
randomized algorithm, no deterministic result for given input
if
__name__
==
'__main__'
:
unittest
.
main
()
TestSuite/testing_Algorithms/test_CP.py
View file @
c1513931
...
...
@@ -4,11 +4,21 @@ from proxtoolbox.Algorithms.CP import *
from
proxtoolbox.ProxOperators.P_binary
import
*
from
proxtoolbox.ProxOperators.P_RN
import
*
from
proxtoolbox.ProxOperators.P_M
import
*
class
test_CP
(
unittest
.
TestCase
):
def
test_CP
(
self
):
config
=
{
'proxoperators'
:[
P_RN
,
P_M
,
P_binary
],
'beta0'
:
2
,
'beta_max'
:
2
,
'beta_switch'
:
1
,
'prox_idx'
:
2
,
'iter'
:
10
,
'prox_idx'
:
2
,
'support_idx'
:
np
.
array
([
1
,
2
]),
'Nx'
:
8
,
'Ny'
:
0
,
'Nz'
:
0
,
'Prox'
:[
P_binary
,
P_RN
],
'norm_data'
:
1
,
'product_space_dimension'
:
5
,
'beta_0'
:
2
,
'M'
:
np
.
array
([
1
,
2
,
2
,
2
,
2
,
12
])}
self
.
pro
=
CP
(
config
)
u
=
np
.
array
([
1
,
2
,
5
,
6
,
-
5
,
-
6
])
self
.
assertEqual
(
self
.
pro
.
evaluate
(
u
).
tolist
(),
np
.
array
([
2.5632402409811483
+
0.8545904827420623j
,
2.4782116433462313
-
0.8545904827420624j
,
-
0.45748570118254206
-
1.6454095172579373j
,
-
1.5632402409811479
-
0.8545904827420623j
,
-
1.4782116433462318
+
0.8545904827420624j
,
-
0.5425142988174578
+
1.6454095172579373j
]).
tolist
())
config
=
{
'proxoperators'
:
[
P_RN
,
P_M
,
P_binary
],
'beta0'
:
2
,
'beta_max'
:
2
,
'beta_switch'
:
1
,
'prox_idx'
:
2
,
'iter'
:
10
,
'prox_idx'
:
2
,
'support_idx'
:
np
.
array
([
1
,
2
]),
'Nx'
:
8
,
'Ny'
:
0
,
'Nz'
:
0
,
'Prox'
:
[
P_binary
,
P_RN
],
'norm_data'
:
1
,
'product_space_dimension'
:
5
,
'beta_0'
:
2
,
'M'
:
np
.
array
([
1
,
2
,
2
,
2
,
2
,
12
])}
self
.
pro
=
CP
(
config
)
u
=
np
.
array
([
1
,
2
,
5
,
6
,
-
5
,
-
6
])
self
.
assertEqual
(
self
.
pro
.
evaluate
(
u
).
tolist
(),
np
.
array
(
[
2.5632402409811483
+
0.8545904827420623j
,
2.4782116433462313
-
0.8545904827420624j
,
-
0.45748570118254206
-
1.6454095172579373j
,
-
1.5632402409811479
-
0.8545904827420623j
,
-
1.4782116433462318
+
0.8545904827420624j
,
-
0.5425142988174578
+
1.6454095172579373j
]).
tolist
())
if
__name__
==
'__main__'
:
unittest
.
main
()
TestSuite/testing_Algorithms/test_CPrand.py
View file @
c1513931
...
...
@@ -4,11 +4,21 @@ from proxtoolbox.Algorithms.CPrand import *
from
proxtoolbox.ProxOperators.P_binary
import
*
from
proxtoolbox.ProxOperators.P_RN
import
*
from
proxtoolbox.ProxOperators.P_M
import
*
class
test_CPrand
(
unittest
.
TestCase
):
def
test_CPrand
(
self
):
config
=
{
'proxoperators'
:[
P_RN
,
P_M
,
P_binary
],
'beta0'
:
2
,
'beta_max'
:
2
,
'beta_switch'
:
1
,
'prox_idx'
:
2
,
'iter'
:
10
,
'prox_idx'
:
2
,
'support_idx'
:
np
.
array
([
1
,
2
]),
'Nx'
:
8
,
'Ny'
:
0
,
'Nz'
:
0
,
'Prox'
:[
P_binary
,
P_RN
],
'norm_data'
:
1
,
'product_space_dimension'
:
5
,
'beta_0'
:
2
,
'M'
:
np
.
array
([
1
,
2
,
2
,
2
,
2
,
12
])}
self
.
pro
=
CPrand
(
config
)
u
=
np
.
array
([
1
,
2
,
5
,
6
,
-
5
,
-
6
])
self
.
assertEqual
(
self
.
pro
.
evaluate
(
u
).
tolist
(),
np
.
array
([
2.5632402409811483
+
0.8545904827420623j
,
2.4782116433462313
-
0.8545904827420624j
,
-
0.45748570118254206
-
1.6454095172579373j
,
-
1.5632402409811479
-
0.8545904827420623j
,
-
1.4782116433462318
+
0.8545904827420624j
,
-
0.5425142988174578
+
1.6454095172579373j
]).
tolist
())
config
=
{
'proxoperators'
:
[
P_RN
,
P_M
,
P_binary
],
'beta0'
:
2
,
'beta_max'
:
2
,
'beta_switch'
:
1
,
'prox_idx'
:
2
,
'iter'
:
10
,
'prox_idx'
:
2
,
'support_idx'
:
np
.
array
([
1
,
2
]),
'Nx'
:
8
,
'Ny'
:
0
,
'Nz'
:
0
,
'Prox'
:
[
P_binary
,
P_RN
],
'norm_data'
:
1
,
'product_space_dimension'
:
5
,
'beta_0'
:
2
,
'M'
:
np
.
array
([
1
,
2
,
2
,
2
,
2
,
12
])}
self
.
pro
=
CPrand
(
config
)
u
=
np
.
array
([
1
,
2
,
5
,
6
,
-
5
,
-
6
])
self
.
assertEqual
(
self
.
pro
.
evaluate
(
u
).
tolist
(),
np
.
array
(
[
2.5632402409811483
+
0.8545904827420623j
,
2.4782116433462313
-
0.8545904827420624j
,
-
0.45748570118254206
-
1.6454095172579373j
,
-
1.5632402409811479
-
0.8545904827420623j
,
-
1.4782116433462318
+
0.8545904827420624j
,
-
0.5425142988174578
+
1.6454095172579373j
]).
tolist
())
if
__name__
==
'__main__'
:
unittest
.
main
()
TestSuite/testing_Algorithms/test_DRAP.py
View file @
c1513931
...
...
@@ -3,16 +3,22 @@ import numpy as np
from
proxtoolbox.Algorithms.DRAP
import
*
from
proxtoolbox.ProxOperators.P_M
import
*
from
proxtoolbox.ProxOperators.P_RN
import
*
class
test_DRAP
(
unittest
.
TestCase
):
def
test_DRAP
(
self
):
config
=
{
'proxoperators'
:[
P_M
,
P_RN
],
'beta_0'
:
2
,
'beta_max'
:
2
,
'beta_switch'
:
1
,
'prox_idx'
:
2
,
'iter'
:
10
,
'prox_idx'
:
2
,
'support_idx'
:
np
.
array
([
1
,
2
]),
'norm_data'
:
2
,
'Nx'
:
6
,
'Ny'
:
0
,
'Nz'
:
0
,
'product_space_dimension'
:
1
,
'M'
:
np
.
array
([
1
,
2
,
2
,
2
,
2
,
12
])}
u
=
np
.
array
([
1
,
2
,
5
,
6
,
-
5
,
-
6
])
self
.
pro
=
DRAP
(
config
)
self
.
assertEqual
(
self
.
pro
.
evaluate
(
u
).
tolist
(),
np
.
array
([(
-
0.46784903139375517
+
1.5204091013988432j
),
(
1.4290442701495376
+
1.3514747567989709j
),
(
1.936431529153929
-
0.1689343445998707j
),
(
2.110489706143043
-
1.5204091013988432j
),(
-
1.968582497760174
-
1.3514747567989709j
),
-
2.0395339762925806
+
0.1689343445998707j
]).
tolist
())
config
=
{
'proxoperators'
:
[
P_M
,
P_RN
],
'beta_0'
:
2
,
'beta_max'
:
2
,
'beta_switch'
:
1
,
'prox_idx'
:
2
,
'iter'
:
10
,
'prox_idx'
:
2
,
'support_idx'
:
np
.
array
([
1
,
2
]),
'norm_data'
:
2
,
'Nx'
:
6
,
'Ny'
:
0
,
'Nz'
:
0
,
'product_space_dimension'
:
1
,
'M'
:
np
.
array
([
1
,
2
,
2
,
2
,
2
,
12
])}
u
=
np
.
array
([
1
,
2
,
5
,
6
,
-
5
,
-
6
])
self
.
pro
=
DRAP
(
config
)
self
.
assertEqual
(
self
.
pro
.
evaluate
(
u
).
tolist
(),
np
.
array
(
[(
-
0.46784903139375517
+
1.5204091013988432j
),
(
1.4290442701495376
+
1.3514747567989709j
),
(
1.936431529153929
-
0.1689343445998707j
),
(
2.110489706143043
-
1.5204091013988432j
),
(
-
1.968582497760174
-
1.3514747567989709j
),
-
2.0395339762925806
+
0.1689343445998707j
]).
tolist
())
if
__name__
==
'__main__'
:
unittest
.
main
()
TestSuite/testing_Algorithms/test_GRAAL_F.py
View file @
c1513931
...
...
@@ -4,14 +4,23 @@ from proxtoolbox.Algorithms.GRAAL_F import *
from
proxtoolbox.ProxOperators.P_binary
import
*
from
proxtoolbox.ProxOperators.P_RN
import
*
from
proxtoolbox.ProxOperators.P_M
import
*
class
test_GRAAL_F
(
unittest
.
TestCase
):
def
test_GRAAL_F
(
self
):
config
=
{
'proxoperators'
:
[
P_M
,
P_RN
,
P_binary
],
'beta0'
:
2
,
'beta_max'
:
2
,
'beta_switch'
:
1
,
'prox_idx'
:
2
,
'iter'
:
10
,
'prox_idx'
:
2
,
'support_idx'
:
np
.
array
([
1
,
2
]),
'Nx'
:
8
,
'Ny'
:
0
,
'Nz'
:
0
,
'Prox'
:[
P_M
,
P_RN
],
'norm_data'
:
1
,
'product_space_dimension'
:
5
,
'beta_0'
:
2
,
'Fx'
:
np
.
array
([
1
,
2
,
3
]),
'phi'
:
2
,
'T'
:
P_M
,
'M'
:
np
.
array
([
1
,
2
,
2
,
2
,
2
,
12
])}
self
.
pro
=
GRAAL_F
(
config
)
x
=
np
.
array
([
1
,
2
,
5
,
6
,
-
5
,
-
6
])
self
.
assertEqual
(
self
.
pro
.
evaluate
(
x
).
tolist
(),
np
.
array
([
1.467849031393755
-
1.5204091013988432j
,
0.5709557298504624
-
1.3514747567989709j
,
3.063568470846071
+
0.1689343445998707j
,
3.889510293856957
+
1.5204091013988432j
,
-
3.031417502239826
+
1.3514747567989709j
,
-
3.9604660237074194
-
0.1689343445998707j
]).
tolist
())
config
=
{
'proxoperators'
:
[
P_M
,
P_RN
,
P_binary
],
'beta0'
:
2
,
'beta_max'
:
2
,
'beta_switch'
:
1
,
'prox_idx'
:
2
,
'iter'
:
10
,
'prox_idx'
:
2
,
'support_idx'
:
np
.
array
([
1
,
2
]),
'Nx'
:
8
,
'Ny'
:
0
,
'Nz'
:
0
,
'Prox'
:
[
P_M
,
P_RN
],
'norm_data'
:
1
,
'product_space_dimension'
:
5
,
'beta_0'
:
2
,
'Fx'
:
np
.
array
([
1
,
2
,
3
]),
'phi'
:
2
,
'T'
:
P_M
,
'M'
:
np
.
array
([
1
,
2
,
2
,
2
,
2
,
12
])}
self
.
pro
=
GRAAL_F
(
config
)
x
=
np
.
array
([
1
,
2
,
5
,
6
,
-
5
,
-
6
])
self
.
assertEqual
(
self
.
pro
.
evaluate
(
x
).
tolist
(),
np
.
array
(
[
1.467849031393755
-
1.5204091013988432j
,
0.5709557298504624
-
1.3514747567989709j
,
3.063568470846071
+
0.1689343445998707j
,
3.889510293856957
+
1.5204091013988432j
,
-
3.031417502239826
+
1.3514747567989709j
,
-
3.9604660237074194
-
0.1689343445998707j
]).
tolist
())
if
__name__
==
'__main__'
:
unittest
.
main
()
#input:x = [1,2,5,6,-5,-6], M:[1,2,2,2,2,12],T: P_M
#output:[ 1.46785-1.52041j 0.57096-1.35147j 3.06357+0.16893j 3.88951+1.520401j -3.03142 +1.35147j -3.96047-0.16893j]
# input:x = [1,2,5,6,-5,-6], M:[1,2,2,2,2,12],T: P_M
# output:[ 1.46785-1.52041j 0.57096-1.35147j 3.06357+0.16893j 3.88951+1.520401j -3.03142 +1.35147j -3.96047-0.16893j]
TestSuite/testing_Algorithms/test_GRAAL_objective.py
View file @
c1513931
import
numpy
as
np
import
unittest
from
proxtoolbox.Algorithms.GRAAL_objective
import
*
from
proxtoolbox.ProxOperators.P_binary
import
*
from
proxtoolbox.ProxOperators.P_RN
import
*
from
proxtoolbox.ProxOperators.P_M
import
*
class
test_GRAAL_objective
(
unittest
.
TestCase
):
def
test_GRAAL_objective
(
self
):
config
=
{
'proxoperators'
:
[
P_M
,
P_RN
,
P_binary
],
'beta0'
:
2
,
'beta_max'
:
2
,
'beta_switch'
:
1
,
'prox_idx'
:
2
,
'iter'
:
10
,
'prox_idx'
:
2
,
'support_idx'
:
np
.
array
([
1
,
2
]),
'Nx'
:
8
,
'Ny'
:
0
,
'Nz'
:
0
,
'Prox'
:[
P_M
,
P_RN
],
'norm_data'
:
1
,
'product_space_dimension'
:
5
,
'beta_0'
:
2
,
'Fx'
:
np
.
array
([
1
,
2
,
3
]),
'phi'
:
2
,
'T'
:
P_M
,
'M'
:
np
.
array
([
1
,
2
,
2
,
2
,
2
,
12
]),
'Fx1'
:
np
.
array
([
1.467849031393755
-
1.5204091013988432j
,
0.5709557298504624
-
1.3514747567989709j
,
3.063568470846071
+
0.1689343445998707j
,
3.889510293856957
+
1.5204091013988432j
,
-
3.031417502239826
+
1.3514747567989709j
,
-
3.9604660237074194
-
0.1689343445998707j
])}
self
.
pro
=
GRAAL_objective
(
config
)
x
=
np
.
array
([
1
,
2
,
5
,
6
,
-
5
,
-
6
])
self
.
assertEqual
(
self
.
pro
.
evaluate
(
x
),
7.759022480773861
)
config
=
{
'proxoperators'
:
[
P_M
,
P_RN
,
P_binary
],
'beta0'
:
2
,
'beta_max'
:
2
,
'beta_switch'
:
1
,
'prox_idx'
:
2
,
'iter'
:
10
,
'prox_idx'
:
2
,
'support_idx'
:
np
.
array
([
1
,
2
]),
'Nx'
:
8
,
'Ny'
:
0
,
'Nz'
:
0
,
'Prox'
:
[
P_M
,
P_RN
],
'norm_data'
:
1
,
'product_space_dimension'
:
5
,
'beta_0'
:
2
,
'Fx'
:
np
.
array
([
1
,
2
,
3
]),
'phi'
:
2
,
'T'
:
P_M
,
'M'
:
np
.
array
([
1
,
2
,
2
,
2
,
2
,
12
]),
'Fx1'
:
np
.
array
(
[
1.467849031393755
-
1.5204091013988432j
,
0.5709557298504624
-
1.3514747567989709j
,
3.063568470846071
+
0.1689343445998707j
,
3.889510293856957
+
1.5204091013988432j
,
-
3.031417502239826
+
1.3514747567989709j
,
-
3.9604660237074194
-
0.1689343445998707j
])}
self
.
pro
=
GRAAL_objective
(
config
)
x
=
np
.
array
([
1
,
2
,
5
,
6
,
-
5
,
-
6
])
self
.
assertEqual
(
self
.
pro
.
evaluate
(
x
),
7.759022480773861
)
if
__name__
==
'__main__'
:
unittest
.
main
()
#input:Fx1:[ 1.46785-1.52041j 0.57096-1.35147j 3.06357+0.16893j 3.88951+1.520401j -3.03142 +1.35147j -3.96047-0.16893j]
#output:7.7590
#
input:Fx1:[ 1.46785-1.52041j 0.57096-1.35147j 3.06357+0.16893j 3.88951+1.520401j -3.03142 +1.35147j -3.96047-0.16893j]
#
output:7.7590
TestSuite/testing_Algorithms/test_KM.py
View file @
c1513931
...
...
@@ -4,14 +4,20 @@ from proxtoolbox.Algorithms.KM import *
from
proxtoolbox.ProxOperators.P_binary
import
*
from
proxtoolbox.ProxOperators.P_RN
import
*
from
proxtoolbox.ProxOperators.P_M
import
*
# input: config={'proxoperators':[P_binary,P_RN,P_avg],'beta0':2 ,'beta_max':2,'beta_switch':1,'prox_idx':2,'iter':10,'prox_idx':2,'support_idx':np.array([1,2]),'Nx':8,'Ny':0,'Nz':0,'Prox':[P_binary,P_RN], 'norm_data':1, 'product_space_dimension':5,'beta_0':2,'Fx':np.array([1,2,3]),'phi':2}
#u=[1,2,5,6,-5,-6],
#
u=[1,2,5,6,-5,-6],
class
test_KM
(
unittest
.
TestCase
):
def
test_KM
(
self
):
config
=
{
'proxoperators'
:[
P_binary
,
P_RN
,
P_M
],
'beta0'
:
2
,
'beta_max'
:
2
,
'beta_switch'
:
1
,
'prox_idx'
:
2
,
'iter'
:
10
,
'prox_idx'
:
2
,
'support_idx'
:
np
.
array
([
1
,
2
]),
'Nx'
:
8
,
'Ny'
:
0
,
'Nz'
:
0
,
'Prox'
:[
P_binary
,
P_RN
],
'norm_data'
:
1
,
'product_space_dimension'
:
5
,
'beta_0'
:
2
,
'Fx'
:
np
.
array
([
1
,
2
,
3
]),
'phi'
:
2
,
'T'
:
P_M
,
'M'
:
np
.
array
([
1
,
2
,
2
,
2
,
2
,
12
])}
self
.
pro
=
KM
(
config
)
u
=
np
.
array
([
1
,
2
,
5
,
6
,
-
5
,
-
6
])
self
.
assertEqual
(
self
.
pro
.
evaluate
(
u
).
tolist
(),
np
.
array
([
1000
,
1001
,
1004
,
1005
,
994
,
993
]).
tolist
())
config
=
{
'proxoperators'
:
[
P_binary
,
P_RN
,
P_M
],
'beta0'
:
2
,
'beta_max'
:
2
,
'beta_switch'
:
1
,
'prox_idx'
:
2
,
'iter'
:
10
,
'prox_idx'
:
2
,
'support_idx'
:
np
.
array
([
1
,
2
]),
'Nx'
:
8
,
'Ny'
:
0
,
'Nz'
:
0
,
'Prox'
:
[
P_binary
,
P_RN
],
'norm_data'
:
1
,
'product_space_dimension'
:
5
,
'beta_0'
:
2
,
'Fx'
:
np
.
array
([
1
,
2
,
3
]),
'phi'
:
2
,
'T'
:
P_M
,
'M'
:
np
.
array
([
1
,
2
,
2
,
2
,
2
,
12
])}
self
.
pro
=
KM
(
config
)
u
=
np
.
array
([
1
,
2
,
5
,
6
,
-
5
,
-
6
])
self
.
assertEqual
(
self
.
pro
.
evaluate
(
u
).
tolist
(),
np
.
array
([
1000
,
1001
,
1004
,
1005
,
994
,
993
]).
tolist
())
if
__name__
==
'__main__'
:
unittest
.
main
()
TestSuite/testing_Algorithms/test_RRR.py
View file @
c1513931
...
...
@@ -4,13 +4,22 @@ from proxtoolbox.Algorithms.RRR import *
from
proxtoolbox.ProxOperators.P_binary
import
*
from
proxtoolbox.ProxOperators.P_RN
import
*
from
proxtoolbox.ProxOperators.P_M
import
*
class
test_RRR
(
unittest
.
TestCase
):
def
test_RRR
(
self
):
config
=
{
'proxoperators'
:[
P_RN
,
P_M
],
'beta0'
:
2
,
'beta_max'
:
2
,
'beta_switch'
:
1
,
'prox_idx'
:
2
,
'iter'
:
10
,
'prox_idx'
:
2
,
'support_idx'
:
np
.
array
([
1
,
2
]),
'Nx'
:
8
,
'Ny'
:
0
,
'Nz'
:
0
,
'Prox'
:[
P_binary
,
P_RN
],
'norm_data'
:
1
,
'product_space_dimension'
:
5
,
'beta_0'
:
2
,
'M'
:
np
.
array
([
1
,
2
,
2
,
2
,
2
,
12
])}
self
.
pro
=
RRR
(
config
)
u
=
np
.
array
([
1
,
2
,
5
,
6
,
-
5
,
-
6
])
self
.
assertEqual
(
self
.
pro
.
evaluate
(
u
).
tolist
(),
np
.
array
([
-
2.93569806278751
+
3.0408182027976864j
,
-
1.1419114597009248
+
2.7029495135979418j
,
-
6.127136941692142
-
0.3378686891997414j
,
-
7.779020587713914
-
3.0408182027976864j
,
6.062835004479652
-
2.7029495135979418j
,
7.920932047414839
+
0.3378686891997414j
]).
tolist
())
config
=
{
'proxoperators'
:
[
P_RN
,
P_M
],
'beta0'
:
2
,
'beta_max'
:
2
,
'beta_switch'
:
1
,
'prox_idx'
:
2
,
'iter'
:
10
,
'prox_idx'
:
2
,
'support_idx'
:
np
.
array
([
1
,
2
]),
'Nx'
:
8
,
'Ny'
:
0
,
'Nz'
:
0
,
'Prox'
:
[
P_binary
,
P_RN
],
'norm_data'
:
1
,
'product_space_dimension'
:
5
,
'beta_0'
:
2
,
'M'
:
np
.
array
([
1
,
2
,
2
,
2
,
2
,
12
])}
self
.
pro
=
RRR
(
config
)
u
=
np
.
array
([
1
,
2
,
5
,
6
,
-
5
,
-
6
])
self
.
assertEqual
(
self
.
pro
.
evaluate
(
u
).
tolist
(),
np
.
array
(
[
-
2.93569806278751
+
3.0408182027976864j
,
-
1.1419114597009248
+
2.7029495135979418j
,
-
6.127136941692142
-
0.3378686891997414j
,
-
7.779020587713914
-
3.0408182027976864j
,
6.062835004479652
-
2.7029495135979418j
,
7.920932047414839
+
0.3378686891997414j
]).
tolist
())
if
__name__
==
'__main__'
:
unittest
.
main
()
#input:u=[1,2,5,6,-5,-6]
#output:[-2.9357+3.0408j,-1.1419+2.7029j,-6.1271-0.3379j, -7.7790-3.0408j,6.0628-2.7029j,7.9209+0.3379j]
#
input:u=[1,2,5,6,-5,-6]
#
output:[-2.9357+3.0408j,-1.1419+2.7029j,-6.1271-0.3379j, -7.7790-3.0408j,6.0628-2.7029j,7.9209+0.3379j]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment