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

Ruff fix1 #11

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions darmonpoints/arithgroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,7 @@ def element_of_norm(
self, N, use_magma=True, return_all=False, radius=-1, max_elements=-1
): # in rationalquaternion
N = ZZ(N)
force_sign = not "P" in self._grouptype
force_sign = "P" not in self._grouptype
if use_magma:
# assert return_all == False
elt_magma = self._O_magma.ElementOfNorm(N * self._F_magma.Integers())
Expand Down Expand Up @@ -1978,7 +1978,7 @@ def element_of_norm(
N = N.gens_reduced()[0]
except AttributeError:
pass
force_sign = not "P" in self._grouptype
force_sign = "P" not in self._grouptype
if return_all and radius < 0 and max_elements < 0:
raise ValueError("Radius must be positive")

Expand Down Expand Up @@ -2724,8 +2724,8 @@ def _generators_auxiliary(self):
)
if (
not h == 1
and not h in small_gens_matrices_dict
and not hinv in small_gens_matrices_dict
and h not in small_gens_matrices_dict
and hinv not in small_gens_matrices_dict
):
## This is new. Add h to the dictionary and add one to the index for next time
small_gens_matrices_dict[h] = current_index
Expand Down
2 changes: 1 addition & 1 deletion darmonpoints/arithgroup_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ def compute_cusp_stabiliser(self, cusp_matrix):
gen = T_conj

## Now take successive powers until the result is in Gamma_0(N)
while not gen[1][0] in N_ideal:
while gen[1][0] not in N_ideal:
gen *= T_conj

## We've found an element in Stab_Gamma(cusp): add to our list of generators
Expand Down
2 changes: 1 addition & 1 deletion darmonpoints/arithgroup_nscartan.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ def get_word_rep(self, delta):
delta0 = delta
q = self.q
i = 0
while not delta0 in self._Gamma:
while delta0 not in self._Gamma:
i += 1
delta0 *= self.extra_matrix_inverse
w = self._get_word_rep_initial(self.B(delta0))
Expand Down
8 changes: 4 additions & 4 deletions darmonpoints/cohomology_arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ def get_overconvergent_class_matrices(
):
# If the moments are pre-calculated, will load them. Otherwise, calculate and
# save them to disk.
if use_ps_dists == False:
if use_ps_dists is False:
raise NotImplementedError(
"Must use distributions from Pollack-Stevens code in the split case"
)

sgninfty = "plus" if sign_at_infinity == 1 else "minus"
dist_type = "ps" if use_ps_dists == True else "fm"
dist_type = "ps" if use_ps_dists is True else "fm"
fname = "moments_%s_%s_%s_%s_%s.sobj" % (
p,
E.cremona_label(),
Expand Down Expand Up @@ -148,7 +148,7 @@ def get_overconvergent_class_quaternionic(
base_ring = Zp(p, prec)

sgninfty = "plus" if sign_at_infinity == 1 else "minus"
dist_type = "ps" if use_ps_dists == True else "fm"
dist_type = "ps" if use_ps_dists is True else "fm"
fname = "moments_%s_%s_%s_%s_%s.sobj" % (p, Ename, sgninfty, prec, dist_type)
if use_sage_db:
try:
Expand Down Expand Up @@ -1451,7 +1451,7 @@ def get_cocycle_from_elliptic_curve(Coh, E, sign=1, use_magma=True, **kwargs):
return get_cocycle_from_elliptic_curve(
Coh, E, 1, use_magma, **kwargs
) + get_cocycle_from_elliptic_curve(Coh, E, -1, use_magma, **kwargs)
if not sign in [1, -1]:
if sign not in [1, -1]:
raise NotImplementedError
F = E.base_ring()
if F == QQ:
Expand Down
2 changes: 1 addition & 1 deletion darmonpoints/homology.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ def is_cycle(self, return_residue=False):
ans = True
else:
ans = False
return ans if return_residue == False else (ans, res)
return ans if return_residue is False else (ans, res)

def hecke_smoothen(self, r, prec=None):
if prec is None:
Expand Down
4 changes: 2 additions & 2 deletions darmonpoints/integrals.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def sample_point(G, e, prec=20):
rev, h = e
hemb = G.embed(set_immutable(h**-1), prec)
wploc = G.embed(G.wp(), prec)
if rev == True:
if rev is True:
hemb = hemb * wploc
a, b, c, d = hemb.list()
if d == 0:
Expand Down Expand Up @@ -401,7 +401,7 @@ def __call__(self, h, check=False):
ans = self.cocycle.evaluate_and_identity(a)
else:
ans = self.cocycle.evaluate(a)
if rev == False:
if rev is False:
return ans
else:
return -ans
Expand Down
4 changes: 2 additions & 2 deletions darmonpoints/limits.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def compute_tau0(v0, gamma, wD, return_exact=False):
if c * tau0 + d != v0(wD):
tau0 = v0(tau0_vec[1][0])
idx = 1
return tau0_vec[idx][0] if return_exact == True else tau0
return tau0_vec[idx][0] if return_exact is True else tau0


def order_and_unit(F, conductor):
Expand Down Expand Up @@ -383,7 +383,7 @@ def find_optimal_embeddings(F, use_magma=False, extra_conductor=1, magma=None):
w = F.maximal_order().ring_generators()[0]
D = F.discriminant()
## this matrix gives an optimal embedding of conductor 1
if use_magma == True or extra_conductor != 1:
if use_magma is True or extra_conductor != 1:
if magma is None:
from sage.interfaces.magma import magma
tmp = magma.ReducedForms(str(D * extra_conductor**2), nvals=1)
Expand Down
4 changes: 2 additions & 2 deletions darmonpoints/ocmodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def valuation(self, l=None):

"""
if not self._parent.base_ring().is_exact():
if not l is None and l != self._parent._Rmod.prime():
if l is not None and l != self._parent._Rmod.prime():
raise ValueError("This function can only be called with the base prime")
l = self._parent._Rmod.prime()
return min([self._val[ii, 0].valuation(l) for ii in range(self._depth)])
Expand All @@ -313,7 +313,7 @@ def valuation_list(self, l=None):

"""
if not self._parent.base_ring().is_exact():
if not l is None and l != self._parent._Rmod.prime():
if l is not None and l != self._parent._Rmod.prime():
raise ValueError("This function can only be called with the base prime")
l = self._parent._Rmod.prime()
return [self._val[ii, 0].valuation(l) for ii in range(self._depth)]
Expand Down
5 changes: 2 additions & 3 deletions darmonpoints/sarithgroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def __init__(self, reverse, gamma):
set_immutable(self.gamma)

def _repr_(self):
return "(%s)^%s" % (self.gamma, "+" if self.reverse == False else "-")
return "(%s)^%s" % (self.gamma, "+" if self.reverse is False else "-")

def __iter__(self):
return iter([self.reverse, self.gamma])
Expand Down Expand Up @@ -763,8 +763,7 @@ def iota(q):
q = q.list()
return sum(v(a) * b for a, b in zip(q, mats))

if prec > self._prec: # DEBUG
self._prec = prec
self._prec = max(prec, self._prec)
return iota

def embed(self, q, prec):
Expand Down
10 changes: 5 additions & 5 deletions darmonpoints/schottky.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,15 +479,15 @@ def vertex_classes(self):
r = dict()
visited = set()
for i in range(len(action_table[0])):
if not i in visited:
if i not in visited:
visited.add(i)
open_list = [(i, ())]
r[i] = (i, ())
while len(open_list) > 0:
current, current_word = open_list.pop()
for j, actj in enumerate(action_table):
nxt = actj[current]
if nxt is not None and not (nxt in visited):
if nxt is not None and nxt not in visited:
next_word = reduce_word((j,) + current_word)
visited.add(nxt)
open_list.append((nxt, next_word))
Expand All @@ -503,7 +503,7 @@ def edge_classes(self, action_table=None):
r = dict()
visited = set()
for i in edges:
if not i in visited:
if i not in visited:
visited.add(i)
open_list = [(i, ())]
r[i] = (i, ())
Expand All @@ -512,7 +512,7 @@ def edge_classes(self, action_table=None):
open_list = open_list[1:]
for j, actj in enumerate(action_table):
nxt = (actj[current[0]], actj[current[1]])
if (nxt in edges) and not (nxt in visited):
if (nxt in edges) and nxt not in visited:
next_word = reduce_word((j,) + current_word)
visited.add(nxt)
open_list.append((nxt, next_word))
Expand Down Expand Up @@ -1192,7 +1192,7 @@ def get_subtree(self, v1, v2):
while len(open_list) > 0:
current = open_list.pop()
for i in adj[current]:
if not i in visited:
if i not in visited:
visited.add(i)
open_list.append(i)
return visited
Expand Down
8 changes: 4 additions & 4 deletions darmonpoints/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def is_in_Gamma0loc(A, det_condition=True, p=None):
r"""
Whether the matrix A has all entries Zp-integral, and is upper-triangular mod p.
"""
if det_condition == True and A.determinant() != 1:
if det_condition is True and A.determinant() != 1:
return False
if p is not None:
return all(o.valuation(p) >= 0 for o in A.list()) and A[1, 0].valuation(p) > 0
Expand Down Expand Up @@ -1068,7 +1068,7 @@ def our_sqrt(xx, K=None, return_all=False):
if (y0**2 - x).valuation() >= minval:
found = True
break
if found == False:
if found is False:
if return_all:
return []
else:
Expand All @@ -1086,7 +1086,7 @@ def our_sqrt(xx, K=None, return_all=False):
if (y0**2 - y0 + (1 - x) / 4).valuation() >= minval:
found = True
break
if found == False:
if found is False:
if return_all:
return []
else:
Expand Down Expand Up @@ -1144,7 +1144,7 @@ def our_cuberoot(xx, K=None, return_all=False):
if (y0**3 - x).valuation() >= minval:
found = True
break
if found == False:
if found is False:
raise ValueError("Not a cube")
y1 = y0
y = K(0)
Expand Down
Loading