Opened 12 years ago

Closed 11 years ago

#10327 closed defect (fixed)

Problems with get_systems and symbolic expressions

Reported by: Jean-Pierre Flori Owned by: Burcin Erocal
Priority: minor Milestone: sage-4.7.1
Component: symbolics Keywords:
Cc: Jean-Pierre Flori Merged in: sage-4.7.1.alpha2
Authors: Mike Hansen Reviewers: Karl-Dieter Crisman
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description

I'm using Sage 4.6.1.alpha2 with Pynac 0.2.1.

get_systems raises an error when called on a user created variable (but not on 'x'):

sage: get_systems('x+x')
[]
sage: get_systems('x*x')
[]
sage: a = var('a')
sage: get_systems('a+a')
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/home/jp/boulot/sage/sage-current/<ipython console> in <module>()

/home/jp/boulot/sage/sage-current/local/lib/python2.6/site-packages/sage/misc/citation.so in sage.misc.citation.get_systems (sage/misc/citation.c:873)()

/home/jp/boulot/sage/sage-current/local/lib/python/cProfile.pyc in runctx(statement, globals, locals, filename)
     47     try:
     48         try:
---> 49             prof = prof.runctx(statement, globals, locals)
     50         except SystemExit:
     51             pass

/home/jp/boulot/sage/sage-current/local/lib/python/cProfile.pyc in runctx(self, cmd, globals, locals)
    138         self.enable()
    139         try:
--> 140             exec cmd in globals, locals
    141         finally:
    142             self.disable()

/home/jp/boulot/sage/sage-current/<string> in <module>()

TypeError: unsupported operand type(s) for +: 'NoneType' and 'NoneType'
sage: get_systems('a*a')
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/home/jp/boulot/sage/sage-current/<ipython console> in <module>()

/home/jp/boulot/sage/sage-current/local/lib/python2.6/site-packages/sage/misc/citation.so in sage.misc.citation.get_systems (sage/misc/citation.c:873)()

/home/jp/boulot/sage/sage-current/local/lib/python/cProfile.pyc in runctx(statement, globals, locals, filename)
     47     try:
     48         try:
---> 49             prof = prof.runctx(statement, globals, locals)
     50         except SystemExit:
     51             pass

/home/jp/boulot/sage/sage-current/local/lib/python/cProfile.pyc in runctx(self, cmd, globals, locals)
    138         self.enable()
    139         try:
--> 140             exec cmd in globals, locals
    141         finally:
    142             self.disable()

/home/jp/boulot/sage/sage-current/<string> in <module>()

TypeError: unsupported operand type(s) for *: 'NoneType' and 'NoneType'

Similarly, get_systems('2a') and get_systems('a2') gives an error with None_Type

Moreover I get a segfault when calling get_systems on a power with symbolic expressions as base and exponent.

sage: from sage.misc.citation import get_systems
sage: get_systems('x**x')
[]
sage: a = var('a')
sage: get_systems('a**x')

Program received signal SIGSEGV, Segmentation fault.
0x00007fffd636b5c8 in __pyx_pf_4sage_8symbolic_10expression_10Expression___pow__ (__pyx_v_self=0x7ffff7dab0f0, __pyx_v_exp=0x42c03f8, __pyx_v_ignored=<value optimized out>) at sage/symbolic/expression.cpp:12008
12008         __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4sage_8symbolic_10expression_Expression *)__pyx_v_base->__pyx_base.__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->coerce_in(__pyx_v_base, __pyx_v_exp)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 2447; __pyx_clineno = __LINE__; goto __pyx_L5_error;}

and :

sage: a = var('a')
sage: get_systems('x**a')

Program received signal SIGSEGV, Segmentation fault.
ptr (__pyx_v_self=<value optimized out>, __pyx_v_exp=0x7ffff7dab0f0, __pyx_v_ignored=<value optimized out>) at /home/jp/boulot/sage/sage-current/local//include/pynac/ptr.h:73
73              ptr(const ptr & other) throw() : p(other.p) { p->add_reference(); }

I'll have a deeper look at it later, but I have no idea of how get_systems work yet.

Attachments (1)

trac_10327.patch (913 bytes) - added by Mike Hansen 12 years ago.

Download all attachments as: .zip

Change History (5)

Changed 12 years ago by Mike Hansen

Attachment: trac_10327.patch added

comment:1 Changed 12 years ago by Mike Hansen

Authors: Mike Hansen
Milestone: sage-4.6.1
Status: newneeds_review

comment:2 Changed 11 years ago by Karl-Dieter Crisman

Reviewers: Karl-Dieter Crisman
Status: needs_reviewpositive_review

I finally figured out why it works. For my own reference, or others who might have been similarly confused by this important but arcane subject. In some sense we're lucky that JP happened upon 'a', as many others weren't in this!

sage: get_systems('print locals()')
{'a': None, 'bad_res': None, 'systems_used': None, 'stats': None, 'bad_re': None, 'i': None, 'cmd': 'print locals()', 'system': None, 'filename': '/Users/karl-dietercrisman/.sage//temp/new_host_2.home/60265//tmp_2', 're': <module 're' from '/Applications/MathApps/sage/local/lib/python/re.pyc'>, 's': None, 'r': None, 'cProfile': <module 'cProfile' from '/Applications/MathApps/sage/local/lib/python/cProfile.pyc'>, 'pstats': <module 'pstats' from '/Applications/MathApps/sage/local/lib/python/pstats.pyc'>, 'strings': None}
[]

Yes, we wouldn't want to use these particular locals to exec the command.

And work the patch does, in a fair number of cases (using quite a few of the systems) I still tested. Good catch.

comment:3 Changed 11 years ago by Jeroen Demeyer

Milestone: sage-4.7sage-4.7.1

comment:4 Changed 11 years ago by Jeroen Demeyer

Merged in: sage-4.7.1.alpha2
Resolution: fixed
Status: positive_reviewclosed
Note: See TracTickets for help on using tickets.