194 lines
7.3 KiB
Diff
194 lines
7.3 KiB
Diff
|
From 5ea93bc9ab7ae9829ed596e2d53976962164ba78 Mon Sep 17 00:00:00 2001
|
||
|
From: Vighnesh Shenoy <vighneshq@gmail.com>
|
||
|
Date: Sun, 9 Jun 2019 23:34:21 +0530
|
||
|
Subject: [PATCH] Issue #16977, fix more compatibility issues with Python3.8.
|
||
|
|
||
|
xml.dom.minidom preserves attribute order in Python3.8 which causes
|
||
|
some test failures. Modified the order of attribute insertion to
|
||
|
ensure that tests run on both 3.8 & earlier versions. Modified the use
|
||
|
of officially removed time.clock with a conditional import in
|
||
|
sympy/core/compatibility.py
|
||
|
---
|
||
|
examples/advanced/pidigits.py | 2 +-
|
||
|
examples/advanced/pyglet_plotting.py | 4 ++--
|
||
|
sympy/core/compatibility.py | 5 ++++
|
||
|
sympy/plotting/pygletplot/plot_window.py | 2 +-
|
||
|
sympy/printing/mathml.py | 30 ++++++++++++------------
|
||
|
5 files changed, 24 insertions(+), 19 deletions(-)
|
||
|
|
||
|
diff --git a/examples/advanced/pidigits.py b/examples/advanced/pidigits.py
|
||
|
index 430ea5aaf83..e444ba2276b 100755
|
||
|
--- a/examples/advanced/pidigits.py
|
||
|
+++ b/examples/advanced/pidigits.py
|
||
|
@@ -10,7 +10,7 @@ from mpmath import libmp, pi
|
||
|
from mpmath import functions as mpf_funs
|
||
|
|
||
|
import math
|
||
|
-from time import clock
|
||
|
+from sympy.core.compatibility import clock
|
||
|
import sys
|
||
|
|
||
|
|
||
|
diff --git a/examples/advanced/pyglet_plotting.py b/examples/advanced/pyglet_plotting.py
|
||
|
index 16d13ac5137..c12ed54f5b1 100755
|
||
|
--- a/examples/advanced/pyglet_plotting.py
|
||
|
+++ b/examples/advanced/pyglet_plotting.py
|
||
|
@@ -8,10 +8,10 @@ Suggested Usage: python -i pyglet_plo
|
||
|
|
||
|
|
||
|
from sympy import symbols, sin, cos, pi, sqrt
|
||
|
-from sympy.core.compatibility import range
|
||
|
+from sympy.core.compatibility import range, clock
|
||
|
from sympy.plotting.pygletplot import PygletPlot
|
||
|
|
||
|
-from time import sleep, clock
|
||
|
+from time import sleep
|
||
|
|
||
|
|
||
|
def main():
|
||
|
diff --git a/sympy/core/compatibility.py b/sympy/core/compatibility.py
|
||
|
index 2827b40ca17..9b6a644d847 100644
|
||
|
--- a/sympy/core/compatibility.py
|
||
|
+++ b/sympy/core/compatibility.py
|
||
|
@@ -945,3 +945,8 @@ try:
|
||
|
except ImportError: # Python 2.7
|
||
|
def filterfalse(pred, itr):
|
||
|
return filter(lambda x: not pred(x), itr)
|
||
|
+
|
||
|
+try:
|
||
|
+ from time import clock
|
||
|
+except ImportError: # Python 3.8+
|
||
|
+ from time import perf_counter as clock
|
||
|
diff --git a/sympy/plotting/pygletplot/plot_window.py b/sympy/plotting/pygletplot/plot_window.py
|
||
|
index 91bf42cc532..193093229b4 100644
|
||
|
--- a/sympy/plotting/pygletplot/plot_window.py
|
||
|
+++ b/sympy/plotting/pygletplot/plot_window.py
|
||
|
@@ -1,6 +1,6 @@
|
||
|
from __future__ import print_function, division
|
||
|
|
||
|
-from time import clock
|
||
|
+from sympy.core.compatibility import clock
|
||
|
|
||
|
import pyglet.gl as pgl
|
||
|
|
||
|
diff --git a/sympy/printing/mathml.py b/sympy/printing/mathml.py
|
||
|
index c1eba60b3d4..e5012efe74d 100644
|
||
|
--- a/sympy/printing/mathml.py
|
||
|
+++ b/sympy/printing/mathml.py
|
||
|
@@ -654,8 +654,8 @@ class MathMLPresentationPrinter(MathMLPr
|
||
|
return table
|
||
|
brac = self.dom.createElement('mfenced')
|
||
|
if self._settings["mat_delim"] == "[":
|
||
|
- brac.setAttribute('open', '[')
|
||
|
brac.setAttribute('close', ']')
|
||
|
+ brac.setAttribute('open', '[')
|
||
|
brac.appendChild(table)
|
||
|
return brac
|
||
|
|
||
|
@@ -961,8 +961,8 @@ class MathMLPresentationPrinter(MathMLPr
|
||
|
|
||
|
def _print_AccumulationBounds(self, i):
|
||
|
brac = self.dom.createElement('mfenced')
|
||
|
- brac.setAttribute('open', u'\u27e8')
|
||
|
brac.setAttribute('close', u'\u27e9')
|
||
|
+ brac.setAttribute('open', u'\u27e8')
|
||
|
brac.appendChild(self._print(i.min))
|
||
|
brac.appendChild(self._print(i.max))
|
||
|
return brac
|
||
|
@@ -1106,19 +1106,19 @@ class MathMLPresentationPrinter(MathMLPr
|
||
|
brac = self.dom.createElement('mfenced')
|
||
|
if i.start == i.end:
|
||
|
# Most often, this type of Interval is converted to a FiniteSet
|
||
|
- brac.setAttribute('open', '{')
|
||
|
brac.setAttribute('close', '}')
|
||
|
+ brac.setAttribute('open', '{')
|
||
|
brac.appendChild(self._print(i.start))
|
||
|
else:
|
||
|
- if i.left_open:
|
||
|
- brac.setAttribute('open', '(')
|
||
|
- else:
|
||
|
- brac.setAttribute('open', '[')
|
||
|
-
|
||
|
if i.right_open:
|
||
|
brac.setAttribute('close', ')')
|
||
|
else:
|
||
|
brac.setAttribute('close', ']')
|
||
|
+
|
||
|
+ if i.left_open:
|
||
|
+ brac.setAttribute('open', '(')
|
||
|
+ else:
|
||
|
+ brac.setAttribute('open', '[')
|
||
|
brac.appendChild(self._print(i.start))
|
||
|
brac.appendChild(self._print(i.end))
|
||
|
|
||
|
@@ -1128,8 +1128,8 @@ class MathMLPresentationPrinter(MathMLPr
|
||
|
def _print_Abs(self, expr, exp=None):
|
||
|
mrow = self.dom.createElement('mrow')
|
||
|
x = self.dom.createElement('mfenced')
|
||
|
- x.setAttribute('open', '|')
|
||
|
x.setAttribute('close', '|')
|
||
|
+ x.setAttribute('open', '|')
|
||
|
x.appendChild(self._print(expr.args[0]))
|
||
|
mrow.appendChild(x)
|
||
|
return mrow
|
||
|
@@ -1191,8 +1191,8 @@ class MathMLPresentationPrinter(MathMLPr
|
||
|
def _print_set(self, s):
|
||
|
items = sorted(s, key=default_sort_key)
|
||
|
brac = self.dom.createElement('mfenced')
|
||
|
- brac.setAttribute('open', '{')
|
||
|
brac.setAttribute('close', '}')
|
||
|
+ brac.setAttribute('open', '{')
|
||
|
for item in items:
|
||
|
brac.appendChild(self._print(item))
|
||
|
return brac
|
||
|
@@ -1309,8 +1309,8 @@ class MathMLPresentationPrinter(MathMLPr
|
||
|
def _print_Range(self, s):
|
||
|
dots = u"\u2026"
|
||
|
brac = self.dom.createElement('mfenced')
|
||
|
- brac.setAttribute('open', '{')
|
||
|
brac.setAttribute('close', '}')
|
||
|
+ brac.setAttribute('open', '{')
|
||
|
|
||
|
if s.start.is_infinite:
|
||
|
printset = dots, s[-1] - s.step, s[-1]
|
||
|
@@ -1507,8 +1507,8 @@ class MathMLPresentationPrinter(MathMLPr
|
||
|
power = expr.args[2]
|
||
|
sup = self.dom.createElement('msup')
|
||
|
brac = self.dom.createElement('mfenced')
|
||
|
- brac.setAttribute('open', u'\u27e8')
|
||
|
brac.setAttribute('close', u'\u27e9')
|
||
|
+ brac.setAttribute('open', u'\u27e8')
|
||
|
brac.appendChild(self._print(shift))
|
||
|
sup.appendChild(brac)
|
||
|
sup.appendChild(self._print(power))
|
||
|
@@ -1674,8 +1674,8 @@ class MathMLPresentationPrinter(MathMLPr
|
||
|
def _print_floor(self, e):
|
||
|
mrow = self.dom.createElement('mrow')
|
||
|
x = self.dom.createElement('mfenced')
|
||
|
- x.setAttribute('open', u'\u230A')
|
||
|
x.setAttribute('close', u'\u230B')
|
||
|
+ x.setAttribute('open', u'\u230A')
|
||
|
x.appendChild(self._print(e.args[0]))
|
||
|
mrow.appendChild(x)
|
||
|
return mrow
|
||
|
@@ -1683,8 +1683,8 @@ class MathMLPresentationPrinter(MathMLPr
|
||
|
def _print_ceiling(self, e):
|
||
|
mrow = self.dom.createElement('mrow')
|
||
|
x = self.dom.createElement('mfenced')
|
||
|
- x.setAttribute('open', u'\u2308')
|
||
|
x.setAttribute('close', u'\u2309')
|
||
|
+ x.setAttribute('open', u'\u2308')
|
||
|
x.appendChild(self._print(e.args[0]))
|
||
|
mrow.appendChild(x)
|
||
|
return mrow
|
||
|
@@ -1727,8 +1727,8 @@ class MathMLPresentationPrinter(MathMLPr
|
||
|
x = self.dom.createElement('msub')
|
||
|
x.appendChild(self.parenthesize(e.parent, PRECEDENCE["Atom"], strict = True))
|
||
|
brac = self.dom.createElement('mfenced')
|
||
|
- brac.setAttribute("open", "")
|
||
|
brac.setAttribute("close", "")
|
||
|
+ brac.setAttribute("open", "")
|
||
|
for i in e.indices:
|
||
|
brac.appendChild(self._print(i))
|
||
|
x.appendChild(brac)
|