Skip to content

Commit 4764908

Browse files
Merge pull request sympy#17779 from oscarbenjamin/flake8_core
Fix import etc flake8 issues in core
2 parents 14c9bf4 + f4966fa commit 4764908

19 files changed

+48
-89
lines changed

sympy/core/expr.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,6 @@ def equals(self, other, failing_expression=False):
732732
733733
"""
734734
from sympy.simplify.simplify import nsimplify, simplify
735-
from sympy.solvers.solveset import solveset
736735
from sympy.solvers.solvers import solve
737736
from sympy.polys.polyerrors import NotAlgebraic
738737
from sympy.polys.numberfields import minimal_polynomial
@@ -2999,7 +2998,7 @@ def aseries(self, x=None, n=6, bound=0, hir=False):
29992998

30002999
from sympy import Order, Dummy
30013000
from sympy.functions import exp, log
3002-
from sympy.series.gruntz import mrv, rewrite, mrv_leadterm
3001+
from sympy.series.gruntz import mrv, rewrite
30033002

30043003
if x.is_positive is x.is_negative is None:
30053004
xpos = Dummy('x', positive=True)
@@ -3626,7 +3625,6 @@ def round(self, n=None):
36263625
>>> isinstance(round(S(123), -2), Number)
36273626
True
36283627
"""
3629-
from sympy.core.power import integer_log
36303628
from sympy.core.numbers import Float
36313629

36323630
x = self

sympy/core/function.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
from __future__ import print_function, division
3333

3434
from .add import Add
35-
from .assumptions import ManagedProperties, _assume_defined
35+
from .assumptions import ManagedProperties
3636
from .basic import Basic, _atomic
3737
from .cache import cacheit
3838
from .compatibility import iterable, is_sequence, as_int, ordered, Iterable
@@ -1237,7 +1237,7 @@ def __new__(cls, expr, *variables, **kwargs):
12371237

12381238
from sympy.matrices.common import MatrixCommon
12391239
from sympy import Integer, MatrixExpr
1240-
from sympy.tensor.array import Array, NDimArray, derive_by_array
1240+
from sympy.tensor.array import Array, NDimArray
12411241
from sympy.utilities.misc import filldedent
12421242

12431243
expr = sympify(expr)

sympy/core/power.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,12 +1149,12 @@ def as_real_imag(self, deep=True, **hints):
11491149

11501150
if self.exp.is_Integer:
11511151
exp = self.exp
1152-
re, im = self.base.as_real_imag(deep=deep)
1153-
if not im:
1152+
re_e, im_e = self.base.as_real_imag(deep=deep)
1153+
if not im_e:
11541154
return self, S.Zero
11551155
a, b = symbols('a b', cls=Dummy)
11561156
if exp >= 0:
1157-
if re.is_Number and im.is_Number:
1157+
if re_e.is_Number and im_e.is_Number:
11581158
# We can be more efficient in this case
11591159
expr = expand_multinomial(self.base**exp)
11601160
if expr != self:
@@ -1163,11 +1163,11 @@ def as_real_imag(self, deep=True, **hints):
11631163
expr = poly(
11641164
(a + b)**exp) # a = re, b = im; expr = (a + b*I)**exp
11651165
else:
1166-
mag = re**2 + im**2
1167-
re, im = re/mag, -im/mag
1168-
if re.is_Number and im.is_Number:
1166+
mag = re_e**2 + im_e**2
1167+
re_e, im_e = re_e/mag, -im_e/mag
1168+
if re_e.is_Number and im_e.is_Number:
11691169
# We can be more efficient in this case
1170-
expr = expand_multinomial((re + im*S.ImaginaryUnit)**-exp)
1170+
expr = expand_multinomial((re_e + im_e*S.ImaginaryUnit)**-exp)
11711171
if expr != self:
11721172
return expr.as_real_imag()
11731173

@@ -1182,23 +1182,23 @@ def as_real_imag(self, deep=True, **hints):
11821182
r = [i for i in expr.terms() if i[0][1] % 4 == 3]
11831183
im_part3 = Add(*[cc*a**aa*b**bb for (aa, bb), cc in r])
11841184

1185-
return (re_part.subs({a: re, b: S.ImaginaryUnit*im}),
1186-
im_part1.subs({a: re, b: im}) + im_part3.subs({a: re, b: -im}))
1185+
return (re_part.subs({a: re_e, b: S.ImaginaryUnit*im_e}),
1186+
im_part1.subs({a: re_e, b: im_e}) + im_part3.subs({a: re_e, b: -im_e}))
11871187

11881188
elif self.exp.is_Rational:
1189-
re, im = self.base.as_real_imag(deep=deep)
1189+
re_e, im_e = self.base.as_real_imag(deep=deep)
11901190

1191-
if im.is_zero and self.exp is S.Half:
1192-
if re.is_extended_nonnegative:
1191+
if im_e.is_zero and self.exp is S.Half:
1192+
if re_e.is_extended_nonnegative:
11931193
return self, S.Zero
1194-
if re.is_extended_nonpositive:
1194+
if re_e.is_extended_nonpositive:
11951195
return S.Zero, (-self.base)**self.exp
11961196

11971197
# XXX: This is not totally correct since for x**(p/q) with
11981198
# x being imaginary there are actually q roots, but
11991199
# only a single one is returned from here.
1200-
r = self.func(self.func(re, 2) + self.func(im, 2), S.Half)
1201-
t = atan2(im, re)
1200+
r = self.func(self.func(re_e, 2) + self.func(im_e, 2), S.Half)
1201+
t = atan2(im_e, re_e)
12021202

12031203
rp, tp = self.func(r, self.exp), t*self.exp
12041204

sympy/core/tests/test_args.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,6 @@ def test_sympy__sets__fancysets__ComplexRegion():
936936

937937
def test_sympy__sets__fancysets__CartesianComplexRegion():
938938
from sympy.sets.fancysets import CartesianComplexRegion
939-
from sympy import S
940939
from sympy.sets import Interval
941940
a = Interval(0, 1)
942941
b = Interval(2, 3)
@@ -1572,7 +1571,6 @@ def test_sympy__stats__joint_rv_types__NegativeMultinomialDistribution():
15721571

15731572
def test_sympy__stats__rv__RandomIndexedSymbol():
15741573
from sympy.stats.rv import RandomIndexedSymbol, pspace
1575-
from sympy.tensor import Indexed
15761574
from sympy.stats.stochastic_process_types import DiscreteMarkovChain
15771575
X = DiscreteMarkovChain("X")
15781576
assert _test_args(RandomIndexedSymbol(X[0].symbol, pspace(X[0])))
@@ -1619,7 +1617,6 @@ def test_sympy__stats__stochastic_process_types__GeneratorMatrixOf():
16191617

16201618
def test_sympy__stats__stochastic_process_types__StochasticStateSpaceOf():
16211619
from sympy.stats.stochastic_process_types import StochasticStateSpaceOf, DiscreteMarkovChain
1622-
from sympy import MatrixSymbol
16231620
DMC = DiscreteMarkovChain("Y")
16241621
assert _test_args(StochasticStateSpaceOf(DMC, [0, 1, 2]))
16251622

@@ -3862,7 +3859,6 @@ def test_sympy__physics__units__dimensions__DimensionSystem():
38623859

38633860
def test_sympy__physics__units__quantities__Quantity():
38643861
from sympy.physics.units.quantities import Quantity
3865-
from sympy.physics.units import length
38663862
assert _test_args(Quantity("dam"))
38673863

38683864

sympy/core/tests/test_arit.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from sympy import (Basic, Symbol, sin, cos, atan, exp, sqrt, Rational,
22
Float, re, pi, sympify, Add, Mul, Pow, Mod, I, log, S, Max, symbols,
3-
oo, zoo, Integer, sign, im, nan, Dummy, factorial, comp, refine,
4-
floor
3+
oo, zoo, Integer, sign, im, nan, Dummy, factorial, comp, floor
54
)
65
from sympy.core.compatibility import long, range
76
from sympy.core.evaluate import distribute

