5 if os
.getenv('SYMPY_PY', '').lower() in ['y', 'yes']:
6 print 'I: forced to be pure python'
11 print 'I: import sympy_pyx ...',
12 from sympy_pyx
import *
14 # XXX figure out how to put this into sympy_pyx.pyx:
22 from sympy_pyx
import _Basic
24 # Cython/Pyrex do not support __new__, so we have to define Basic here
27 def __new__(cls
, args
):
28 o
= _Basic
.__new
__(cls
)
29 o
._set
_rawargs
(tuple(args
))
33 except ImportError, e
:
35 print 'W: can\'t import sympy_pyx -- will be pure python'
43 from sympy_pyx
import *
45 from sympy_py
import *
49 Create a symbolic variable with the name *s*.
52 s -- a string, either a single variable name, or
53 a space separated list of variable names, or
54 a list of variable names.
56 NOTE: The new variable is both returned and automatically injected into
57 the parent's *global* namespace. It's recommended not to use "var" in
58 library code, it is better to use symbols() instead.
61 We define some symbolic variables:
72 frame
= inspect
.currentframe().f_back
75 if not isinstance(s
, list):
76 s
= re
.split('\s|,', s
)
85 frame
.f_globals
[t
] = sym
89 if len(res
) == 0: # var('')
91 elif len(res
) == 1: # var('x')
93 # otherwise var('a b ...')
97 # we should explicitly break cyclic dependencies as stated in inspect
117 def __new__(cls
, arg
):
121 obj
= Basic
.__new
__(cls
, (arg
,))
125 return "sin(%s)" % self
.args
[0]