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
60b9005f
Commit
60b9005f
authored
6 years ago
by
hhakim
Browse files
Options
Downloads
Patches
Plain Diff
Add pyfaust unit tests for
322c8533
(slicing with arbitrary steps).
parent
5c6ecf88
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
misc/test/src/Python/test_FaustPy.py
+59
-3
59 additions, 3 deletions
misc/test/src/Python/test_FaustPy.py
with
59 additions
and
3 deletions
misc/test/src/Python/test_FaustPy.py
+
59
−
3
View file @
60b9005f
...
...
@@ -250,7 +250,6 @@ class TestFaustPy(unittest.TestCase):
F_rows
=
F
[
row_ids
,:]
self
.
assertTrue
((
F_rows
.
toarray
()
==
F
.
toarray
()[
row_ids
,:]).
all
())
print
(
"
test fancy indexing on cols
"
)
F
=
self
.
F
num_inds
=
self
.
r
.
randint
(
1
,
F
.
shape
[
1
])
col_ids
=
[
self
.
r
.
randint
(
0
,
F
.
shape
[
1
]
-
1
)
for
i
in
range
(
0
,
num_inds
)]
...
...
@@ -262,7 +261,6 @@ class TestFaustPy(unittest.TestCase):
else
:
self
.
assertLessEqual
(
n1
/
n2
,
0.005
)
print
(
"
test fancy indexing on rows with slice on cols
"
)
F
=
self
.
F
num_inds
=
self
.
r
.
randint
(
1
,
F
.
shape
[
0
]
-
1
)
col_slice_start
=
self
.
r
.
randint
(
0
,
F
.
shape
[
1
]
-
1
)
col_slice_stop
=
self
.
r
.
randint
(
col_slice_start
+
1
,
F
.
shape
[
1
])
...
...
@@ -272,7 +270,6 @@ class TestFaustPy(unittest.TestCase):
self
.
assertLessEqual
(
norm
(
F_rows
.
toarray
()
-
F
.
toarray
()[
row_ids
,
col_slice_start
:
col_slice_stop
])
/
norm
(
F
.
toarray
()[
row_ids
,
col_slice_start
:
col_slice_stop
]),
0.005
)
print
(
"
test fancy indexing on cols with slice on rows
"
)
F
=
self
.
F
num_inds
=
self
.
r
.
randint
(
1
,
F
.
shape
[
1
])
col_ids
=
[
self
.
r
.
randint
(
0
,
F
.
shape
[
1
]
-
1
)
for
i
in
range
(
0
,
num_inds
)]
...
...
@@ -286,6 +283,65 @@ class TestFaustPy(unittest.TestCase):
self
.
assertLessEqual
(
n1
,
0.0005
)
else
:
self
.
assertLessEqual
(
n1
/
n2
,
0.005
)
print
(
"
test slicing with positive step equal or greater than one
"
)
# rows
rstep
=
self
.
r
.
randint
(
1
,
F
.
shape
[
0
])
assert
(
rstep
>=
1
)
sF
=
F
[
rand_i
:
rand_ii
:
rstep
]
n1
=
norm
(
sF
.
toarray
()
-
F
.
toarray
()[
rand_i
:
rand_ii
:
rstep
])
n2
=
norm
(
F
.
toarray
()[
rand_i
:
rand_ii
:
rstep
])
if
(
n2
==
0
):
# avoid nan error
self
.
assertLessEqual
(
n1
,
0.0005
)
else
:
self
.
assertLessEqual
(
n1
/
n2
,
0.005
)
# columns
cstep
=
self
.
r
.
randint
(
1
,
F
.
shape
[
1
])
assert
(
cstep
>=
1
)
sF
=
F
[:,
rand_j
:
rand_jj
:
cstep
]
n1
=
norm
(
sF
.
toarray
()
-
F
.
toarray
()[:,
rand_j
:
rand_jj
:
cstep
])
n2
=
norm
(
F
.
toarray
()[:,
rand_j
:
rand_jj
:
cstep
])
if
(
n2
==
0
):
# avoid nan error
self
.
assertLessEqual
(
n1
,
0.0005
)
else
:
self
.
assertLessEqual
(
n1
/
n2
,
0.005
)
# rows and cols
sF
=
F
[
rand_i
:
rand_ii
:
rstep
,
rand_j
:
rand_jj
:
cstep
]
n1
=
\
norm
(
sF
.
toarray
()
-
F
.
toarray
()[
rand_i
:
rand_ii
:
rstep
,
rand_j
:
rand_jj
:
cstep
])
n2
=
norm
(
F
.
toarray
()[
rand_i
:
rand_ii
:
rstep
,
rand_j
:
rand_jj
:
cstep
])
if
(
n2
==
0
):
# avoid nan error
self
.
assertLessEqual
(
n1
,
0.0005
)
else
:
self
.
assertLessEqual
(
n1
/
n2
,
0.005
)
print
(
"
test slicing with negative step
"
)
# rows
sF
=
F
[
rand_ii
:
rand_i
:
-
rstep
]
n1
=
norm
(
sF
.
toarray
()
-
F
.
toarray
()[
rand_ii
:
rand_i
:
-
rstep
])
n2
=
norm
(
F
.
toarray
()[
rand_ii
:
rand_i
:
-
rstep
])
if
(
n2
==
0
):
# avoid nan error
self
.
assertLessEqual
(
n1
,
0.0005
)
else
:
self
.
assertLessEqual
(
n1
/
n2
,
0.005
)
# cols
sF
=
F
[:,
rand_jj
:
rand_j
:
-
cstep
]
n1
=
norm
(
sF
.
toarray
()
-
F
.
toarray
()[:,
rand_jj
:
rand_j
:
-
cstep
])
n2
=
norm
(
F
.
toarray
()[:,
rand_jj
:
rand_j
:
-
cstep
])
if
(
n2
==
0
):
# avoid nan error
self
.
assertLessEqual
(
n1
,
0.0005
)
else
:
self
.
assertLessEqual
(
n1
/
n2
,
0.005
)
# rows and cols
sF
=
F
[
rand_ii
:
rand_i
:
-
rstep
,
rand_jj
:
rand_j
:
-
cstep
]
n1
=
\
norm
(
sF
.
toarray
()
-
F
.
toarray
()[
rand_ii
:
rand_i
:
-
rstep
,
rand_jj
:
rand_j
:
-
cstep
])
n2
=
norm
(
F
.
toarray
()[
rand_ii
:
rand_i
:
-
rstep
,
rand_jj
:
rand_j
:
-
cstep
])
if
(
n2
==
0
):
# avoid nan error
self
.
assertLessEqual
(
n1
,
0.0005
)
else
:
self
.
assertLessEqual
(
n1
/
n2
,
0.005
)
def
testToDense
(
self
):
print
(
"
testToDense()
"
)
...
...
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