sympy/core/tests/test_assumptions.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,6 @@ def test_Pow_is_algebraic():
852852

853853

854854
def test_Mul_is_prime_composite():
855-
from sympy import Mul
856855
x = Symbol('x', positive=True, integer=True)
857856
y = Symbol('y', positive=True, integer=True)
858857
assert (x*y).is_prime is None
@@ -890,7 +889,6 @@ def test_Pow_is_pos_neg():
890889
assert (x**y).is_negative is False
891890

892891
def test_Pow_is_prime_composite():
893-
from sympy import Pow
894892
x = Symbol('x', positive=True, integer=True)
895893
y = Symbol('y', positive=True, integer=True)
896894
assert (x**y).is_prime is None

sympy/core/tests/test_complex.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from sympy import (S, Symbol, sqrt, I, Integer, Rational, cos, sin, im, re, Abs,
22
exp, sinh, cosh, tan, tanh, conjugate, sign, cot, coth, pi, symbols,
33
expand_complex, Pow)
4-
from sympy.core.expr import unchanged
54

65
def test_complex():
76
a = Symbol("a", real=True)

sympy/core/tests/test_diff.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@
55
from sympy.core.relational import Eq
66
from sympy.core.singleton import S
77
from sympy.core.symbol import Symbol
8-
from sympy.functions.combinatorial.factorials import (FallingFactorial,
9-
factorial)
8+
from sympy.functions.combinatorial.factorials import factorial
109
from sympy.functions.elementary.complexes import (im, re)
1110
from sympy.functions.elementary.exponential import (exp, log)
1211
from sympy.functions.elementary.miscellaneous import Max
1312
from sympy.functions.elementary.piecewise import Piecewise
1413
from sympy.functions.elementary.trigonometric import (cos, cot, sin, tan)
15-
from sympy.logic.boolalg import And
1614
from sympy.tensor.array.ndim_array import NDimArray
1715
from sympy.utilities.pytest import raises
1816
from sympy.abc import a, b, c, x, y, z

sympy/core/tests/test_evalf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
factorial, fibonacci, floor, Function, GoldenRatio, I, Integral,
33
integrate, log, Mul, N, oo, pi, Pow, product, Product,
44
Rational, S, Sum, simplify, sin, sqrt, sstr, sympify, Symbol, Max, nfloat, cosh, acosh, acos)
5-
from sympy.core.numbers import comp, Rational
5+
from sympy.core.numbers import comp
66
from sympy.core.evalf import (complex_accuracy, PrecisionExhausted,
77
scaled_zero, get_integer_part, as_mpmath, evalf)
88
from mpmath import inf, ninf

sympy/core/tests/test_expr.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
simplify, together, collect, factorial, apart, combsimp, factor, refine,
66
cancel, Tuple, default_sort_key, DiracDelta, gamma, Dummy, Sum, E,
77
exp_polar, expand, diff, O, Heaviside, Si, Max, UnevaluatedExpr,
8-
integrate, gammasimp, Gt, cot)
8+
integrate, gammasimp, Gt)
99
from sympy.core.expr import ExprBuilder, unchanged
1010
from sympy.core.function import AppliedUndef
1111
from sympy.core.compatibility import range, round, PY3
@@ -132,9 +132,9 @@ def __float__(self):
132132

133133

134134
def dotest(s):
135-
for x in all_objs:
136-
for y in all_objs:
137-
s(x, y)
135+
for xo in all_objs:
136+
for yo in all_objs:
137+
s(xo, yo)
138138
return True
139139

140140

@@ -148,6 +148,7 @@ def j(a, b):
148148
x = a*b
149149
x = a/b
150150
x = a**b
151+
del x
151152
assert dotest(j)
152153

153154

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy