Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
faust
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
faust group
faust
Commits
f21bc746
Commit
f21bc746
authored
1 year ago
by
hhakim
Browse files
Options
Downloads
Patches
Plain Diff
Factor test_basis and test_basis_py into verif_basis.
parent
ee4c05a1
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
wrapper/python/pyfaust/tests/TestPoly.py
+10
-39
10 additions, 39 deletions
wrapper/python/pyfaust/tests/TestPoly.py
with
10 additions
and
39 deletions
wrapper/python/pyfaust/tests/TestPoly.py
+
10
−
39
View file @
f21bc746
...
@@ -24,13 +24,7 @@ class TestPoly(unittest.TestCase):
...
@@ -24,13 +24,7 @@ class TestPoly(unittest.TestCase):
self
.
L
@=
self
.
L
.
H
self
.
L
@=
self
.
L
.
H
self
.
K
=
5
self
.
K
=
5
def
test_basis_py
(
self
):
def
verif_basis
(
self
,
d
,
F
,
K
,
L
):
print
(
"
Test basis(impl=
'
py
'
)
"
)
d
=
self
.
d
L
=
self
.
L
K
=
self
.
K
density
=
self
.
density
F
=
basis
(
L
,
K
,
'
chebyshev
'
,
dev
=
self
.
dev
,
impl
=
'
py
'
)
# assert the dimensions are consistent to L
# assert the dimensions are consistent to L
self
.
assertEqual
(
F
.
shape
[
0
],
(
K
+
1
)
*
L
.
shape
[
0
])
self
.
assertEqual
(
F
.
shape
[
0
],
(
K
+
1
)
*
L
.
shape
[
0
])
self
.
assertEqual
(
F
.
shape
[
1
],
L
.
shape
[
0
])
self
.
assertEqual
(
F
.
shape
[
1
],
L
.
shape
[
0
])
...
@@ -63,6 +57,14 @@ class TestPoly(unittest.TestCase):
...
@@ -63,6 +57,14 @@ class TestPoly(unittest.TestCase):
zero_part
=
degn_fac
[
n
*
d
:,
:
-
2
*
d
]
zero_part
=
degn_fac
[
n
*
d
:,
:
-
2
*
d
]
self
.
assertTrue
(
np
.
linalg
.
norm
(
zero_part
)
==
0
)
self
.
assertTrue
(
np
.
linalg
.
norm
(
zero_part
)
==
0
)
def
test_basis_py
(
self
):
print
(
"
Test basis(impl=
'
py
'
)
"
)
d
=
self
.
d
L
=
self
.
L
K
=
self
.
K
density
=
self
.
density
F
=
basis
(
L
,
K
,
'
chebyshev
'
,
dev
=
self
.
dev
,
impl
=
'
py
'
)
self
.
verif_basis
(
d
,
F
,
K
,
L
)
def
test_basis
(
self
):
def
test_basis
(
self
):
print
(
"
Test basis(impl=
'
native
'
)
"
)
print
(
"
Test basis(impl=
'
native
'
)
"
)
...
@@ -71,38 +73,7 @@ class TestPoly(unittest.TestCase):
...
@@ -71,38 +73,7 @@ class TestPoly(unittest.TestCase):
K
=
self
.
K
K
=
self
.
K
density
=
self
.
density
density
=
self
.
density
F
=
basis
(
L
,
K
,
'
chebyshev
'
,
dev
=
self
.
dev
,
impl
=
'
native
'
)
F
=
basis
(
L
,
K
,
'
chebyshev
'
,
dev
=
self
.
dev
,
impl
=
'
native
'
)
# assert the dimensions are consistent to L
self
.
verif_basis
(
d
,
F
,
K
,
L
)
self
.
assertEqual
(
F
.
shape
[
0
],
(
K
+
1
)
*
L
.
shape
[
0
])
self
.
assertEqual
(
F
.
shape
[
1
],
L
.
shape
[
0
])
# assert the 0-degree polynomial matrix is the identity
last_fac
=
F
.
factors
(
F
.
numfactors
()
-
1
).
toarray
()
Id
=
np
.
eye
(
d
)
self
.
assertTrue
(
np
.
allclose
(
Id
,
last_fac
))
if
K
>=
1
:
# assert the 1-degree polynomial matrix is in the form [Id ; L]
deg1_fac
=
F
.
factors
(
F
.
numfactors
()
-
2
).
toarray
()
self
.
assertTrue
(
np
.
allclose
(
deg1_fac
[:
d
,
:],
Id
))
self
.
assertTrue
(
np
.
allclose
(
deg1_fac
[
d
:
2
*
d
,
:],
L
.
toarray
()))
if
K
>=
2
:
# assert the 2-degree polynomial matrix is in the form [Id ; [-Id, L]]
I2d
=
np
.
eye
(
2
*
d
)
deg2_fac
=
F
.
factors
(
F
.
numfactors
()
-
3
).
toarray
()
self
.
assertTrue
(
np
.
allclose
(
deg2_fac
[:
2
*
d
,
:],
I2d
))
self
.
assertTrue
(
np
.
allclose
(
deg2_fac
[
2
*
d
:,
:
d
],
-
Id
))
self
.
assertTrue
(
np
.
allclose
(
deg2_fac
[
2
*
d
:,
d
:],
2
*
L
.
toarray
()))
if
K
>=
3
:
# assert the n-degree polynomial matrix is in the form
# [I_nd ; [0 , -Id, 2L]]
for
n
in
range
(
3
,
K
):
Ind
=
np
.
eye
(
n
*
d
)
degn_fac
=
F
.
factors
(
F
.
numfactors
()
-
n
-
1
).
toarray
()
self
.
assertTrue
(
np
.
allclose
(
degn_fac
[:
n
*
d
,
:],
Ind
))
self
.
assertTrue
(
np
.
allclose
(
degn_fac
[
n
*
d
:,
-
2
*
d
:
-
d
],
-
Id
))
self
.
assertTrue
(
np
.
allclose
(
degn_fac
[
n
*
d
:,
-
d
:],
2
*
L
.
toarray
()))
zero_part
=
degn_fac
[
n
*
d
:,
:
-
2
*
d
]
self
.
assertTrue
(
np
.
linalg
.
norm
(
zero_part
)
==
0
)
def
test_basisT0
(
self
):
def
test_basisT0
(
self
):
print
(
"
Test basis(T0)
"
)
print
(
"
Test basis(T0)
"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment