number minimal of argument for export data

Bug #1420248 reported by Alex
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Yade
New
Undecided
Unassigned

Bug Description

Hello,

I encounter an anomaly in the export.textExt () function
When I give in parameter That a single argument, I have an execution error.
i have to passed two argument minimum for not have of error

see example below :

=======================================================================================================
EXAMPLE 1 : with error
=======================================================================================================
export.textExt('../../tmp/data_export_melangeur.txt',format='x_y_z_r_attrs',attrs=('b.mat.id'))
=======================================================================================================

Exportation des données en cours...
---------------------------------------------------------------------------
SyntaxError Traceback (most recent call last)
/soft/yade/1.12.0/gcc/4.4.7/bin/yade-1.12.0 in <module>()

/soft/yade/1.12.0/gcc/4.4.7/bin/yade-1.12.0 in ExportData()
     52 # export.textExt('../../tmp/data_export_melangeur.txt',format='x_y_z_r_matId',attrs=('b.mat.label'))
     53 # export.textExt('../../tmp/data_export_melangeur.txt',format='x_y_z_r_attrs',attrs=('b.shape.color','b.state.pos' ))
---> 54 export.textExt('../../tmp/data_export_melangeur.txt',format='x_y_z_r_attrs',attrs=('b.mat.id'))
     55
     56 def testcode():

/soft/yade/1.12.0/gcc/4.4.7/lib64/yade-1.12.0/py/yade/export.pyc in textExt(filename, format, comment, mask, attrs)
     56 output+=('%g\t%g\t%g\t%g'%(b.state.pos[0],b.state.pos[1],b.state.pos[2],b.shape.radius))
     57 for cmd in attrs:
---> 58 v = eval(cmd)
     59 if isinstance(v,(int,float)):
     60 output+='\t%g'%v

SyntaxError: unexpected EOF while parsing (<string>, line 1)

=======================================================================================================
EXAMPLE 2 : with error
=======================================================================================================
export.textExt('../../tmp/data_export_melangeur.txt',format='x_y_z_r_attrs',attrs=('b.shape.color'))
=======================================================================================================

Exportation des données en cours...
---------------------------------------------------------------------------
SyntaxError Traceback (most recent call last)
/soft/yade/1.12.0/gcc/4.4.7/bin/yade-1.12.0 in <module>()

/soft/yade/1.12.0/gcc/4.4.7/bin/yade-1.12.0 in ExportData()
     52 # export.textExt('../../tmp/data_export_melangeur.txt',format='x_y_z_r_matId',attrs=('b.mat.label'))
     53 # export.textExt('../../tmp/data_export_melangeur.txt',format='x_y_z_r_attrs',attrs=('b.shape.color','b.state.pos' ))
---> 54 export.textExt('../../tmp/data_export_melangeur.txt',format='x_y_z_r_attrs',attrs=('b.shape.color'))
     55
     56 def testcode():

/soft/yade/1.12.0/gcc/4.4.7/lib64/yade-1.12.0/py/yade/export.pyc in textExt(filename, format, comment, mask, attrs)
     56 output+=('%g\t%g\t%g\t%g'%(b.state.pos[0],b.state.pos[1],b.state.pos[2],b.shape.radius))
     57 for cmd in attrs:
---> 58 v = eval(cmd)
     59 if isinstance(v,(int,float)):
     60 output+='\t%g'%v

SyntaxError: unexpected EOF while parsing (<string>, line 1)

=======================================================================================================
EXAMPLE 3,4 and 5 : no error
=======================================================================================================
export.textExt('../../tmp/data_export_melangeur.txt',format='x_y_z_r_attrs',attrs=('b.shape.color','b.state.pos' ))
=======================================================================================================

#format x_y_z_r_attrs
0.336553 0.0248906 -0.835412 0.02 0.336553 0.0248906 -0.835412 1 0 1
-0.318431 -0.174808 -0.780485 0.02 -0.318431 -0.174808 -0.780485 1 0 1
0.232435 -0.145611 -0.799793 0.02 0.232435 -0.145611 -0.799793 1 0 1
0.169229 -0.38806 -0.784145 0.02 0.169229 -0.38806 -0.784145 1 0 1
-0.120705 -0.213641 -0.738489 0.02 -0.120705 -0.213641 -0.738489 1 0 1
-0.243449 -0.293311 -0.784106 0.02 -0.243449 -0.293311 -0.784106 1 0 1

=======================================================================================================
export.textExt('../../tmp/data_export_melangeur.txt',format='x_y_z_r_attrs',attrs=('b.shape.color','b.mat.id' ))
=======================================================================================================

#format x_y_z_r_attrs
0.124342 -0.423004 -0.650883 0.02 1 0 1 0
-0.0990602 -0.201278 -0.747631 0.02 1 0 1 0
0.0408943 -0.36283 -0.695135 0.02 1 0 1 0
0.146338 -0.411332 -0.784349 0.02 1 0 1 0
-0.0313473 -0.190286 -0.749565 0.02 1 0 1 0
0.134005 -0.431563 -0.748373 0.02 1 0 1 0
0.192398 -0.0521496 -0.806122 0.02 1 0 1 0

=======================================================================================================
export.textExt('../../tmp/data_export_melangeur.txt',format='x_y_z_r_attrs',attrs=('b.shape.color','b.mat.id','b.state.pos' ))
=======================================================================================================

#format x_y_z_r_attrs
-0.0663139 -0.282156 -0.724299 0.02 1 0 1 0 -0.0663139 -0.282156 -0.724299
0.441224 0.112877 -0.902508 0.02 1 0 1 0 0.441224 0.112877 -0.902508
0.166181 -0.275276 -0.754 0.02 1 0 1 0 0.166181 -0.275276 -0.754
0.172778 -0.385368 -0.755037 0.02 1 0 1 0 0.172778 -0.385368 -0.755037
0.107078 -0.371537 -0.688094 0.02 1 0 1 0 0.107078 -0.371537 -0.688094
0.0671631 -0.500364 -0.742586 0.02 1 0 1 0 0.0671631 -0.500364 -0.742586
-0.341773 -0.296308 -0.76077 0.02 1 0 1 0 -0.341773 -0.296308 -0.76077
0.133467 -0.384747 -0.747603 0.02 1 0 1 0 0.133467 -0.384747 -0.747603

Alexandre,

Revision history for this message
Jan Stránský (honzik) wrote : Re: [Yade-dev] [Bug 1420248] [NEW] number minimal of argument for export data
Download full text (15.5 KiB)

Hi Alexander,

the problem is hidden in python syntax. The 'attrs' argument should be a
list or tuple. So if you use

export.textExt('../../tmp/data_export_melangeur.txt',format='x_y_z_r_attrs',attrs=('
b.mat.id',)) # notice the comma, making ('b.mat.id',) actually a tuple, ('
b.mat.id') is just one string

it should work

cheers
Jan

2015-02-10 12:37 GMT+01:00 Alex <email address hidden>:

> Public bug reported:
>
> Hello,
>
>
> I encounter an anomaly in the export.textExt () function
> When I give in parameter That a single argument, I have an execution
> error.
> i have to passed two argument minimum for not have of error
>
> see example below :
>
>
> =======================================================================================================
> EXAMPLE 1 : with error
>
> =======================================================================================================
>
> export.textExt('../../tmp/data_export_melangeur.txt',format='x_y_z_r_attrs',attrs=('
> b.mat.id'))
>
> =======================================================================================================
>
>
> Exportation des données en cours...
> ---------------------------------------------------------------------------
> SyntaxError Traceback (most recent call last)
> /soft/yade/1.12.0/gcc/4.4.7/bin/yade-1.12.0 in <module>()
>
> /soft/yade/1.12.0/gcc/4.4.7/bin/yade-1.12.0 in ExportData()
> 52 #
> export.textExt('../../tmp/data_export_melangeur.txt',format='x_y_z_r_matId',attrs=('b.mat.label'))
> 53 #
> export.textExt('../../tmp/data_export_melangeur.txt',format='x_y_z_r_attrs',attrs=('b.shape.color','b.state.pos'
> ))
> ---> 54
> export.textExt('../../tmp/data_export_melangeur.txt',format='x_y_z_r_attrs',attrs=('
> b.mat.id'))
> 55
> 56 def testcode():
>
> /soft/yade/1.12.0/gcc/4.4.7/lib64/yade-1.12.0/py/yade/export.pyc in
> textExt(filename, format, comment, mask, attrs)
> 56
> output+=('%g\t%g\t%g\t%g'%(b.state.pos[0],b.state.pos[1],b.state.pos[2],b.shape.radius))
> 57 for cmd in attrs:
> ---> 58 v = eval(cmd)
> 59 if
> isinstance(v,(int,float)):
> 60
> output+='\t%g'%v
>
> SyntaxError: unexpected EOF while parsing (<string>, line 1)
>
>
>
> =======================================================================================================
> EXAMPLE 2 : with error
>
> =======================================================================================================
>
> export.textExt('../../tmp/data_export_melangeur.txt',format='x_y_z_r_attrs',attrs=('b.shape.color'))
>
> =======================================================================================================
>
>
> Exportation des données en cours...
> ---------------------------------------------------------------------------
> SyntaxError Traceback (most recent call last)
> /soft/yade/1.12.0/gcc/4.4.7/bin/yade-1.12.0 in <module>()
>
> /soft/yade/1.12.0/gcc/4.4.7/bin/yade-1.12.0 in ExportData()
> 52 #
> export.text...

Revision history for this message
Alex (alexandre-gaudry) wrote :

yes, actually it works

thank you !

Revision history for this message
Janek Kozicki (cosurgi) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers