Ticket #12446 (new defect)
sage access in cython_lambda broken
| Reported by: | schilly | Owned by: | jdemeyer |
|---|---|---|---|
| Priority: | minor | Milestone: | sage-5.11 |
| Component: | cython | Keywords: | |
| Cc: | Work issues: | ||
| Report Upstream: | N/A | Reviewers: | |
| Authors: | Merged in: | ||
| Dependencies: | Stopgaps: |
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'
Note: See
TracTickets for help on using
tickets.

This is Mac OS X 10.7.4, I actually get a couple other errors.
sage -t -only-optional=gcc "devel/sage-main/sage/misc/cython.py" ********************************************************************** File "/Users/.../sage-5.4.beta2/devel/sage-main/sage/misc/cython.py", line 617: sage: g(2,3) # optional -- gcc Expected: 55.200000000000003 Got: 55.2 ********************************************************************** File "/Users/.../sage-5.4.beta2/devel/sage-main/sage/misc/cython.py", line 619: sage: g(0,0) # optional -- gcc Expected: 3.2000000000000002 Got: 3.2 ********************************************************************** File "/Users.../sage-5.4.beta2/devel/sage-main/sage/misc/cython.py", line 626: sage: f(10) # optional -- gcc Exception raised: KeyError: 'math' ********************************************************************** File "/Users/.../sage-5.4.beta2/devel/sage-main/sage/misc/cython.py", line 629: sage: f(10) # optional -- gcc Exception raised: KeyError: 'math' ********************************************************************** 1 items had failures: 4 of 12 in __main__.example_0 ***Test Failed*** 4 failures.