#12446: sage access in cython_lambda broken
---------------------------+------------------------
Reporter: schilly | Owner: jdemeyer
Type: defect | Status: new
Priority: minor | Milestone: sage-6.4
Component: cython | Resolution:
Keywords: | Merged in:
Authors: | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
Dependencies: | Stopgaps:
---------------------------+------------------------
Description changed by jdemeyer:
Old description:
> this is a quote from cython_lambda's documentation.
>
> {{{
> We access a global function and variable.
> sage: a = 25 sage: f = cython_lambda('double x',
> 'sage.math.sin(x) + sage.a') # optional -- gcc
> sage: f(10)
> }}}
>
> apart from the missing newline, this doesn't work.
>
> {{{
> sage: a = 25; f = cython_lambda('double x','sage.math.sin(x) + sage.a')
> sage: f(1)
> ---------------------------------------------------------------------------
> KeyError Traceback (most recent call
> last)
>
> /home/harri/Programming/psnobfit/<ipython console> in <module>()
>
> /home/harri/.sage/temp/x220/11839/spyx/_home_harri__sage_temp_x220_11839_tmp_0_spyx/_home_harri__sage_temp_x220_11839_tmp_0_spyx_0.so
> in _home_harri__sage_temp_x220_11839_tmp_0_spyx_0.f
> (_home_harri__sage_temp_x220_11839_tmp_0_spyx_0.c:621)()
> 11 sage = _s()
> 12
> 13 def f(double x):
> ---> 14 return sage.math.sin(x) + sage.a
> 15
> /home/harri/.sage/temp/x220/11839/spyx/_home_harri__sage_temp_x220_11839_tmp_0_spyx/_home_harri__sage_temp_x220_11839_tmp_0_spyx_0.so
> in _home_harri__sage_temp_x220_11839_tmp_0_spyx_0._s.__getattr__
> (_home_harri__sage_temp_x220_11839_tmp_0_spyx_0.c:559)()
> 7 class _s:
> 8 def __getattr__(self, x):
> ----> 9 return globals()[x]
> 10
> 11 sage = _s()
>
> KeyError: 'math'
> }}}
New description:
This is a quote from `cython_lambda`'s documentation:
{{{
sage: a = 25
sage: f = cython_lambda('double x', 'sage.math.sin(x) + sage.a')
sage: f(10) # known bug
24.455978889110629
sage: a = 50
sage: f(10) # known bug
49.455978889110632
}}}
Executing this gives
{{{
sage: a = 25
sage: f = cython_lambda('double x', 'sage.math.sin(x) + sage.a')
sage: f(10)
Traceback (most recent call last):
...
KeyError: 'math'
}}}
--
--
Ticket URL: <http://trac.sagemath.org/ticket/12446#comment:8>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.