Opened 9 years ago

Closed 6 years ago

#12446 closed defect (fixed)

Introduce user_globals

Reported by: schilly Owned by: was
Priority: major Milestone: sage-6.6
Component: user interface Keywords:
Cc: Merged in:
Authors: Jeroen Demeyer Reviewers: Volker Braun
Report Upstream: N/A Work issues:
Branch: 704007e (Commits, GitHub, GitLab) Commit: 704007ea5b0b4bf145ad5acae3e5fd4749d83c0b
Dependencies: Stopgaps:

Status badges

Description (last modified by jdemeyer)

We introduce a new feature: user globals. The idea is to store somewhere a dictionary with the user-space globals which can then be used to inject global variables.

This ticket implements the framework for this and fixes this bug in cython_lambda as proof-of-concept:

        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'

Change History (15)

comment:1 Changed 9 years ago by kcrisman

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.

comment:2 Changed 9 years ago by kcrisman

Actually, the floating point ones are fixed at #13533, so I guess this globals thing is still all this ticket is about. However, that's not documented at #13533, so I figure I'll at least post this error message for posterity.

comment:3 Changed 8 years ago by jdemeyer

  • Component changed from misc to cython
  • Owner changed from jason to jdemeyer

comment:4 Changed 8 years ago by jdemeyer

  • Milestone changed from sage-5.11 to sage-5.12

comment:5 Changed 7 years ago by vbraun_spam

  • Milestone changed from sage-6.1 to sage-6.2

comment:6 Changed 7 years ago by vbraun_spam

  • Milestone changed from sage-6.2 to sage-6.3

comment:7 Changed 7 years ago by vbraun_spam

  • Milestone changed from sage-6.3 to sage-6.4

comment:8 Changed 7 years ago by jdemeyer

  • Description modified (diff)

comment:9 Changed 6 years ago by jdemeyer

  • Authors set to Jeroen Demeyer
  • Component changed from cython to user interface
  • Description modified (diff)
  • Milestone changed from sage-6.4 to sage-6.6
  • Owner changed from jdemeyer to was
  • Priority changed from minor to major
  • Summary changed from sage access in cython_lambda broken to Introduce user_globals

comment:10 Changed 6 years ago by jdemeyer

  • Branch set to u/jdemeyer/sage_access_in_cython_lambda_broken

comment:11 Changed 6 years ago by git

  • Commit set to b5b2726fd61bb2955a02838f3b298864f882e158

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

b5b2726Introduce user_globals

comment:12 Changed 6 years ago by jdemeyer

  • Status changed from new to needs_review

comment:13 Changed 6 years ago by git

  • Commit changed from b5b2726fd61bb2955a02838f3b298864f882e158 to 704007ea5b0b4bf145ad5acae3e5fd4749d83c0b

Branch pushed to git repo; I updated commit sha1. New commits:

704007eMake it an error to use user_globals with initialization

comment:14 Changed 6 years ago by vbraun

  • Reviewers set to Volker Braun
  • Status changed from needs_review to positive_review

comment:15 Changed 6 years ago by vbraun

  • Branch changed from u/jdemeyer/sage_access_in_cython_lambda_broken to 704007ea5b0b4bf145ad5acae3e5fd4749d83c0b
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.