Skip to content
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
10 changes: 5 additions & 5 deletions src/sage/calculus/calculus.py
Original file line number Diff line number Diff line change
Expand Up @@ -2497,7 +2497,7 @@ def symbolic_expression_from_maxima_string(x, equals_sub=False, maxima=maxima):
maxima.set('_tmp_', x)

# This is inefficient since it so rarely is needed:
#r = maxima._eval_line('listofvars(_tmp_);')[1:-1]
# r = maxima._eval_line('listofvars(_tmp_);')[1:-1]

s = maxima._eval_line('_tmp_;')

Expand All @@ -2509,10 +2509,10 @@ def symbolic_expression_from_maxima_string(x, equals_sub=False, maxima=maxima):
# there is a potential very subtle bug if 'foo is in a string
# literal -- but string literals should *never* ever be part of a
# symbolic expression.
s = s.replace("'","")
s = s.replace("'", "")

delayed_functions = maxima_qp.findall(s)
if len(delayed_functions):
if delayed_functions:
for X in delayed_functions:
if X == '?%at': # we will replace Maxima's "at" with symbolic evaluation, not a SymbolicFunction
pass
Expand All @@ -2537,8 +2537,8 @@ def symbolic_expression_from_maxima_string(x, equals_sub=False, maxima=maxima):
s = s.replace("%","")

s = s.replace("#","!=") # a lot of this code should be refactored somewhere...
#we apply the square-bracket replacing patterns repeatedly
#to ensure that nested brackets get handled (from inside to out)
# we apply the square-bracket replacing patterns repeatedly
# to ensure that nested brackets get handled (from inside to out)
while True:
olds = s
s = polylog_ex.sub('polylog(\\1,', s)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/coding/codecan/codecan.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ cdef class InnerGroup:

d, _ = self.minimize_by_row_mult(factor * act_col)
d.pop(first_nz_rep)
if len(d): # there is at least one more multiplication
if d: # there is at least one more multiplication
group_changed[0] = True
for i in range(self.rank):
factor = d.get(self.get_rep(i))
Expand Down
4 changes: 2 additions & 2 deletions src/sage/data_structures/bounded_integer_sequences.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1388,7 +1388,7 @@ def _biseq_stresstest():
L[randint(0, 99)] = L[randint(0, 99)] + L[randint(0, 99)]
elif branch == 1:
x = randint(0, 99)
if len(L[x]):
if L[x]:
y = randint(0, len(L[x]) - 1)
z = randint(y, len(L[x]) - 1)
L[randint(0, 99)] = L[x][y:z]
Expand All @@ -1400,7 +1400,7 @@ def _biseq_stresstest():
t = L[randint(0, 99)].list()
elif branch == 3:
x = randint(0, 99)
if len(L[x]):
if L[x]:
y = randint(0, len(L[x])-1)
t = L[x][y]
try:
Expand Down
8 changes: 4 additions & 4 deletions src/sage/databases/findstat.py
Original file line number Diff line number Diff line change
Expand Up @@ -2802,7 +2802,7 @@ def __init__(self, id, domain=None, check=True):
FindStatCombinatorialStatistic.__init__(self)
Element.__init__(self, FindStatStatistics()) # this is not completely correct, but it works

def _fetch_first_terms_raw(self):
def _fetch_first_terms_raw(self) -> list:
r"""
Return the first terms of the compound statistic, as ``(string,
value)`` pairs, fetched from FindStat.
Expand All @@ -2817,7 +2817,7 @@ def _fetch_first_terms_raw(self):
"""
fields = "Values"
url = FINDSTAT_API_STATISTICS + self.id_str() + "?fields=" + fields
if len(self._maps):
if self._maps:
values = _get_json(url)["included"]["CompoundStatistics"][self.id_str()]["Values"]
else:
values = _get_json(url)["included"]["Statistics"][self.id_str()]["Values"]
Expand Down Expand Up @@ -2851,7 +2851,7 @@ def __call__(self, elt):
"""
return self.statistic()(self.compound_map()(elt))

def id_str(self):
def id_str(self) -> str:
"""
Return the padded identifier of the compound statistic.

Expand All @@ -2862,7 +2862,7 @@ def id_str(self):
"""
return self._id

def _repr_(self):
def _repr_(self) -> str:
"""
Return a string representation of the compound statistic.

Expand Down
8 changes: 4 additions & 4 deletions src/sage/geometry/lattice_polytope.py
Original file line number Diff line number Diff line change
Expand Up @@ -5060,7 +5060,7 @@ def _palp(command, polytopes, reduce_dimension=False):
for p in polytopes:
if p.dim() == 0:
raise ValueError(("Cannot run \"%s\" for the zero-dimensional "
+ "polytope!\nPolytope: %s") % (command, p))
+ "polytope!\nPolytope: %s") % (command, p))
if p.dim() < p.lattice_dim():
if not reduce_dimension:
raise ValueError(("Cannot run PALP for a %d-dimensional polytope " +
Expand All @@ -5075,9 +5075,9 @@ def _palp(command, polytopes, reduce_dimension=False):
stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True)
stderr = p.stderr
err = stderr.read()
if len(err):
if err:
raise RuntimeError(("Error executing \"%s\" for a polytope sequence!"
+ "\nOutput:\n%s") % (command, err))
+ "\nOutput:\n%s") % (command, err))
os.remove(input_file_name)
try:
p.terminate()
Expand All @@ -5086,7 +5086,7 @@ def _palp(command, polytopes, reduce_dimension=False):
return output_file_name


def _palp_canonical_order(V, PM_max, permutations):
def _palp_canonical_order(V, PM_max, permutations) -> tuple:
r"""
Compute the PALP normal form of the vertices V
using auxiliary data computed elsewhere.
Expand Down
9 changes: 5 additions & 4 deletions src/sage/schemes/elliptic_curves/cm.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ def cm_orders(h, proof=None):
# WAS extracted this by cutting/pasting from the pdf, and running this program:
# z = {}
# for X in open('/Users/wstein/tmp/a.txt').readlines():
# if len(X.strip()):
# if X.strip():
# v = [int(a) for a in X.split()]
# for i in range(5):
# z[v[3*i]]=(v[3*i+2], v[3*i+1])
Expand Down Expand Up @@ -575,7 +575,7 @@ def cm_orders(h, proof=None):

# klaise_table = {}
# for X in open('klaise_table.txt').readlines():
# if len(X.strip()):
# if X.strip():
# v = [int(a) for a in X.split()]
# for i in range(4):
# klaise_table[v[3*i]]=(v[3*i+2], v[3*i+1])
Expand Down Expand Up @@ -888,7 +888,8 @@ def discriminants_with_bounded_class_number(hmax, B=None, proof=None):

@cached_function
def is_cm_j_invariant(j, algorithm='CremonaSutherland', method=None):
r"""Return whether or not this is a CM `j`-invariant, and the CM discriminant if it is.
r"""
Return whether or not this is a CM `j`-invariant, and the CM discriminant if it is.

INPUT:

Expand All @@ -910,7 +911,7 @@ def is_cm_j_invariant(j, algorithm='CremonaSutherland', method=None):
ALGORITHM:

The default algorithm used is to test whether the minimal
polynomial of ``j`` is a Hilbert CLass Polynomail, using
polynomial of ``j`` is a Hilbert CLass Polynomial, using
:func:`is_HCP` which implements Algorithm 2 of [CreSuth2023]_ by
Cremona and Sutherland.

Expand Down
2 changes: 1 addition & 1 deletion src/sage/symbolic/ginac/inifcns_comb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ static ex binomial_evalf(const ex & x, const ex & y, PyObject* parent)
return binomial(x, y).hold();
}

// At the moment the numeric evaluation of a binomail function always
// At the moment the numeric evaluation of a binomial function always
// gives a real number, but if this would be implemented using the gamma
// function, also complex conjugation should be changed (or rather, deleted).
static ex binomial_conjugate(const ex & x, const ex & y)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/symbolic/relation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1415,7 +1415,7 @@
return any(isinstance(a, GenericDeclaration) and a.has(v) and
a._assumption in ['even', 'odd', 'integer', 'integervalued']
for a in alist)
if len(f.variables()) and all(has_integer_assumption(var) for var in f.variables()):
if f.variables() and all(has_integer_assumption(var) for var in f.variables()):
return f.solve_diophantine(x, solution_dict=solution_dict)

if algorithm == 'sympy':
Expand Down Expand Up @@ -1623,7 +1623,7 @@

We can solve with respect to a bigger modulus if it consists only of small prime factors::

sage: [d] = solve_mod([5*x + y == 3, 2*x - 3*y == 9], 3*5*7*11*19*23*29, solution_dict = True)

Check warning on line 1626 in src/sage/symbolic/relation.py

View workflow job for this annotation

GitHub Actions / Conda (macos, Python 3.13, all)

Warning: slow doctest:

slow doctest:: Test ran for 13.80s cpu, 24.13s wall Check ran for 0.00s cpu, 0.00s wall

Check warning on line 1626 in src/sage/symbolic/relation.py

View workflow job for this annotation

GitHub Actions / Conda (macos, Python 3.12, all)

Warning: slow doctest:

slow doctest:: Test ran for 15.55s cpu, 22.61s wall Check ran for 0.00s cpu, 0.00s wall
sage: d[x]
12915279
sage: d[y]
Expand Down Expand Up @@ -1670,7 +1670,7 @@
sage: solve_mod([2*x^2 + x*y, -x*y+2*y^2+x-2*y, -2*x^2+2*x*y-y^2-x-y], 12)
[(0, 0), (4, 4), (0, 3), (4, 7)]
sage: eqs = [-y^2+z^2, -x^2+y^2-3*z^2-z-1, -y*z-z^2-x-y+2, -x^2-12*z^2-y+z]
sage: solve_mod(eqs, 11)

Check warning on line 1673 in src/sage/symbolic/relation.py

View workflow job for this annotation

GitHub Actions / Conda (macos, Python 3.13, all)

Warning: slow doctest:

slow doctest:: Test ran for 15.30s cpu, 24.94s wall Check ran for 0.00s cpu, 0.00s wall

Check warning on line 1673 in src/sage/symbolic/relation.py

View workflow job for this annotation

GitHub Actions / Conda (macos, Python 3.12, all)

Warning: slow doctest:

slow doctest:: Test ran for 17.15s cpu, 30.02s wall Check ran for 0.00s cpu, 0.00s wall
[(8, 5, 6)]

Confirm that modulus 1 now behaves as it should::
Expand Down Expand Up @@ -1789,7 +1789,7 @@
Confirm we can reproduce the first few terms of :oeis:`A187719`::

sage: from sage.symbolic.relation import _solve_mod_prime_power
sage: [sorted(_solve_mod_prime_power([x^2==41], 10, i, [x]))[0][0] for i in [1..13]]

Check warning on line 1792 in src/sage/symbolic/relation.py

View workflow job for this annotation

GitHub Actions / Conda (macos, Python 3.13, all)

Warning: slow doctest:

slow doctest:: Test ran for 18.31s cpu, 25.53s wall Check ran for 0.00s cpu, 0.00s wall

Check warning on line 1792 in src/sage/symbolic/relation.py

View workflow job for this annotation

GitHub Actions / Conda (macos, Python 3.12, all)

Warning: slow doctest:

slow doctest:: Test ran for 20.13s cpu, 30.75s wall Check ran for 0.00s cpu, 0.00s wall
[1, 21, 71, 1179, 2429, 47571, 1296179, 8703821, 26452429, 526452429,
13241296179, 19473547571, 2263241296179]
"""
Expand Down
2 changes: 1 addition & 1 deletion src/sage/topology/simplicial_complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -2198,7 +2198,7 @@ def chain_complex(self, subcomplex=None, augmented=False,
# nonzero via a dictionary.
matrix_data = {}
col = 0
if len(old) and len(current):
if old and current:
for simplex in current:
for i in range(n + 1):
face_i = simplex.face(i)
Expand Down
Loading