Skip to content

Commit

Permalink
sagemathgh-39354: some fixes for PLR1716
Browse files Browse the repository at this point in the history
    
which is about using the syntax `a < b < c` when possible

### 📝 Checklist

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
    
URL: sagemath#39354
Reported by: Frédéric Chapoton
Reviewer(s): Martin Rubey
  • Loading branch information
Release Manager committed Jan 25, 2025
2 parents 5e24e77 + f6311ca commit e4b5a13
Show file tree
Hide file tree
Showing 16 changed files with 30 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/sage/combinat/composition_tableau.py
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ def _rec(self, obj, state):
# We check to make sure that k does not violate the Triple Rule
if j != 0 and i != 0 and any(k == obj_copy[m][j] for m in range(i)):
continue
if j != 0 and i != 0 and any(obj_copy[m][j] < k and k <= obj_copy[m][j - 1]
if j != 0 and i != 0 and any(obj_copy[m][j] < k <= obj_copy[m][j - 1]
for m in range(i)):
continue

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,7 @@ def three_factor_product(k, n1, n2, n3, check=False, explain_construction=False)
Rolf S. Rees,
Journal of Combinatorial Designs 1.1 (1993): 15-26.
"""
assert n1 <= n2 and n2 <= n3
assert n1 <= n2 <= n3

if explain_construction:
return ("Three-factor product with n={}.{}.{} from:\n" +
Expand Down
7 changes: 3 additions & 4 deletions src/sage/combinat/gray_codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,12 @@ def combinations(n, t):
n = int(n)
else:
n = Infinity
assert 0 <= t and t <= n, "t(={}) must be >=0 and <=n(={})".format(t,n)
assert 0 <= t <= n, "t(={}) must be >=0 and <=n(={})".format(t, n)
if t == 0 or t == n:
return iter([])
if t % 2:
return _revolving_door_odd(n,t)
else:
return _revolving_door_even(n,t)
return _revolving_door_odd(n, t)
return _revolving_door_even(n, t)


def _revolving_door_odd(n, t):
Expand Down
10 changes: 5 additions & 5 deletions src/sage/combinat/ncsf_qsym/combinatorics.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,11 @@ def number_of_SSRCT(content_comp, shape_comp):
else:
return ZZ.zero()
s = ZZ.zero()
cond = lambda al,be: all(al[j] <= be_val
and not any(al[i] <= k and k <= be[i]
for k in range(al[j], be_val)
for i in range(j))
for j, be_val in enumerate(be))
cond = lambda al, be: all(al[j] <= be_val
and not any(al[i] <= k <= be[i]
for k in range(al[j], be_val)
for i in range(j))
for j, be_val in enumerate(be))
C = Compositions(content_comp.size()-content_comp[0],
inner=[1]*len(shape_comp),
outer=list(shape_comp))
Expand Down
8 changes: 4 additions & 4 deletions src/sage/combinat/permutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2121,13 +2121,13 @@ def _icondition(self, i):
pos_ip1 = self.index(i + 1)
pos_im1 = self.index(i - 1)

if pos_i < pos_im1 and pos_im1 < pos_ip1:
if pos_i < pos_im1 < pos_ip1:
state = '213'
elif pos_im1 < pos_ip1 and pos_ip1 < pos_i:
elif pos_im1 < pos_ip1 < pos_i:
state = '132'
elif pos_i < pos_ip1 and pos_ip1 < pos_im1:
elif pos_i < pos_ip1 < pos_im1:
state = '231'
elif pos_ip1 < pos_im1 and pos_im1 < pos_i:
elif pos_ip1 < pos_im1 < pos_i:
state = '312'
else:
state = None
Expand Down
2 changes: 1 addition & 1 deletion src/sage/functions/spike_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def _eval(self, x):
x = float(x)
for i in range(len(self.support)):
z = self.support[i]
if z - eps <= x and x <= z + eps:
if z - eps <= x <= z + eps:
return self.height[i], i
return float(0), -1

Expand Down
2 changes: 1 addition & 1 deletion src/sage/graphs/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -5500,7 +5500,7 @@ def twograph(self):
# Triangles
K3 = Graph({1: [2, 3], 2: [3]}, format='dict_of_lists')
for x, y, z in G.subgraph_search_iterator(K3, return_graphs=False):
if x < y and y < z:
if x < y < z:
T.append([x, y, z])

# Triples with just one edge
Expand Down
2 changes: 1 addition & 1 deletion src/sage/graphs/graph_latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,7 @@ def set_option(self, option_name, option_value=None):
raise TypeError('%s option must be a dictionary, not %s' % (name, value))
else:
for key, p in value.items():
if not (type(p) in [float, RealLiteral] and (0 <= p) and (p <= 1)) and (p not in label_places):
if not (isinstance(p, (float, RealLiteral)) and (0 <= p <= 1)) and (p not in label_places):
raise ValueError('%s option for %s needs to be a number between 0.0 and 1.0 or a place (like "above"), not %s' % (name, key, p))
elif name == 'loop_placements':
if not isinstance(value, dict):
Expand Down
2 changes: 1 addition & 1 deletion src/sage/graphs/isgci.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ def __eq__(self, other):
sage: graph_classes.Chordal == graph_classes.Tree
Unknown
"""
return self >= other and other >= self
return self >= other >= self

def __lt__(self, other):
r"""
Expand Down
2 changes: 1 addition & 1 deletion src/sage/groups/abelian_gps/abelian_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -1861,7 +1861,7 @@ def equals(left, right):
return left.is_isomorphic(right)
if left_ambient is not right_ambient:
return False
return left <= right and right <= left
return left <= right <= left

__eq__ = equals

Expand Down
2 changes: 1 addition & 1 deletion src/sage/matrix/symplectic_basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def _smallest_element_position_or_None(E, pivot):
for i in range(pivot, n):
for j in range(pivot, n):
v = E[j, i]
if 0 < v and v < min:
if 0 < v < min:
min = v
found = (j, i)
return found
Expand Down
6 changes: 3 additions & 3 deletions src/sage/plot/arc.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,9 @@ def get_minmax_data(self):

if s < twopi - epsilon: # bb determined by the sector
def is_cyclic_ordered(x1, x2, x3):
return ((x1 < x2 and x2 < x3) or
(x2 < x3 and x3 < x1) or
(x3 < x1 and x1 < x2))
return ((x1 < x2 < x3) or
(x2 < x3 < x1) or
(x3 < x1 < x2))

x1 = cos_angle * r1 * cos(s1) - sin_angle * r2 * sin(s1)
x2 = cos_angle * r1 * cos(s2) - sin_angle * r2 * sin(s2)
Expand Down
4 changes: 2 additions & 2 deletions src/sage/rings/number_field/bdd_height.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,8 +608,8 @@ def packet_height(n, pair, u):
u_height = sum([max(u_log[k], 0) for k in range(r + 1)])
unit_height_dict[u] = u_height
if u_height < inter_bound:
U0.append(u)
if inter_bound <= u_height and u_height < b - (t/12):
U0.append(u)
if inter_bound <= u_height < b - (t/12):
U0_tilde.append(u)
if u_height > t/12 + d_tilde:
U_copy.remove(u)
Expand Down
4 changes: 2 additions & 2 deletions src/sage/schemes/elliptic_curves/ell_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -2579,9 +2579,9 @@ class of curves. If the j-invariant is not unique in the isogeny
A = [] # adjacency matrix
labels = [] # list of vertex labels
for (i, E) in enumerate(Es):
if 0 < curve_max and curve_max < len(Es):
if 0 < curve_max < len(Es):
warn('Isogeny graph contains more than '
+ str(curve_max) + ' curves.')
+ str(curve_max) + ' curves.')
curve_max = 0

r = [0] * len(Es) # adjacency matrix row
Expand Down
2 changes: 1 addition & 1 deletion src/sage/schemes/hyperelliptic_curves/monsky_washnitzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2596,7 +2596,7 @@ def monomial(self, i, j, b=None):
i = int(i)
j = int(j)

if 0 < i and i < self._n:
if 0 < i < self._n:
if b is None:
by_to_j = self._series_ring_y << (j - 1)
else:
Expand Down
4 changes: 2 additions & 2 deletions src/sage/sets/integer_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -748,8 +748,8 @@ def __contains__(self, elt):
except (TypeError, ValueError):
return False
if abs(self._step).divides(Integer(elt)-self._middle_point):
return (self._begin <= elt and elt < self._end) or \
(self._begin >= elt and elt > self._end)
return (self._begin <= elt < self._end) or \
(self._begin >= elt > self._end)
return False

def next(self, elt):
Expand Down

0 comments on commit e4b5a13

Please sign in to comment.