Re: [sage-devel] Different behavior in normal usage and when building the doc (decimal separator / tachyon syntax error)

2020-01-08 Thread Jean-Florent Raymond
Le 07/01/2020 à 10:20, dimp...@gmail.com a écrit :
> On Mon, Jan 06, 2020 at 06:37:25PM +0100, Jean-Florent Raymond wrote:
>>
>> I have been investigating a bug that happened when I tried to build the
>> documentation of sage 9.0 on a new machine.
>> It seems to be the same as described in
>>
>> https://groups.google.com/d/topic/sage-devel/5jajeJiJNiY/discussion
>> (the thread describes a way to circumvent it)
>>
>> In a few words: in order to produce 3d pictures for the documentation,
>> the script that builds the documentation calls tachyon (because jmol is
>> not available) and the tachyon call results in a syntax error. Strangely
>> I have not been able to reproduce this error except when building the
>> documentation.
>> The way it works is that a string describing the 3d scene is written to
>> a temporary file, which is then read by tachyon. Investigating further I
>> found that some decimal numbers are printed in this file with commas as
>> decimal separator when building the doc and with dots when running
>> sage... I highly suspect this to be the reason of the syntax error
>> raised by tachyon. Below is an example of lines from the two temporary
>> files corresponding to the same call, the first in normal sage and the
>> second one obtained when building the doc.
>>
>> TRI V0 0.641519 0.179487 0.025641 V1 0.641026 0.18109 -0.025641 V2
>> 0.641519 0.179487 -0.025641
>> TRI V0 0,641519 0,179487 0,025641 V1 0,641026 0,18109 -0,025641 V2
>> 0,641519 0,179487 -0,025641
>>
>> What I cannot explain is why these lines have been printed differently
>> (i.e. commas instead of dots). They have been printed by the function
>> format_tachyon_triangle from src/sage/plot/plot3d/index_face_set.pyx,
>> whose code is the following (comment is not mine):
>>
>> cdef inline format_tachyon_triangle(point_c P, point_c Q, point_c R):
>> cdef char ss[250]
>> # PyBytes_FromFormat doesn't do floats?
>> cdef Py_ssize_t r = sprintf_9d(ss,
>>"TRI V0 %g %g %g V1 %g %g %g V2 %g %g
>> %g",
>>P.x, P.y, P.z,
>>Q.x, Q.y, Q.z,
>>R.x, R.y, R.z )
>> return bytes_to_str(PyBytes_FromStringAndSize(ss, r))
>>
>> Does anyone here has an idea why this function behaves differently
>> depending on whether it is called in sage or when building the doc?
> 
> Are you on locale that uses commas instead of dots in representing
> floating precision numbers?
> If so, it could be that writing out these files happens under the
> control of your locale...

Indeed, and by changing the locale to en_US the problem disappears. Thanks!
Here is a fix: https://trac.sagemath.org/ticket/28971

Jean-Florent.

> 
> Just a wild guess, of course.
> Dima
> 
> 
>>
>> Best,
>> Jean-Florent.
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "sage-devel" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to sage-devel+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/sage-devel/9fcb3ff1-bedb-2a5c-af16-fcee21588e10%40uca.fr.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/f7eb4ed0-2307-40c8-34ae-60d819040c1b%40uca.fr.


signature.asc
Description: OpenPGP digital signature


Re: [sage-devel] Different behavior in normal usage and when building the doc (decimal separator / tachyon syntax error)

2020-01-07 Thread dimpase
On Mon, Jan 06, 2020 at 06:37:25PM +0100, Jean-Florent Raymond wrote:
> 
> I have been investigating a bug that happened when I tried to build the
> documentation of sage 9.0 on a new machine.
> It seems to be the same as described in
> 
> https://groups.google.com/d/topic/sage-devel/5jajeJiJNiY/discussion
> (the thread describes a way to circumvent it)
> 
> In a few words: in order to produce 3d pictures for the documentation,
> the script that builds the documentation calls tachyon (because jmol is
> not available) and the tachyon call results in a syntax error. Strangely
> I have not been able to reproduce this error except when building the
> documentation.
> The way it works is that a string describing the 3d scene is written to
> a temporary file, which is then read by tachyon. Investigating further I
> found that some decimal numbers are printed in this file with commas as
> decimal separator when building the doc and with dots when running
> sage... I highly suspect this to be the reason of the syntax error
> raised by tachyon. Below is an example of lines from the two temporary
> files corresponding to the same call, the first in normal sage and the
> second one obtained when building the doc.
> 
> TRI V0 0.641519 0.179487 0.025641 V1 0.641026 0.18109 -0.025641 V2
> 0.641519 0.179487 -0.025641
> TRI V0 0,641519 0,179487 0,025641 V1 0,641026 0,18109 -0,025641 V2
> 0,641519 0,179487 -0,025641
> 
> What I cannot explain is why these lines have been printed differently
> (i.e. commas instead of dots). They have been printed by the function
> format_tachyon_triangle from src/sage/plot/plot3d/index_face_set.pyx,
> whose code is the following (comment is not mine):
> 
> cdef inline format_tachyon_triangle(point_c P, point_c Q, point_c R):
> cdef char ss[250]
> # PyBytes_FromFormat doesn't do floats?
> cdef Py_ssize_t r = sprintf_9d(ss,
>"TRI V0 %g %g %g V1 %g %g %g V2 %g %g
> %g",
>P.x, P.y, P.z,
>Q.x, Q.y, Q.z,
>R.x, R.y, R.z )
> return bytes_to_str(PyBytes_FromStringAndSize(ss, r))
> 
> Does anyone here has an idea why this function behaves differently
> depending on whether it is called in sage or when building the doc?

Are you on locale that uses commas instead of dots in representing
floating precision numbers?
If so, it could be that writing out these files happens under the
control of your locale...

Just a wild guess, of course.
Dima


> 
> Best,
> Jean-Florent.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to sage-devel+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sage-devel/9fcb3ff1-bedb-2a5c-af16-fcee21588e10%40uca.fr.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/20200107092046.GC9126%40hilbert.


signature.asc
Description: PGP signature


[sage-devel] Different behavior in normal usage and when building the doc (decimal separator / tachyon syntax error)

2020-01-06 Thread Jean-Florent Raymond
Hello,

I have been investigating a bug that happened when I tried to build the
documentation of sage 9.0 on a new machine.
It seems to be the same as described in

https://groups.google.com/d/topic/sage-devel/5jajeJiJNiY/discussion
(the thread describes a way to circumvent it)

In a few words: in order to produce 3d pictures for the documentation,
the script that builds the documentation calls tachyon (because jmol is
not available) and the tachyon call results in a syntax error. Strangely
I have not been able to reproduce this error except when building the
documentation.
The way it works is that a string describing the 3d scene is written to
a temporary file, which is then read by tachyon. Investigating further I
found that some decimal numbers are printed in this file with commas as
decimal separator when building the doc and with dots when running
sage... I highly suspect this to be the reason of the syntax error
raised by tachyon. Below is an example of lines from the two temporary
files corresponding to the same call, the first in normal sage and the
second one obtained when building the doc.

TRI V0 0.641519 0.179487 0.025641 V1 0.641026 0.18109 -0.025641 V2
0.641519 0.179487 -0.025641
TRI V0 0,641519 0,179487 0,025641 V1 0,641026 0,18109 -0,025641 V2
0,641519 0,179487 -0,025641

What I cannot explain is why these lines have been printed differently
(i.e. commas instead of dots). They have been printed by the function
format_tachyon_triangle from src/sage/plot/plot3d/index_face_set.pyx,
whose code is the following (comment is not mine):

cdef inline format_tachyon_triangle(point_c P, point_c Q, point_c R):
cdef char ss[250]
# PyBytes_FromFormat doesn't do floats?
cdef Py_ssize_t r = sprintf_9d(ss,
   "TRI V0 %g %g %g V1 %g %g %g V2 %g %g
%g",
   P.x, P.y, P.z,
   Q.x, Q.y, Q.z,
   R.x, R.y, R.z )
return bytes_to_str(PyBytes_FromStringAndSize(ss, r))

Does anyone here has an idea why this function behaves differently
depending on whether it is called in sage or when building the doc?

Best,
Jean-Florent.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/9fcb3ff1-bedb-2a5c-af16-fcee21588e10%40uca.fr.