]> git.pld-linux.org Git - packages/python-sympy.git/blob - 0001-Modify-literal-comparisons-as-per-python3.8-guidelines.patch
- test suite fixes
[packages/python-sympy.git] / 0001-Modify-literal-comparisons-as-per-python3.8-guidelines.patch
1 From af7fab8860ee152a51b7c29a197b4a37b2f88a87 Mon Sep 17 00:00:00 2001
2 From: Vighnesh Shenoy <vighneshq@gmail.com>
3 Date: Fri, 7 Jun 2019 02:31:23 +0530
4 Subject: [PATCH] Modify literal comparisons as per python3.8 guidelines
5
6 This is in regards to issue  #16973, Python 3.8 beta raises a warning
7 when comparing with string, int literals using is. The .travis.yml compileall
8 command has been added another flag to error if the convention is not followed.
9 A dummy test has been added in utilities/tests, this must cause the travis
10 build to fail in 3.8. If it does as expected, it can be removed, else the
11 compileall command will have to be changed.
12 ---
13  .travis.yml                          | 5 ++++-
14  sympy/core/tests/test_containers.py  | 2 +-
15  sympy/geometry/tests/test_plane.py   | 2 +-
16  sympy/physics/vector/printing.py     | 2 +-
17  sympy/plotting/plot.py               | 6 +++---
18  sympy/polys/agca/modules.py          | 4 ++--
19  sympy/solvers/diophantine.py         | 2 +-
20  sympy/utilities/tests/test_travis.py | 6 ++++++
21  sympy/vector/coordsysrect.py         | 4 ++--
22  9 files changed, 21 insertions(+), 12 deletions(-)
23  create mode 100644 sympy/utilities/tests/test_travis.py
24
25 diff --git a/sympy/core/tests/test_containers.py b/sympy/core/tests/test_containers.py
26 index 79e3c9b85ba..af871de597a 100644
27 --- a/sympy/core/tests/test_containers.py
28 +++ b/sympy/core/tests/test_containers.py
29 @@ -52,7 +52,7 @@ def test_Tuple_concatenation():
30  
31  
32  def test_Tuple_equality():
33 -    assert Tuple(1, 2) is not (1, 2)
34 +    assert not isinstance(Tuple(1, 2), tuple)
35      assert (Tuple(1, 2) == (1, 2)) is True
36      assert (Tuple(1, 2) != (1, 2)) is False
37      assert (Tuple(1, 2) == (1, 3)) is False
38 diff --git a/sympy/geometry/tests/test_plane.py b/sympy/geometry/tests/test_plane.py
39 index dec80b4bb99..959b9ff546a 100644
40 --- a/sympy/geometry/tests/test_plane.py
41 +++ b/sympy/geometry/tests/test_plane.py
42 @@ -187,7 +187,7 @@ def test_plane():
43      assert pl8.intersection(Plane(p1, normal_vector=(-1, -1, -11)))[0].equals(
44          Line3D(p1, direction_ratio=(1, -1, 0)))
45      assert pl3.random_point() in pl3
46 -    assert len(pl8.intersection(Ray3D(Point3D(0, 2, 3), Point3D(1, 0, 3)))) is 0
47 +    assert len(pl8.intersection(Ray3D(Point3D(0, 2, 3), Point3D(1, 0, 3)))) == 0
48      # check if two plane are equals
49      assert pl6.intersection(pl6)[0].equals(pl6)
50      assert pl8.equals(Plane(p1, normal_vector=(0, 12, 0))) is False
51 diff --git a/sympy/physics/vector/printing.py b/sympy/physics/vector/printing.py
52 index 9d1e769a700..86f4159974a 100644
53 --- a/sympy/physics/vector/printing.py
54 +++ b/sympy/physics/vector/printing.py
55 @@ -152,7 +152,7 @@ class VectorLatexPrinter(LatexPrinter):
56              base = r"\ddddot{%s}" % base
57          else: # Fallback to standard printing
58              return LatexPrinter().doprint(der_expr)
59 -        if len(base_split) is not 1:
60 +        if len(base_split) != 1:
61              base += '_' + base_split[1]
62          return base
63  
64 diff --git a/sympy/plotting/plot.py b/sympy/plotting/plot.py
65 index 7ad4f550b2f..8d87b93be92 100644
66 --- a/sympy/plotting/plot.py
67 +++ b/sympy/plotting/plot.py
68 @@ -506,7 +506,7 @@ class LineOver1DRangeSeries(Line2DBaseSe
69                  #at both ends. If there is a real value in between, then
70                  #sample those points further.
71                  elif p[1] is None and q[1] is None:
72 -                    if self.xscale is 'log':
73 +                    if self.xscale == 'log':
74                          xarray = np.logspace(p[0],q[0], 10)
75                      else:
76                          xarray = np.linspace(p[0], q[0], 10)
77 @@ -539,14 +539,14 @@ class LineOver1DRangeSeries(Line2DBaseSe
78      def get_points(self):
79          np = import_module('numpy')
80          if self.only_integers is True:
81 -            if self.xscale is 'log':
82 +            if self.xscale == 'log':
83                  list_x = np.logspace(int(self.start), int(self.end),
84                          num=int(self.end) - int(self.start) + 1)
85              else:
86                  list_x = np.linspace(int(self.start), int(self.end),
87                      num=int(self.end) - int(self.start) + 1)
88          else:
89 -            if self.xscale is 'log':
90 +            if self.xscale == 'log':
91                  list_x = np.logspace(self.start, self.end, num=self.nb_of_points)
92              else:
93                  list_x = np.linspace(self.start, self.end, num=self.nb_of_points)
94 diff --git a/sympy/polys/agca/modules.py b/sympy/polys/agca/modules.py
95 index aa296c52314..88e1618be11 100644
96 --- a/sympy/polys/agca/modules.py
97 +++ b/sympy/polys/agca/modules.py
98 @@ -26,7 +26,7 @@ from sympy.polys.agca.ideals import Idea
99  from sympy.polys.domains.field import Field
100  from sympy.polys.orderings import ProductOrder, monomial_key
101  from sympy.polys.polyerrors import CoercionFailed
102 -
103 +from sympy.core.basic import _aresame
104  
105  # TODO
106  # - module saturation
107 @@ -357,7 +357,7 @@ class FreeModule(Module):
108              if len(tpl) != self.rank:
109                  raise CoercionFailed
110              return FreeModuleElement(self, tpl)
111 -        elif elem is 0:
112 +        elif _aresame(elem, 0):
113              return FreeModuleElement(self, (self.ring.convert(0),)*self.rank)
114          else:
115              raise CoercionFailed
116 diff --git a/sympy/solvers/diophantine.py b/sympy/solvers/diophantine.py
117 index 1c048d1e57d..2772b08e930 100644
118 --- a/sympy/solvers/diophantine.py
119 +++ b/sympy/solvers/diophantine.py
120 @@ -3183,7 +3183,7 @@ def power_representation(n, p, k, zeros=
121              '''Todd G. Will, "When Is n^2 a Sum of k Squares?", [online].
122                  Available: https://www.maa.org/sites/default/files/Will-MMz-201037918.pdf'''
123              return
124 -        if feasible is 1:  # it's prime and k == 2
125 +        if feasible is not True:  # it's prime and k == 2
126              yield prime_as_sum_of_two_squares(n)
127              return
128  
129 diff --git a/sympy/utilities/tests/test_travis.py b/sympy/utilities/tests/test_travis.py
130 new file mode 100644
131 index 00000000000..f49eaa0cad1
132 --- /dev/null
133 +++ b/sympy/utilities/tests/test_travis.py
134 @@ -0,0 +1,6 @@
135 +def test_travis_issue_16986():
136 +    # If this causes the travis build to fail with Python3.8,
137 +    # then the changes made in PR #16986 are working as
138 +    # intended, and this file can be deleted.
139 +
140 +    assert int(1) is 1
141 diff --git a/sympy/vector/coordsysrect.py b/sympy/vector/coordsysrect.py
142 index a7b0e91c413..e629824c3cd 100644
143 --- a/sympy/vector/coordsysrect.py
144 +++ b/sympy/vector/coordsysrect.py
145 @@ -167,9 +167,9 @@ class CoordSys3D(Basic):
146              if isinstance(transformation, Lambda):
147                  variable_names = ["x1", "x2", "x3"]
148              elif isinstance(transformation, Symbol):
149 -                if transformation.name is 'spherical':
150 +                if transformation.name == 'spherical':
151                      variable_names = ["r", "theta", "phi"]
152 -                elif transformation.name is 'cylindrical':
153 +                elif transformation.name == 'cylindrical':
154                      variable_names = ["r", "theta", "z"]
155                  else:
156                      variable_names = ["x", "y", "z"]
This page took 0.083692 seconds and 3 git commands to generate.