Skip to content

Commit

Permalink
some auto-fixes for ruff --select=W
Browse files Browse the repository at this point in the history
  • Loading branch information
fchapoton authored and spj101 committed Apr 22, 2024
1 parent 6e4d57a commit 3fe2151
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion pySecDec/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
from .code_writer import sum_package, MakePackage, Coefficient
from .make_regions import make_regions
from .metadata import __authors__, __version__, __commit__
from .misc import version
from .misc import version
4 changes: 2 additions & 2 deletions pySecDec/algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ def refactorize(self, *parameters):
return prod

def denest(self):
"""
r"""
Returns a flattened version of a nested :class:`.Polynomial`
of :class:`.Polynomial`\s.
"""
Expand Down Expand Up @@ -1709,7 +1709,7 @@ def derive(self, index):
@doc(_Expression.docstring_of_replace)
def replace(expression, index, value, remove=False):
return Log( expression.arg.replace(index,value,remove) , copy=False )

class Exp(_Expression):
r'''
The real valued exponential function.
Expand Down
4 changes: 2 additions & 2 deletions pySecDec/code_writer/sum_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def sum_package(name, package_generators, regulators, requested_orders,
`pySecDec.loop_integral.LoopPackage` `namedtuples`;
The generator functions for the integrals
:math:`\int f_i`
.. note::
The `pySecDec.code_writer.MakePackage` and
`pySecDec.loop_integral.LoopPackage` objects
Expand Down Expand Up @@ -246,7 +246,7 @@ def sum_package(name, package_generators, regulators, requested_orders,
* ``sidi<i>`` for 1 <= i <= 6
Default: ``['korobov3x3']``
:param processes:
integer or None, optional;
Parallelize the generation of terms in a sum using this
Expand Down
4 changes: 2 additions & 2 deletions pySecDec/code_writer/template_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def validate_pylink_qmc_transforms(pylink_qmc_transforms):
List of pylink_qmc_transforms
'''
pylink_qmc_transforms_available_options = set(
['none'] +
['none'] +
['baker'] +
['korobov'+str(i)+'x'+str(j) for i in range(1,7) for j in range(1,7)] +
['sidi'+str(i) for i in range(1,7)]
Expand Down Expand Up @@ -131,7 +131,7 @@ def recursive_write(file, text, unflushedlen = [0]):
file.flush()
unflushedlen[0] = 0

dest_file_parts = re.split("%\(([^)]*)\)s",string)
dest_file_parts = re.split(r"%\(([^)]*)\)s",string)
dest_file.write(dest_file_parts[0] % replacements)
for n in range(1,len(dest_file_parts),2):
bigtext = replacements[dest_file_parts[n]]
Expand Down
2 changes: 1 addition & 1 deletion pySecDec/code_writer/test_make_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ def test_polynomial_coefficient(self):
target_FORM_code += " Id SecDecInternalfDUMMYSecDecInternalfDUMMYmyNamePart0Part2(x?,y?,z?) = + (3)*a*b*c^3;\n"
target_FORM_code += " Id SecDecInternalfDUMMYSecDecInternalfDUMMYmyNamePart0Part3(x?,y?,z?) = + (4)*a*b*c^4;\n"

self.assertEqual(FORM_code, target_FORM_code)
self.assertEqual(FORM_code, target_FORM_code)

class TestMiscellaneous(unittest.TestCase):
#@pytest.mark.active
Expand Down
2 changes: 1 addition & 1 deletion pySecDec/decomposition/geometric.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def Cheng_Wu(sector, index=-1):

# ********************** geometric decomposition **********************
def generate_fan(*polynomials):
'''
r'''
Calculate the fan of the polynomials in the input. The rays of a
cone are given by the exponent vectors after factoring out a monomial
together with the standard basis vectors. Each choice of factored out
Expand Down
2 changes: 1 addition & 1 deletion pySecDec/disteval.py
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ def signedMax(x):
if standard_lattices:
for i in range(len(kernel2idx)):
try: n[i], newgenvecs[i] = generating_vector(dims[i], n[i])
except ValueError:
except ValueError:
if lattice_candidates > 0: pass
if not np.any(n != lattices):
log("can't increase the lattice sizes any more; giving up")
Expand Down
6 changes: 3 additions & 3 deletions pySecDec/disteval_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def call_cb(self, method, args, callback, callback_args=()):
message = encode_message((token, method, args))
self.process.stdin.write(message)
return token

def cancel_cb(self, token):
if token in self.callbacks:
self.callbacks[token] = (lambda a,b,c:None, ())
Expand All @@ -85,7 +85,7 @@ def call_return(result, error, w):
else: fut.set_exception(WorkerException(error))
self.call_cb(method, args, call_return)
return fut

def multicall(self, calls):
fut = asyncio.futures.Future()
results = [None]*len(calls)
Expand Down Expand Up @@ -191,7 +191,7 @@ async def dobenchmark(workercmd, datadir, intfile, valuemap, npoints, nreps):
info["sums"] = {f"sum{sumidx}" : sum for sumidx, sum in enumerate(info["sums"])}
else:
raise ValueError(f"unknown type: {info['type']}")

realp = {
i : [valuemap[p] for p in info["realp"]]
for i, info in infos.items()
Expand Down
6 changes: 3 additions & 3 deletions pySecDec/integral_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -1661,7 +1661,7 @@ def __call__(self,
parameters={}, real_parameters=[], complex_parameters=[],
epsabs=1e-10, epsrel=1e-4, timeout=None, points=1e4,
number_of_presamples=1e4, shifts=32,
lattice_candidates=0, standard_lattices=False,
lattice_candidates=0, standard_lattices=False,
coefficients=None, verbose=None, format="sympy"):
import asyncio
import json
Expand Down Expand Up @@ -1699,7 +1699,7 @@ def __call__(self,
int(number_of_presamples), int(points), int(shifts),
lattice_candidates, standard_lattices,
valuemap_int, valuemap_coeff, deadline))

if format == "raw":
return result
elif format == "sympy":
Expand All @@ -1708,4 +1708,4 @@ def __call__(self,
return disteval.result_to_mathematica(result)
else:
return disteval.result_to_json(result)

22 changes: 11 additions & 11 deletions pySecDec/loop_integral/loop_regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def loop_regions(name, loop_integral, smallness_parameter,
polynomials_to_decompose = \
[loop_integral.exponentiated_U, loop_integral.exponentiated_F] + \
loop_integral.measure.factors

# add regulators of the form x_i**(n*e_i), where n is the extra regulator
if extra_regulator_name is not None:
extra_regulator = sympify_expression(extra_regulator_name)
Expand Down Expand Up @@ -352,14 +352,14 @@ def suggested_extra_regulator_exponent(loop_integral, smallness_parameter, expan

def extra_regulator_constraints(exp_param_index, polynomial, exp_order, regulators, powerlist, dimension, indices=None, normaliz=None):
'''
Returns a dictionary of vectors :\mathbf{n}_i: that give constraints
of the form :math:`\langle\mathbf{n_i},\bf{\nu}_{\delta}\rangle \neq 0`
on the coefficient of a regulator :math:`\delta` introduced by
multiplying the integrand with a monomial
:math:`\mathbf{x}^{\delta\bf{\nu}_{\delta}}`, where :math:`\mathbf{x}`
are the variables of the input polynomial. The dictionary contains
entries for each region individually and a list of all constraints
(entry `all`). Only exponents corresponding to integration variables
Returns a dictionary of vectors :\\mathbf{n}_i: that give constraints
of the form :math:`\\langle\\mathbf{n_i},\bf{\nu}_{\\delta}\rangle \neq 0`
on the coefficient of a regulator :math:`\\delta` introduced by
multiplying the integrand with a monomial
:math:`\\mathbf{x}^{\\delta\bf{\nu}_{\\delta}}`, where :math:`\\mathbf{x}`
are the variables of the input polynomial. The dictionary contains
entries for each region individually and a list of all constraints
(entry `all`). Only exponents corresponding to integration variables
can be non-zero.
:param exp_param_index:
Expand Down Expand Up @@ -421,7 +421,7 @@ def extra_regulator_constraints(exp_param_index, polynomial, exp_order, regulato
facets = polytope.facets

regions = facets[ facets[:,exp_param_index] > 0 ]
regions = regions[ np.dot(regions,powerlist)<= exp_order ]
regions = regions[ np.dot(regions,powerlist)<= exp_order ]

region_facets_sd_0 = {}
all_facets_sd_0 = []
Expand All @@ -439,7 +439,7 @@ def extra_regulator_constraints(exp_param_index, polynomial, exp_order, regulato
region_facets_sd_0[tuple(region[:-1])] = facets
all_facets_sd_0 = all_facets_sd_0 + [facets]
all_facets_sd_0 = np.concatenate(all_facets_sd_0)

# internal facets
facets_sd_int_0 = [facet for facet in all_facets_sd_0 if any([np.array_equal(facet, -fac) for fac in all_facets_sd_0])]
# store only internal facets for each region
Expand Down
2 changes: 1 addition & 1 deletion pySecDec/make_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def make_package(name, integration_variables, regulators, requested_orders,
integration over :math:`[0,1]^{N-1}`.
'iterative', 'geometric', and 'geometric_ku' are only
valid for loop integrals. The functions
valid for loop integrals. The functions
'iterative_no_primary', 'geometric_no_primary', or
'geometric_infinity_no_primary' should be used when
decomposing a function with no overall Dirac delta
Expand Down
2 changes: 1 addition & 1 deletion pySecDec/make_regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ def make_regions(name, integration_variables, regulators, requested_orders, smal
tindependent = np.all([not np.any(poly.expolist[:,smallness_parameter_index]) for poly in polynomials_refactorized + [numerator_refactorized] ])
if tindependent and expand_region_expansion_order >= 0:
expand_region_expansion_order = 0

series = expand_region(polynomials_refactorized, numerator_refactorized, smallness_parameter_index, expand_region_expansion_order, polynomial_name_indices)

for i,term in enumerate(series):
Expand Down
2 changes: 1 addition & 1 deletion pySecDec/subtraction.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""
r"""
Subtraction
-----------
Expand Down
2 changes: 1 addition & 1 deletion pySecDec/test_expansion.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def setUp(self):
self.p6_1 = Polynomial([(0,),(1,),(2,)], coeffs=['3/16','3/16','-9/16'], polysymbols=['eps'])
self.p6_2 = ExponentiatedPolynomial([(2,),(3,),(4,)], coeffs=['9/16','-9/8','9/16'], polysymbols=['eps'], exponent=-1)
self.p6 = Product(self.p6_1,self.p6_2)
self.p7 = ExponentiatedPolynomial([(1,1),(1,2),(2,0),(2,1),(2,2),(3,0),(3,1),(4,0)],
self.p7 = ExponentiatedPolynomial([(1,1),(1,2),(2,0),(2,1),(2,2),(3,0),(3,1),(4,0)],
coeffs=['3/4','-3/4','-3/16','-3/16','9/16','3/32','-9/32','9/256'],
polysymbols=['n1','eps'], exponent=-1)

Expand Down

0 comments on commit 3fe2151

Please sign in to comment.