Skip to content

Commit ea9f346

Browse files
authored
Merge pull request #1236 from inclement/sympy_recipe
Added sympy recipe
2 parents 95b3247 + 5f66527 commit ea9f346

File tree

5 files changed

+303
-0
lines changed

5 files changed

+303
-0
lines changed

ci/constants.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ class TargetPython(Enum):
5757
'pyzmq',
5858
'secp256k1',
5959
'shapely',
60+
# mpmath package with a version >= 0.19 required
61+
'sympy',
6062
'twisted',
6163
'vlc',
6264
'websocket-client',
@@ -93,6 +95,8 @@ class TargetPython(Enum):
9395
'pyjnius', 'pyopenal',
9496
# SyntaxError: invalid syntax (Python2)
9597
'storm',
98+
# mpmath package with a version >= 0.19 required
99+
'sympy',
96100
'vlc',
97101
])
98102
# to be created via https://github.com/kivy/python-for-android/issues/1514
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
from pythonforandroid.recipe import PythonRecipe
3+
4+
5+
class SympyRecipe(PythonRecipe):
6+
version = '1.1.1'
7+
url = 'https://github.com/sympy/sympy/releases/download/sympy-{version}/sympy-{version}.tar.gz'
8+
9+
depends = [('python2', 'python3crystax'), 'mpmath']
10+
11+
call_hostpython_via_targetpython = True
12+
13+
patches = ['fix_timeutils.patch', 'fix_pretty_print.patch']
14+
15+
16+
recipe = SympyRecipe()
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
diff --git a/pip/download.py b/pip/download.py
2+
index 54d3131..1aab70f 100644
3+
--- a/pip/download.py
4+
+++ b/pip/download.py
5+
@@ -89,23 +89,25 @@ def user_agent():
6+
# Complete Guess
7+
data["implementation"]["version"] = platform.python_version()
8+
9+
- if sys.platform.startswith("linux"):
10+
- from pip._vendor import distro
11+
- distro_infos = dict(filter(
12+
- lambda x: x[1],
13+
- zip(["name", "version", "id"], distro.linux_distribution()),
14+
- ))
15+
- libc = dict(filter(
16+
- lambda x: x[1],
17+
- zip(["lib", "version"], libc_ver()),
18+
- ))
19+
- if libc:
20+
- distro_infos["libc"] = libc
21+
- if distro_infos:
22+
- data["distro"] = distro_infos
23+
-
24+
- if sys.platform.startswith("darwin") and platform.mac_ver()[0]:
25+
- data["distro"] = {"name": "macOS", "version": platform.mac_ver()[0]}
26+
+ # if sys.platform.startswith("linux"):
27+
+ # from pip._vendor import distro
28+
+ # distro_infos = dict(filter(
29+
+ # lambda x: x[1],
30+
+ # zip(["name", "version", "id"], distro.linux_distribution()),
31+
+ # ))
32+
+ # libc = dict(filter(
33+
+ # lambda x: x[1],
34+
+ # zip(["lib", "version"], libc_ver()),
35+
+ # ))
36+
+ # if libc:
37+
+ # distro_infos["libc"] = libc
38+
+ # if distro_infos:
39+
+ # data["distro"] = distro_infos
40+
+
41+
+ # if sys.platform.startswith("darwin") and platform.mac_ver()[0]:
42+
+ # data["distro"] = {"name": "macOS", "version": platform.mac_ver()[0]}
43+
+
44+
+ data['distro'] = {'name': 'Android'}
45+
46+
if platform.system():
47+
data.setdefault("system", {})["name"] = platform.system()
Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
diff --git a/sympy/printing/pretty/pretty.py b/sympy/printing/pretty/pretty.py
2+
index 604e97c..ddd3eb2 100644
3+
--- a/sympy/printing/pretty/pretty.py
4+
+++ b/sympy/printing/pretty/pretty.py
5+
@@ -166,14 +166,14 @@ class PrettyPrinter(Printer):
6+
arg = e.args[0]
7+
pform = self._print(arg)
8+
if isinstance(arg, Equivalent):
9+
- return self._print_Equivalent(arg, altchar=u"\N{NOT IDENTICAL TO}")
10+
+ return self._print_Equivalent(arg, altchar=u"NOT IDENTICAL TO")
11+
if isinstance(arg, Implies):
12+
- return self._print_Implies(arg, altchar=u"\N{RIGHTWARDS ARROW WITH STROKE}")
13+
+ return self._print_Implies(arg, altchar=u"RIGHTWARDS ARROW WITH STROKE")
14+
15+
if arg.is_Boolean and not arg.is_Not:
16+
pform = prettyForm(*pform.parens())
17+
18+
- return prettyForm(*pform.left(u"\N{NOT SIGN}"))
19+
+ return prettyForm(*pform.left(u"NOT SIGN"))
20+
else:
21+
return self._print_Function(e)
22+
23+
@@ -200,43 +200,43 @@ class PrettyPrinter(Printer):
24+
25+
def _print_And(self, e):
26+
if self._use_unicode:
27+
- return self.__print_Boolean(e, u"\N{LOGICAL AND}")
28+
+ return self.__print_Boolean(e, u"LOGICAL AND")
29+
else:
30+
return self._print_Function(e, sort=True)
31+
32+
def _print_Or(self, e):
33+
if self._use_unicode:
34+
- return self.__print_Boolean(e, u"\N{LOGICAL OR}")
35+
+ return self.__print_Boolean(e, u"LOGICAL OR")
36+
else:
37+
return self._print_Function(e, sort=True)
38+
39+
def _print_Xor(self, e):
40+
if self._use_unicode:
41+
- return self.__print_Boolean(e, u"\N{XOR}")
42+
+ return self.__print_Boolean(e, u"XOR")
43+
else:
44+
return self._print_Function(e, sort=True)
45+
46+
def _print_Nand(self, e):
47+
if self._use_unicode:
48+
- return self.__print_Boolean(e, u"\N{NAND}")
49+
+ return self.__print_Boolean(e, u"NAND")
50+
else:
51+
return self._print_Function(e, sort=True)
52+
53+
def _print_Nor(self, e):
54+
if self._use_unicode:
55+
- return self.__print_Boolean(e, u"\N{NOR}")
56+
+ return self.__print_Boolean(e, u"NOR")
57+
else:
58+
return self._print_Function(e, sort=True)
59+
60+
def _print_Implies(self, e, altchar=None):
61+
if self._use_unicode:
62+
- return self.__print_Boolean(e, altchar or u"\N{RIGHTWARDS ARROW}", sort=False)
63+
+ return self.__print_Boolean(e, altchar or u"RIGHTWARDS ARROW", sort=False)
64+
else:
65+
return self._print_Function(e)
66+
67+
def _print_Equivalent(self, e, altchar=None):
68+
if self._use_unicode:
69+
- return self.__print_Boolean(e, altchar or u"\N{IDENTICAL TO}")
70+
+ return self.__print_Boolean(e, altchar or u"IDENTICAL TO")
71+
else:
72+
return self._print_Function(e, sort=True)
73+
74+
@@ -425,7 +425,7 @@ class PrettyPrinter(Printer):
75+
if self._use_unicode:
76+
# use unicode corners
77+
horizontal_chr = xobj('-', 1)
78+
- corner_chr = u'\N{BOX DRAWINGS LIGHT DOWN AND HORIZONTAL}'
79+
+ corner_chr = u'BOX DRAWINGS LIGHT DOWN AND HORIZONTAL'
80+
81+
func_height = pretty_func.height()
82+
83+
@@ -580,7 +580,7 @@ class PrettyPrinter(Printer):
84+
85+
LimArg = self._print(z)
86+
if self._use_unicode:
87+
- LimArg = prettyForm(*LimArg.right(u'\N{BOX DRAWINGS LIGHT HORIZONTAL}\N{RIGHTWARDS ARROW}'))
88+
+ LimArg = prettyForm(*LimArg.right(u'BOX DRAWINGS LIGHT HORIZONTALRIGHTWARDS ARROW'))
89+
else:
90+
LimArg = prettyForm(*LimArg.right('->'))
91+
LimArg = prettyForm(*LimArg.right(self._print(z0)))
92+
@@ -589,7 +589,7 @@ class PrettyPrinter(Printer):
93+
dir = ""
94+
else:
95+
if self._use_unicode:
96+
- dir = u'\N{SUPERSCRIPT PLUS SIGN}' if str(dir) == "+" else u'\N{SUPERSCRIPT MINUS}'
97+
+ dir = u'SUPERSCRIPT PLUS SIGN' if str(dir) == "+" else u'SUPERSCRIPT MINUS'
98+
99+
LimArg = prettyForm(*LimArg.right(self._print(dir)))
100+
101+
@@ -740,7 +740,7 @@ class PrettyPrinter(Printer):
102+
def _print_Adjoint(self, expr):
103+
pform = self._print(expr.arg)
104+
if self._use_unicode:
105+
- dag = prettyForm(u'\N{DAGGER}')
106+
+ dag = prettyForm(u'DAGGER')
107+
else:
108+
dag = prettyForm('+')
109+
from sympy.matrices import MatrixSymbol
110+
@@ -850,8 +850,8 @@ class PrettyPrinter(Printer):
111+
if '\n' in partstr:
112+
tempstr = partstr
113+
tempstr = tempstr.replace(vectstrs[i], '')
114+
- tempstr = tempstr.replace(u'\N{RIGHT PARENTHESIS UPPER HOOK}',
115+
- u'\N{RIGHT PARENTHESIS UPPER HOOK}'
116+
+ tempstr = tempstr.replace(u'RIGHT PARENTHESIS UPPER HOOK',
117+
+ u'RIGHT PARENTHESIS UPPER HOOK'
118+
+ ' ' + vectstrs[i])
119+
o1[i] = tempstr
120+
o1 = [x.split('\n') for x in o1]
121+
@@ -1153,7 +1153,7 @@ class PrettyPrinter(Printer):
122+
def _print_Lambda(self, e):
123+
vars, expr = e.args
124+
if self._use_unicode:
125+
- arrow = u" \N{RIGHTWARDS ARROW FROM BAR} "
126+
+ arrow = u" RIGHTWARDS ARROW FROM BAR "
127+
else:
128+
arrow = " -> "
129+
if len(vars) == 1:
130+
@@ -1173,7 +1173,7 @@ class PrettyPrinter(Printer):
131+
elif len(expr.variables):
132+
pform = prettyForm(*pform.right(self._print(expr.variables[0])))
133+
if self._use_unicode:
134+
- pform = prettyForm(*pform.right(u" \N{RIGHTWARDS ARROW} "))
135+
+ pform = prettyForm(*pform.right(u" RIGHTWARDS ARROW "))
136+
else:
137+
pform = prettyForm(*pform.right(" -> "))
138+
if len(expr.point) > 1:
139+
@@ -1462,7 +1462,7 @@ class PrettyPrinter(Printer):
140+
and expt is S.Half and bpretty.height() == 1
141+
and (bpretty.width() == 1
142+
or (base.is_Integer and base.is_nonnegative))):
143+
- return prettyForm(*bpretty.left(u'\N{SQUARE ROOT}'))
144+
+ return prettyForm(*bpretty.left(u'SQUARE ROOT'))
145+
146+
# Construct root sign, start with the \/ shape
147+
_zZ = xobj('/', 1)
148+
@@ -1558,7 +1558,7 @@ class PrettyPrinter(Printer):
149+
from sympy import Pow
150+
return self._print(Pow(p.sets[0], len(p.sets), evaluate=False))
151+
else:
152+
- prod_char = u"\N{MULTIPLICATION SIGN}" if self._use_unicode else 'x'
153+
+ prod_char = u"MULTIPLICATION SIGN" if self._use_unicode else 'x'
154+
return self._print_seq(p.sets, None, None, ' %s ' % prod_char,
155+
parenthesize=lambda set: set.is_Union or
156+
set.is_Intersection or set.is_ProductSet)
157+
@@ -1570,7 +1570,7 @@ class PrettyPrinter(Printer):
158+
def _print_Range(self, s):
159+
160+
if self._use_unicode:
161+
- dots = u"\N{HORIZONTAL ELLIPSIS}"
162+
+ dots = u"HORIZONTAL ELLIPSIS"
163+
else:
164+
dots = '...'
165+
166+
@@ -1641,7 +1641,7 @@ class PrettyPrinter(Printer):
167+
168+
def _print_ImageSet(self, ts):
169+
if self._use_unicode:
170+
- inn = u"\N{SMALL ELEMENT OF}"
171+
+ inn = u"SMALL ELEMENT OF"
172+
else:
173+
inn = 'in'
174+
variables = self._print_seq(ts.lamda.variables)
175+
@@ -1653,10 +1653,10 @@ class PrettyPrinter(Printer):
176+
177+
def _print_ConditionSet(self, ts):
178+
if self._use_unicode:
179+
- inn = u"\N{SMALL ELEMENT OF}"
180+
+ inn = u"SMALL ELEMENT OF"
181+
# using _and because and is a keyword and it is bad practice to
182+
# overwrite them
183+
- _and = u"\N{LOGICAL AND}"
184+
+ _and = u"LOGICAL AND"
185+
else:
186+
inn = 'in'
187+
_and = 'and'
188+
@@ -1677,7 +1677,7 @@ class PrettyPrinter(Printer):
189+
190+
def _print_ComplexRegion(self, ts):
191+
if self._use_unicode:
192+
- inn = u"\N{SMALL ELEMENT OF}"
193+
+ inn = u"SMALL ELEMENT OF"
194+
else:
195+
inn = 'in'
196+
variables = self._print_seq(ts.variables)
197+
@@ -1690,7 +1690,7 @@ class PrettyPrinter(Printer):
198+
def _print_Contains(self, e):
199+
var, set = e.args
200+
if self._use_unicode:
201+
- el = u" \N{ELEMENT OF} "
202+
+ el = u" ELEMENT OF "
203+
return prettyForm(*stringPict.next(self._print(var),
204+
el, self._print(set)), binding=8)
205+
else:
206+
@@ -1698,7 +1698,7 @@ class PrettyPrinter(Printer):
207+
208+
def _print_FourierSeries(self, s):
209+
if self._use_unicode:
210+
- dots = u"\N{HORIZONTAL ELLIPSIS}"
211+
+ dots = u"HORIZONTAL ELLIPSIS"
212+
else:
213+
dots = '...'
214+
return self._print_Add(s.truncate()) + self._print(dots)
215+
@@ -1708,7 +1708,7 @@ class PrettyPrinter(Printer):
216+
217+
def _print_SeqFormula(self, s):
218+
if self._use_unicode:
219+
- dots = u"\N{HORIZONTAL ELLIPSIS}"
220+
+ dots = u"HORIZONTAL ELLIPSIS"
221+
else:
222+
dots = '...'
223+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/sympy/utilities/timeutils.py b/sympy/utilities/timeutils.py
2+
index 3770d85..c53594e 100644
3+
--- a/sympy/utilities/timeutils.py
4+
+++ b/sympy/utilities/timeutils.py
5+
@@ -8,7 +8,7 @@ import math
6+
from sympy.core.compatibility import range
7+
8+
_scales = [1e0, 1e3, 1e6, 1e9]
9+
-_units = [u's', u'ms', u'\N{GREEK SMALL LETTER MU}s', u'ns']
10+
+_units = [u's', u'ms', u'mus', u'ns']
11+
12+
13+
def timed(func, setup="pass", limit=None):

0 commit comments

Comments
 (0)