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
Admin message
GitLab upgrade completed. Current version is 17.11.4.
Show more breadcrumbs
faust group
faust
Commits
4612a6b2
Commit
4612a6b2
authored
8 years ago
by
Nicolas Bellot
Committed by
hhakim
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
wrapper Python ajout fontionnalite slicing F(2:3,4:7)
parent
84b2e826
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
misc/test/src/test_pyFaust.py
+55
-1
55 additions, 1 deletion
misc/test/src/test_pyFaust.py
wrapper/python/FaustPy.py
+55
-31
55 additions, 31 deletions
wrapper/python/FaustPy.py
wrapper/python/src/FaustCorePy.pyx
+1
-1
1 addition, 1 deletion
wrapper/python/src/FaustCorePy.pyx
with
111 additions
and
33 deletions
misc/test/src/test_pyFaust.py
+
55
−
1
View file @
4612a6b2
...
...
@@ -43,7 +43,7 @@ sys.path.append(FaustPath)
import
numpy
as
np
#import PyFaust
import
FaustPy
dim1
=
3
dim1
=
4
dim2
=
5
dim3
=
7
nb_factor
=
3
...
...
@@ -215,7 +215,61 @@ print "Ok"
######################################
print
"
*** SLICING ***
"
for
i
in
range
(
dim1
):
for
j
in
range
(
dim2
):
F_i_j
=
F
[
i
,
j
]
F_trans_j_i
=
F_trans
[
j
,
i
]
if
F_i_j
!=
F_dense
[
i
,
j
]:
raise
ValueError
(
'
invalid value
'
)
if
F_i_j
!=
F_trans_dense
[
j
,
i
]:
raise
ValueError
(
'
invalid value
'
)
F_dense_slice
=
F
[...,...]
if
not
(
F_dense_slice
.
shape
==
(
dim1
,
dim2
))
:
print
"
expected size :
"
+
str
([
dim1
,
dim2
])
print
"
got :
"
+
str
(
F_dense_slice
.
shape
)
raise
ValueError
(
'
invalid size of the dense matrix
'
)
if
not
(
F_dense
==
F_dense_slice
).
all
():
raise
ValueError
(
'
invalid value
'
)
F_trans_dense_slice
=
F_trans
[...,...]
if
not
(
F_trans_dense_slice
.
shape
==
(
dim2
,
dim1
))
:
print
"
expected size :
"
+
str
([
dim2
,
dim1
])
print
"
got :
"
+
str
(
F_trans_dense_slice
.
shape
)
raise
ValueError
(
'
invalid size of the dense matrix
'
)
if
not
(
F_trans_dense
==
F_trans_dense_slice
).
all
():
raise
ValueError
(
'
invalid value
'
)
F_dense_slice_1
=
F
[
0
:
dim1
,
0
:
dim2
]
if
not
(
F_dense_slice_1
.
shape
==
(
dim1
,
dim2
))
:
print
"
expected size :
"
+
str
([
dim1
,
dim2
])
print
"
got :
"
+
str
(
F_dense_slice_1
.
shape
)
raise
ValueError
(
'
invalid size of the dense matrix
'
)
if
not
(
F_dense
==
F_dense_slice_1
).
all
():
raise
ValueError
(
'
invalid value
'
)
#~ slice_row=dim1:0:-1
#~ slice_col=dim2:0:-1
#~ F_dense_slice_2 = F[slice_row,slice_col]
F_dense_slice_2
=
F
[::
-
1
,::
-
1
]
if
not
(
F_dense_slice_2
.
shape
==
(
dim1
,
dim2
))
:
print
"
expected size :
"
+
str
([
dim1
,
dim2
])
print
"
got :
"
+
str
(
F_dense_slice_2
.
shape
)
print
F_dense_slice_2
print
""
print
F_dense
raise
ValueError
(
'
invalid size of the dense matrix
'
)
if
not
(
F_dense
[::
-
1
,::
-
1
]
==
F_dense_slice_2
).
all
():
raise
ValueError
(
'
invalid value
'
)
This diff is collapsed.
Click to expand it.
wrapper/python/FaustPy.py
+
55
−
31
View file @
4612a6b2
##############################################################################
## Description: ##
## ##
## FaustPy is class wrapping a C++ class ##
## ##
## For more information on the FAuST Project, please visit the website ##
## of the project : <http://faust.gforge.inria.fr> ##
## ##
## License: ##
## Copyright (2016): Nicolas Bellot, Adrien Leman, Thomas Gautrais, ##
## Luc Le Magoarou, Remi Gribonval ##
## INRIA Rennes, FRANCE ##
## http://www.inria.fr/ ##
## ##
## The FAuST Toolbox is distributed under the terms of the GNU Affero ##
## General Public License. ##
## This program is free software: you can redistribute it and/or modify ##
## it under the terms of the GNU Affero General Public License as ##
## published by the Free Software Foundation. ##
## ##
## This program is distributed in the hope that it will be useful, but ##
## WITHOUT ANY WARRANTY; without even the implied warranty of ##
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ##
## See the GNU Affero General Public License for more details. ##
## ##
## You should have received a copy of the GNU Affero General Public ##
## License along with this program. ##
## If not, see <http://www.gnu.org/licenses/>. ##
## ##
## Contacts: ##
## Nicolas Bellot : nicolas.bellot@inria.fr ##
## Adrien Leman : adrien.leman@inria.fr ##
## Thomas Gautrais : thomas.gautrais@inria.fr ##
## Luc Le Magoarou : luc.le-magoarou@inria.fr ##
## Remi Gribonval : remi.gribonval@inria.fr ##
## ##
##############################################################################
#import sys
#FaustPath='/home/nbellot/Documents/faust_root/faust/trunk/devcpp/build/wrapper/python'
#sys.path.append(FaustPath)
...
...
@@ -50,38 +88,24 @@ class Faust:
return
self_dense
#~ dim1 = 5
#~ dim2 = 10
#~ dim3 = 7
#~ nb_factor = 2
#~ int_max= 100
#~ print('**** CONFIG FAUST F ****');
#~ print 'dim1 : '+str(dim1)
#~ print 'dim2 : '+str(dim2)
#~ print 'nb_factor : '+str(nb_factor)
#~ #initialisation de la liste des facteurs
#~ list_factor=[0]*nb_factor
#~ for i in range(nb_factor):
#~ list_factor[i]=np.random.randint(int_max, size=(dim1,dim1))
#~ list_factor[nb_factor-1]=np.random.randint(int_max, size=(dim1,dim2))
def
__getitem__
(
self
,
list_index
):
#check if list_index has a 2 index (row and column)
if
(
len
(
list_index
)
!=
2
):
raise
ValueError
(
'
list_index must contains 2 elements, the row index and the col index
'
)
#check if the index are slice or integer or Ellipsis
for
id
in
list_index
:
if
(
not
isinstance
(
id
,
slice
))
and
(
not
isinstance
(
id
,
int
)
and
(
id
!=
Ellipsis
)):
raise
ValueError
(
'
list_index must contains slice (1:n) or Ellipsis (...) or int (2)
'
)
keyCol
=
list_index
[
1
]
keyRow
=
list_index
[
0
]
identity
=
np
.
eye
(
self
.
getNbCol
(),
self
.
getNbCol
());
identity
=
identity
[...,
keyCol
]
submatrix
=
self
*
identity
submatrix
=
submatrix
[
keyRow
,:]
return
submatrix
#~ print "*** CONTRUCTOR ***"
#~ F = FaustPy(list_factor)
#~ print "Ok"
#~ print("dim : "+str(F.shape))
#~ Fbis=F.transpose()
#~ print("**** F ****")
#~ F.afficher()
#~ print("**** F trans ****")
#~ Fbis.afficher()
#~ print("**** attributs F ****")
#~ print(F.__dict__)
#~ dir(Fbis)
This diff is collapsed.
Click to expand it.
wrapper/python/src/FaustCorePy.pyx
+
1
−
1
View file @
4612a6b2
...
...
@@ -2,7 +2,7 @@
## Description: ##
## ##
## Cython source file making the links between : ##
## the Cython module
Cy
Faust and Python
##
## the Cython module Faust
CoreCy
and Python ##
## ##
## For more information on the FAuST Project, please visit the website ##
## of the project : <http://faust.gforge.inria.fr> ##
...
...
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