Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix E721 warnings for .pyx files #36036

Merged
merged 5 commits into from
Aug 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/sage/dynamics/complex_dynamics/mandel_julia_helper.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ cpdef polynomial_mandelbrot(f, parameter=None, double x_center=0,
# Take the given base color and create a list of evenly spaced
# colors between the given base color and white. The number of
# colors in the list depends on the variable color_num.
if type(base_color) == Color:
if isinstance(base_color, Color):
# Convert Color to RGB list
base_color = [int(k*255) for k in base_color]
color_list = []
Expand Down Expand Up @@ -973,7 +973,7 @@ cpdef general_julia(f, double x_center=0, double y_center=0, image_width=4,
# Take the given base color and create a list of evenly spaced
# colors between the given base color and white. The number of
# colors in the list depends on the variable color_num.
if type(base_color) == Color:
if isinstance(base_color, Color):
# Convert Color to RGB list
base_color = [int(k*255) for k in base_color]
color_list = []
Expand Down
24 changes: 16 additions & 8 deletions src/sage/libs/coxeter3/coxeter.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,10 @@ cdef class String:
sage: all([tb > ta1, tb >= ta1, tb >= tb]) # optional - coxeter3
True
"""
if type(other) != type(self):
return False
if type(other) is not type(self):
jhpalmieri marked this conversation as resolved.
Show resolved Hide resolved
if op in (Py_LT, Py_LE, Py_GT, Py_GE):
return NotImplemented
return op == Py_NE

s = repr(self)
o = repr(other)
Expand Down Expand Up @@ -199,8 +201,10 @@ cdef class Type:
sage: all([tb > ta1, tb >= ta1, tb >= tb]) # optional - coxeter3
True
"""
if type(other) != type(self):
return False
if type(other) is not type(self):
jhpalmieri marked this conversation as resolved.
Show resolved Hide resolved
if op in (Py_LT, Py_LE, Py_GT, Py_GE):
return NotImplemented
return op == Py_NE

s = repr(self)
o = repr(other)
Expand Down Expand Up @@ -363,8 +367,10 @@ cdef class CoxGroup(SageObject):
sage: B4 >= A5 # optional - coxeter3
True
"""
if type(other) != type(self):
return False
if type(other) is not type(self):
jhpalmieri marked this conversation as resolved.
Show resolved Hide resolved
if op in (Py_LT, Py_LE, Py_GT, Py_GE):
return NotImplemented
return op == Py_NE

s_t = self.type()
o_t = other.type()
Expand Down Expand Up @@ -839,8 +845,10 @@ cdef class CoxGroupElement:
sage: w1 != v1 # optional - coxeter3
True
"""
if type(other) != type(self):
return False
if type(other) is not type(self):
jhpalmieri marked this conversation as resolved.
Show resolved Hide resolved
if op in (Py_LT, Py_LE, Py_GT, Py_GE):
return NotImplemented
return op == Py_NE

s_p = self.parent_group()
o_p = other.parent_group()
Expand Down
2 changes: 1 addition & 1 deletion src/sage/matrix/action.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ cdef class MatrixMatrixAction(MatrixMulAction):
B = B.dense_matrix()
else:
A = A.dense_matrix()
assert type(A) == type(B), (type(A), type(B))
assert type(A) is type(B), (type(A), type(B))
prod = A._matrix_times_matrix_(B)
if A._subdivisions is not None or B._subdivisions is not None:
Asubs = A.subdivisions()
Expand Down
2 changes: 1 addition & 1 deletion src/sage/matroids/extension.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ cdef class MatroidExtensions(LinearSubclasses):
"""
if M.full_rank() == 0:
pass
if type(M) == BasisMatroid:
if isinstance(M, BasisMatroid):
BM = M
else:
BM = BasisMatroid(M)
Expand Down
4 changes: 2 additions & 2 deletions src/sage/matroids/lean_matrix.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ cdef class LeanMatrix:
cdef long i
cdef LeanMatrix A
if isinstance(left, LeanMatrix):
if type(left) == type(right):
if type(left) is type(right):
return (<LeanMatrix>left)._matrix_times_matrix_(right)
else:
return NotImplemented
Expand Down Expand Up @@ -457,7 +457,7 @@ cdef class LeanMatrix:
return NotImplemented
if not isinstance(left, LeanMatrix) or not isinstance(right, LeanMatrix):
return NotImplemented
if type(left) != type(right):
if type(left) is not type(right):
return NotImplemented
if op == Py_EQ:
res = True
Expand Down
4 changes: 2 additions & 2 deletions src/sage/matroids/linear_matroid.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -4451,7 +4451,7 @@ cdef class TernaryMatroid(LinearMatroid):
"""
if certificate:
return self._is_isomorphic(other), self._isomorphism(other)
if type(other) == TernaryMatroid:
if isinstance(other, TernaryMatroid):
return self.is_field_isomorphic(other)
else:
return LinearMatroid._is_isomorphic(self, other)
Expand Down Expand Up @@ -6152,7 +6152,7 @@ cdef class RegularMatroid(LinearMatroid):
"""
if certificate:
return self._is_isomorphic(other), self._isomorphism(other)
if type(other) == RegularMatroid:
if isinstance(other, RegularMatroid):
return self.is_field_isomorphic(other)
else:
return LinearMatroid._is_isomorphic(self, other)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/numerical/backends/generic_backend.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ cdef class GenericBackend:
sage: p.add_linear_constraint([(0, 3), (1, 2)], None, 6) # optional - Nonexistent_LP_solver
sage: p.remove_constraints([0, 1]) # optional - Nonexistent_LP_solver
"""
if type(constraints) == int: self.remove_constraint(constraints)
if isinstance(constraints, int): self.remove_constraint(constraints)

cdef int last = self.nrows() + 1

Expand Down
4 changes: 2 additions & 2 deletions src/sage/rings/integer.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2852,12 +2852,12 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
except (ValueError, TypeError):
pass

if type(m) == Integer and type(self) == Integer:
if isinstance(m, Integer):
elog = self.exact_log(m)
if elog == -sage.rings.infinity.infinity or m**elog == self:
return elog

if (type(m) == Rational and type(self) == Integer
if (isinstance(m, Rational)
and m.numer() == 1):
elog = -self.exact_log(m.denom())
if m**elog == self:
Expand Down
6 changes: 3 additions & 3 deletions src/sage/rings/number_field/totallyreal.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def enumerate_totallyreal_fields_prim(n, B, a = [], verbose=0, return_seqs=False
f_out[n_int] = 1

if keep_fields:
if type(keep_fields) == bool:
if isinstance(keep_fields, bool):
keepB = pari(int(math.floor(B*math.log(B))))
else:
keepB = pari(keep_fields)
Expand Down Expand Up @@ -337,7 +337,7 @@ def enumerate_totallyreal_fields_prim(n, B, a = [], verbose=0, return_seqs=False
if verbose:
verb_int = 1
saveout = sys.stdout
if type(verbose) == str:
if isinstance(verbose, str):
fsock = open(verbose, 'w')
sys.stdout = fsock
# Else, print to screen
Expand Down Expand Up @@ -458,7 +458,7 @@ def enumerate_totallyreal_fields_prim(n, B, a = [], verbose=0, return_seqs=False
print("Polynomials with nfdisc <= B:", counts[3])
for i from 0 <= i < lenS:
print(S[i])
if type(verbose) == str:
if isinstance(verbose, str):
fsock.close()
sys.stdout = saveout

Expand Down
2 changes: 1 addition & 1 deletion src/sage/structure/category_object.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ cdef class CategoryObject(SageObject):
if self._category is None:
self._init_category_(category)
return
if not (type(category) == tuple or type(category) == list):
if not isinstance(category, (tuple, list)):
category = [category]
self._category = self._category.join([self._category]+list(category))

Expand Down