diff --git a/maintainer/CI/dox_warnings.py b/maintainer/CI/dox_warnings.py
index 2e359b6d7de..4059fef2f47 100755
--- a/maintainer/CI/dox_warnings.py
+++ b/maintainer/CI/dox_warnings.py
@@ -55,14 +55,14 @@
# filter out non-critical warnings
warnings = {}
for (filepath, lineno, warning), warning_list in raw_warnings.items():
- if re.search('^member \S+ belongs to two different groups\. '
- 'The second one found here will be ignored\.$', warning):
+ if re.search(r'^member \S+ belongs to two different groups\. '
+ r'The second one found here will be ignored\.$', warning):
# happens when a function is declared in a group in the .hpp file but
# defined in another group in the .cpp file; this is usually caused by
# the "Private functions" and "Exported functions" groups in .hpp files
continue
- if re.search(
- '^documented symbol `\S+\' was not declared or defined\.$', warning):
+ if re.search(r'^documented symbol `\S+\' was not declared or defined\.$',
+ warning):
# known bug, fixed in 1.8.16
continue
if re.search('^no uniquely matching class member found for $', warning):
@@ -75,7 +75,7 @@
# warning, when in reality the warning is silenced because the text on
# the following line is captured and becomes the argument description
continue
- filepath = re.sub('^.*(?=src/)', '', filepath)
+ filepath = re.sub(r'^.*(?=src/)', '', filepath)
if filepath not in warnings:
warnings[filepath] = {}
warnings[filepath][(lineno, warning)] = warning_list
@@ -94,7 +94,7 @@
f.write(filepath + ':\n')
for (lineno, warning) in sorted(warnings[filepath].keys()):
warning_list = warnings[filepath][(lineno, warning)]
- s = re.sub('\(.*\)', '()', warning)
+ s = re.sub(r'\(.*\)', '()', warning)
if warning_list:
s += ': ' + ', '.join(x.strip() for x in warning_list)
f.write(' line {}: {}\n'.format(lineno, s))
diff --git a/maintainer/benchmarks/lj.py b/maintainer/benchmarks/lj.py
index 99813ff8492..6757d3a5298 100644
--- a/maintainer/benchmarks/lj.py
+++ b/maintainer/benchmarks/lj.py
@@ -58,7 +58,6 @@
import espressomd
-from espressomd import thermostat
if args.visualizer:
from espressomd import visualization
from threading import Thread
diff --git a/maintainer/benchmarks/p3m.py b/maintainer/benchmarks/p3m.py
index 25ab32b8eb8..ca138b34702 100644
--- a/maintainer/benchmarks/p3m.py
+++ b/maintainer/benchmarks/p3m.py
@@ -58,11 +58,9 @@
import espressomd
-from espressomd import thermostat
from espressomd import electrostatics
if args.visualizer:
from espressomd import visualization
- from threading import Thread
required_features = ["P3M", "LENNARD_JONES", "MASS"]
espressomd.assert_features(required_features)
@@ -101,7 +99,7 @@
# Integration parameters
#############################################################
system.time_step = 0.01
-system.cell_system.skin = .4
+system.cell_system.skin = .4
system.thermostat.turn_off()
diff --git a/maintainer/gh_post_docs_warnings.py b/maintainer/gh_post_docs_warnings.py
index e6333fef995..26f0f4c307e 100755
--- a/maintainer/gh_post_docs_warnings.py
+++ b/maintainer/gh_post_docs_warnings.py
@@ -22,7 +22,6 @@
import os
import sys
import requests
-import subprocess
if not os.environ['CI_COMMIT_REF_NAME'].startswith('PR-'):
exit(0)
diff --git a/maintainer/gh_post_style_patch.py b/maintainer/gh_post_style_patch.py
index e74e0ee6c37..f9ff687062d 100755
--- a/maintainer/gh_post_style_patch.py
+++ b/maintainer/gh_post_style_patch.py
@@ -60,5 +60,5 @@
comment += 'You can run `gitlab-runner exec docker style` afterwards to check if your changes worked out properly.\n\n'
comment += 'Please note that there are often multiple ways to correctly format code. As I am just a robot, I sometimes fail to identify the most aesthetically pleasing way. So please look over my suggested changes and adapt them where the style does not make sense.'
- if len(patch) > 0:
+ if patch:
requests.post(URL, json={'body': comment})
diff --git a/maintainer/git2changelog.py b/maintainer/git2changelog.py
index f0787d4169f..6500c6a528a 100755
--- a/maintainer/git2changelog.py
+++ b/maintainer/git2changelog.py
@@ -16,7 +16,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
-import string
import re
import os
@@ -52,14 +51,14 @@
continue
# Match the author line and extract the part we want
- m = re.match('^Author:\s*(.*)\s*$', line)
+ m = re.match(r'^Author:\s*(.*)\s*$', line)
if m is not None:
author = m.group(1)
authorFound = True
continue
# Match the date line
- m = re.match('^Date:\s*(.*)\s*$', line)
+ m = re.match(r'^Date:\s*(.*)\s*$', line)
if m is not None:
date = m.group(1)
dateFound = True
@@ -92,7 +91,7 @@
continue
# Collect the files for this commit. FIXME: Still need to add +/- to files
elif authorFound & dateFound & messageFound:
- fileList = re.split(' \| ', line, 2)
+ fileList = re.split(r' \| ', line, 2)
if len(fileList) > 1:
if files:
files = files + ", " + fileList[0].strip()
diff --git a/src/config/defines.py b/src/config/defines.py
index c036c6c6db3..163a2cda93b 100644
--- a/src/config/defines.py
+++ b/src/config/defines.py
@@ -21,9 +21,10 @@
class Defines:
- def __init__(self, compiler, flags=[]):
+ def __init__(self, compiler, flags=()):
self._compiler = compiler
- self._flags = flags + ["-E", "-dM"]
+ assert isinstance(flags, (list, tuple))
+ self._flags = list(flags) + ["-E", "-dM"]
build_in = self._build_in_defs()
self._buildin = set(build_in)
diff --git a/src/config/featuredefs.py b/src/config/featuredefs.py
index ee7c229115d..4a12c4144b4 100644
--- a/src/config/featuredefs.py
+++ b/src/config/featuredefs.py
@@ -20,11 +20,10 @@
# This module parses the feature definition file features.def
#
import fileinput
-import string
import re
-class SyntaxError:
+class SyntaxError(Exception):
def __init__(self, message, instead):
self.message = message
@@ -171,7 +170,7 @@ def check_validity(self, activated):
for feature in allfeatures:
featurevars[feature] = feature in newset
- for feature, expr, undef in self.requirements:
+ for feature, expr, _ in self.requirements:
# print 'Requirement: ', feature, ' -> ', expr
if feature in newset:
if not eval(expr, featurevars):
diff --git a/src/config/gen_sampleconfig.py b/src/config/gen_sampleconfig.py
index 7f5476b126b..30b2f842893 100644
--- a/src/config/gen_sampleconfig.py
+++ b/src/config/gen_sampleconfig.py
@@ -20,8 +20,6 @@
# This script appends the sample list of features to the file
# myconfig-sample.h.
#
-import time
-import string
import fileinput
import inspect
import sys
diff --git a/src/python/espressomd/MDA_ESP/__init__.py b/src/python/espressomd/MDA_ESP/__init__.py
index 95184f5f969..9cbad2cfec5 100644
--- a/src/python/espressomd/MDA_ESP/__init__.py
+++ b/src/python/espressomd/MDA_ESP/__init__.py
@@ -210,9 +210,9 @@ def _read_first_frame(self):
with util.openany(self.filename, 'rt') as espfile:
n_atoms = 1
for pos, line in enumerate(espfile, start=-3):
- if (pos == -3):
+ if pos == -3:
time = float(line[1:-1])
- elif(pos == -2):
+ elif pos == -2:
n_atoms = int(line)
self.n_atoms = n_atoms
positions = np.zeros(
@@ -224,13 +224,13 @@ def _read_first_frame(self):
self.ts = ts = self._Timestep(
self.n_atoms, **self._ts_kwargs)
self.ts.time = time
- elif(pos == -1):
+ elif pos == -1:
self.ts._unitcell[:3] = np.array(
list(map(float, line[1:-2].split())))
- elif(pos < n_atoms):
+ elif pos < n_atoms:
positions[pos] = np.array(
list(map(float, line[1:-2].split())))
- elif(pos < 2 * n_atoms):
+ elif pos < 2 * n_atoms:
velocities[pos - n_atoms] = np.array(
list(map(float, line[1:-2].split())))
else:
diff --git a/src/python/espressomd/accumulators.py b/src/python/espressomd/accumulators.py
index 1072ee0dabd..c05e3ba5161 100644
--- a/src/python/espressomd/accumulators.py
+++ b/src/python/espressomd/accumulators.py
@@ -241,10 +241,10 @@ def result(self):
-------
numpy.ndarray
- The result of the correlation function as a 2d-array.
+ The result of the correlation function as a 2d-array.
The first column contains the values of the lag time tau.
The second column contains the number of values used to
- perform the averaging of the correlation. Further columns contain
+ perform the averaging of the correlation. Further columns contain
the values of the correlation function. The number of these columns
is the dimension of the output of the correlation operation.
"""
diff --git a/src/python/espressomd/checkpointing.py b/src/python/espressomd/checkpointing.py
index dbc7f91c727..8b41a8ac674 100644
--- a/src/python/espressomd/checkpointing.py
+++ b/src/python/espressomd/checkpointing.py
@@ -17,7 +17,6 @@
# along with this program. If not, see .
#
from collections import OrderedDict
-import sys
import inspect
import os
import re
@@ -97,7 +96,6 @@ def __setattr_submodule(self, obj, name, value):
"""
names = name.split('.')
- tmp_obj = obj
for i in range(len(names) - 1):
obj = getattr(obj, names[i], None)
diff --git a/src/python/espressomd/constraints.py b/src/python/espressomd/constraints.py
index 92e6c065b50..17c86228f45 100644
--- a/src/python/espressomd/constraints.py
+++ b/src/python/espressomd/constraints.py
@@ -15,7 +15,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
from .script_interface import ScriptObjectRegistry, ScriptInterfaceHelper, script_interface_register
-from espressomd.utils import is_valid_type
import numpy as np
from itertools import product
diff --git a/src/python/espressomd/ekboundaries.py b/src/python/espressomd/ekboundaries.py
index a3398831c5c..799c55cd694 100644
--- a/src/python/espressomd/ekboundaries.py
+++ b/src/python/espressomd/ekboundaries.py
@@ -14,7 +14,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-from .script_interface import ScriptInterfaceHelper, script_interface_register
+from .script_interface import script_interface_register
from .__init__ import has_features
import espressomd.lbboundaries
diff --git a/src/python/espressomd/io/writer/vtf.py b/src/python/espressomd/io/writer/vtf.py
index 1933d1e5300..43892a41063 100644
--- a/src/python/espressomd/io/writer/vtf.py
+++ b/src/python/espressomd/io/writer/vtf.py
@@ -40,7 +40,7 @@ def vtf_pid_map(system, types='all'):
id_to_write = []
for p in system.part:
for t in types:
- if p.type == t or t == "all":
+ if t in (p.type, "all"):
id_to_write.append(p.id)
return dict(zip(id_to_write, range(len(id_to_write))))
@@ -70,7 +70,7 @@ def writevsf(system, fp, types='all'):
system.part[pid].type))
for pid, vtf_id, in vtf_index.items():
for b in system.part[pid].bonds:
- if (system.part[b[1]].id in vtf_index):
+ if system.part[b[1]].id in vtf_index:
fp.write("bond {}:{}\n".format(
vtf_id, vtf_index[system.part[b[1]].id]))
diff --git a/src/python/object_in_fluid/__init__.py b/src/python/object_in_fluid/__init__.py
index 1c8ee0f1fad..37a3a468744 100644
--- a/src/python/object_in_fluid/__init__.py
+++ b/src/python/object_in_fluid/__init__.py
@@ -14,32 +14,15 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-from .oif_classes import \
- FixedPoint, \
- PartPoint, \
- Edge, \
- Triangle, \
- Angle, \
- ThreeNeighbors, \
- Mesh, \
- OifCellType,\
- OifCell
-
-from .oif_utils import \
- custom_str, \
- get_triangle_normal, \
- norm, \
- vec_distance, \
- area_triangle, \
- angle_btw_triangles, \
- discard_epsilon, \
- oif_neo_hookean_nonlin, \
- oif_calc_stretching_force, \
- oif_calc_linear_stretching_force, \
- oif_calc_bending_force, \
- oif_calc_local_area_force, \
- oif_calc_global_area_force, \
- oif_calc_volume_force, \
- output_vtk_rhomboid, \
- output_vtk_cylinder, \
- output_vtk_lines
+from .oif_classes import (
+ FixedPoint, PartPoint, Edge, Triangle, Angle, ThreeNeighbors, Mesh,
+ OifCellType, OifCell
+)
+from .oif_utils import (
+ custom_str, get_triangle_normal, norm, vec_distance, area_triangle,
+ angle_btw_triangles, discard_epsilon, oif_neo_hookean_nonlin,
+ oif_calc_stretching_force, oif_calc_linear_stretching_force,
+ oif_calc_bending_force, oif_calc_local_area_force,
+ oif_calc_global_area_force, oif_calc_volume_force, output_vtk_rhomboid,
+ output_vtk_cylinder, output_vtk_lines
+)
diff --git a/src/python/object_in_fluid/oif_classes.py b/src/python/object_in_fluid/oif_classes.py
index 2c1b8349d47..c9dbdb89c20 100644
--- a/src/python/object_in_fluid/oif_classes.py
+++ b/src/python/object_in_fluid/oif_classes.py
@@ -14,12 +14,15 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-import espressomd
import numpy as np
-from .oif_utils import *
-from espressomd.interactions import OifLocalForces
-from espressomd.interactions import OifGlobalForces
-from espressomd.interactions import OifOutDirection
+import espressomd
+from espressomd.interactions import OifLocalForces, OifGlobalForces, OifOutDirection
+from .oif_utils import (
+ large_number, small_epsilon, discard_epsilon, custom_str, norm,
+ vec_distance, get_triangle_normal, area_triangle, angle_btw_triangles,
+ oif_calc_stretching_force, oif_calc_bending_force,
+ oif_calc_local_area_force, oif_calc_global_area_force, oif_calc_volume_force
+)
class FixedPoint:
@@ -105,8 +108,7 @@ class Edge:
"""
def __init__(self, A, B):
- if not (isinstance(A, PartPoint) or (isinstance(A, FixedPoint))) and (
- isinstance(B, PartPoint) or (isinstance(B, FixedPoint))):
+ if not all(isinstance(x, (PartPoint, FixedPoint)) for x in [A, B]):
TypeError("Arguments to Edge must be FixedPoint or PartPoint.")
self.A = A
self.B = B
@@ -123,8 +125,7 @@ class Triangle:
"""
def __init__(self, A, B, C):
- if not (isinstance(A, PartPoint) or (isinstance(A, FixedPoint))) and (isinstance(B, PartPoint) or (
- isinstance(B, FixedPoint))) and (isinstance(C, PartPoint) or (isinstance(C, FixedPoint))):
+ if not all(isinstance(x, (PartPoint, FixedPoint)) for x in [A, B, C]):
TypeError("Arguments to Triangle must be FixedPoint or PartPoint.")
self.A = A
self.B = B
@@ -144,10 +145,8 @@ class Angle:
"""
def __init__(self, A, B, C, D):
- if not (isinstance(A, PartPoint) or (isinstance(A, FixedPoint))) \
- and (isinstance(B, PartPoint) or (isinstance(B, FixedPoint))) \
- and (isinstance(C, PartPoint) or (isinstance(C, FixedPoint))) \
- and (isinstance(D, PartPoint) or (isinstance(D, FixedPoint))):
+ if not all(isinstance(x, (PartPoint, FixedPoint))
+ for x in [A, B, C, D]):
TypeError("Arguments to Angle must be FixedPoint or PartPoint.")
self.A = A
self.B = B
@@ -168,9 +167,7 @@ class ThreeNeighbors:
"""
def __init__(self, A, B, C):
- if not (isinstance(A, PartPoint) or (isinstance(A, FixedPoint))) \
- and (isinstance(B, PartPoint) or (isinstance(B, FixedPoint))) \
- and (isinstance(C, PartPoint) or (isinstance(C, FixedPoint))):
+ if not all(isinstance(x, (PartPoint, FixedPoint)) for x in [A, B, C]):
TypeError(
"Arguments to ThreeNeighbors must be FixedPoint or PartPoint.")
self.A = A
@@ -671,10 +668,10 @@ def volume(self):
triangle.A.get_pos(), triangle.B.get_pos(), triangle.C.get_pos())
tmp_normal_length = norm(tmp_normal)
tmp_sum_z_coords = 1.0 / 3.0 * \
- (triangle.A.get_pos()[2] + triangle.B.get_pos()[
- 2] + triangle.C.get_pos()[2])
- volume -= triangle.area() * tmp_normal[
- 2] / tmp_normal_length * tmp_sum_z_coords
+ (triangle.A.get_pos()[2] + triangle.B.get_pos()[2] +
+ triangle.C.get_pos()[2])
+ volume -= (triangle.area() * tmp_normal[2] / tmp_normal_length *
+ tmp_sum_z_coords)
return volume
def get_n_nodes(self):
@@ -704,9 +701,8 @@ def mirror(self, mirror_x=0, mirror_y=0, mirror_z=0, out_file_name=""):
if out_file_name == "":
raise Exception(
"Cell.Mirror: output meshnodes file for new mesh is missing. Quitting.")
- if (mirror_x != 0 and mirror_x != 1) or (
- mirror_y != 0 and mirror_y != 1) or (
- mirror_z != 0 and mirror_z != 1):
+ if mirror_x not in (0, 1) or mirror_y not in (
+ 0, 1) or mirror_z not in (0, 1):
raise Exception(
"Mesh.Mirror: for mirroring only values 0 or 1 are accepted. 1 indicates that the corresponding coordinate will be flipped. Exiting.")
if mirror_x + mirror_y + mirror_z > 1:
@@ -1050,7 +1046,7 @@ def append_point_data_to_vtk(self, file_name=None, data_name=None,
raise Exception("OifCell: append_point_data_to_vtk: Need to know whether this is the first data list to be "
"appended for this file. Quitting.")
n_points = self.get_n_nodes()
- if (len(data) != n_points):
+ if len(data) != n_points:
raise Exception(
"OifCell: append_point_data_to_vtk: Number of data points does not match number of mesh points. Quitting.")
output_file = open(file_name, "a")
@@ -1070,7 +1066,7 @@ def output_raw_data(self, file_name=None, data=None):
raise Exception(
"OifCell: output_raw_data: No data provided. Quitting.")
n_points = self.get_n_nodes()
- if (len(data) != n_points):
+ if len(data) != n_points:
raise Exception(
"OifCell: output_raw_data: Number of data points does not match number of mesh points. Quitting.")
output_file = open(file_name, "w")
diff --git a/src/python/object_in_fluid/oif_utils.py b/src/python/object_in_fluid/oif_utils.py
index 061998bdab2..e29b4701512 100644
--- a/src/python/object_in_fluid/oif_utils.py
+++ b/src/python/object_in_fluid/oif_utils.py
@@ -16,8 +16,6 @@
# along with this program. If not, see .
import numpy as np
import math
-from espressomd.shapes import Rhomboid
-from espressomd.shapes import Cylinder
small_epsilon = 0.000000001
large_number = 10000000.0
@@ -58,8 +56,7 @@ def norm(vect):
Input vector
"""
- v = np.array(vect)
- return np.sqrt(np.dot(v, v))
+ return np.linalg.norm(vect)
def vec_distance(a, b):
@@ -149,7 +146,7 @@ def discard_epsilon(x):
real number
"""
- if (x > -small_epsilon and x < small_epsilon):
+ if abs(x) < small_epsilon:
res = 0.0
else:
res = x
diff --git a/testsuite/python/accumulator.py b/testsuite/python/accumulator.py
index 068706db6df..36dc685f9f6 100644
--- a/testsuite/python/accumulator.py
+++ b/testsuite/python/accumulator.py
@@ -24,7 +24,7 @@
import sys
import unittest as ut
import numpy as np
-import espressomd # pylint: disable=import-error
+import espressomd
import espressomd.observables
import espressomd.accumulators
diff --git a/testsuite/python/analyze_distance.py b/testsuite/python/analyze_distance.py
index ffd7aaf456c..f1e5f37bd83 100644
--- a/testsuite/python/analyze_distance.py
+++ b/testsuite/python/analyze_distance.py
@@ -76,7 +76,7 @@ def dist_to_id(self, id):
def test_min_dist(self):
# try five times
- for i in range(5):
+ for _ in range(5):
self.system.part[:].pos = np.random.random(
(len(self.system.part), 3)) * BOX_L
self.assertAlmostEqual(self.system.analysis.min_dist(),
diff --git a/testsuite/python/analyze_distribution.py b/testsuite/python/analyze_distribution.py
index 229add97a47..d0699c93084 100644
--- a/testsuite/python/analyze_distribution.py
+++ b/testsuite/python/analyze_distribution.py
@@ -45,7 +45,7 @@ def calc_rdf(self, r, bins):
hist = np.histogram(dist, bins=bins, density=False)[0]
return hist
- def calc_min_distribution(self, bins, type_list_a):
+ def calc_min_distribution(self, bins):
dist = []
for i in range(self.num_part):
dist.append(self.system.analysis.dist_to(id=i))
@@ -122,8 +122,6 @@ def test_distribution_lin(self):
r_max = 100.0
r_bins = 100
bins = np.linspace(r_min, r_max, num=r_bins + 1, endpoint=True)
- bin_volume = 4. / 3. * np.pi * (bins[1:]**3 - bins[:-1]**3)
- box_volume = np.prod(self.system.box_l)
# no int flag
core_rdf = self.system.analysis.distribution(type_list_a=[0],
type_list_b=[0],
@@ -137,7 +135,7 @@ def test_distribution_lin(self):
# rdf
self.assertTrue(np.allclose(core_rdf[1],
- self.calc_min_distribution(bins, type_list_a=[0])))
+ self.calc_min_distribution(bins)))
# with int flag
core_rdf = self.system.analysis.distribution(type_list_a=[0],
type_list_b=[0],
@@ -147,7 +145,7 @@ def test_distribution_lin(self):
log_flag=0,
int_flag=1)
self.assertTrue(np.allclose(core_rdf[1],
- np.cumsum(self.calc_min_distribution(bins, type_list_a=[0]))))
+ np.cumsum(self.calc_min_distribution(bins))))
if __name__ == "__main__":
diff --git a/testsuite/python/analyze_mass_related.py b/testsuite/python/analyze_mass_related.py
index cbcb63f7c21..3c38fdb855d 100644
--- a/testsuite/python/analyze_mass_related.py
+++ b/testsuite/python/analyze_mass_related.py
@@ -139,12 +139,11 @@ def test_kinetic_pressure(self):
np.testing.assert_allclose(
expected_stress, analyze_stress)
- def test_gyration_radius(self):
- if len(self.system.part.select(virtual=True)) > 0:
- with self.assertRaisesRegexp(Exception, "not well-defined"):
- core_rg = self.system.analysis.calc_rg(chain_start=0,
- number_of_chains=1,
- chain_length=len(self.system.part))
+ def test_gyration_radius(self):
+ if self.system.part.select(virtual=True):
+ with self.assertRaisesRegex(Exception, "not well-defined"):
+ self.system.analysis.calc_rg(chain_start=0, number_of_chains=1,
+ chain_length=len(self.system.part))
if __name__ == "__main__":
diff --git a/testsuite/python/cluster_analysis.py b/testsuite/python/cluster_analysis.py
index a32affbb49a..2e27924000d 100644
--- a/testsuite/python/cluster_analysis.py
+++ b/testsuite/python/cluster_analysis.py
@@ -51,7 +51,7 @@ class ClusterAnalysis(ut.TestCase):
handle_errors("")
def test_00_fails_without_criterion_set(self):
- with(self.assertRaises(Exception)):
+ with self.assertRaises(Exception):
self.cs.run_for_all_pairs()
def test_set_criterion(self):
@@ -158,7 +158,7 @@ def test_zz_single_cluster_analysis(self):
# Fractal dimension of a disk should be close to 2
self.es.part.clear()
center = np.array((0.1, .02, 0.15))
- for i in range(3000):
+ for _ in range(3000):
r_inv, phi = np.random.random(2) * np.array((0.2, 2 * np.pi))
r = 1 / r_inv
self.es.part.add(
diff --git a/testsuite/python/collision_detection.py b/testsuite/python/collision_detection.py
index 980af2e0428..685a07a9090 100644
--- a/testsuite/python/collision_detection.py
+++ b/testsuite/python/collision_detection.py
@@ -146,9 +146,6 @@ def verify_state_after_bind_at_poc(self, expected_np):
# At the end of test, this list should be empty
parts_not_accounted_for = list(range(expected_np))
- # Collect pairs of non-virtual-particles found
- non_virtual_pairs = []
-
# We traverse particles. We look for a vs with a bond to find the other vs.
# From the two vs we find the two non-virtual particles
for p in self.s.part:
@@ -203,7 +200,7 @@ def verify_bind_at_poc_pair(self, p1, p2, vs1, vs2):
rel_to = r[0]
dist = r[1]
# Vs is related to one of the particles
- self.assertTrue(rel_to == p1.id or rel_to == p2.id)
+ self.assertTrue(rel_to in (p1.id, p2.id))
# The two vs relate to two different particles
self.assertNotIn(rel_to, seen)
seen.append(rel_to)
@@ -330,18 +327,18 @@ def run_test_glue_to_surface_for_pos(self, *positions):
# Place particle which should not take part in collisions
# In this case, it is skipped, because it is of the wrong type,
# even if it is within range for a collision
- p = self.s.part.add(pos=positions[0], type=self.other_type)
+ self.s.part.add(pos=positions[0], type=self.other_type)
for pos in positions:
# Since this is non-symmetric, we randomize order
if np.random.random() > .5:
- p1 = self.s.part.add(
+ self.s.part.add(
pos=pos + (0, 0, 0), type=self.part_type_to_attach_vs_to)
- p2 = self.s.part.add(
+ self.s.part.add(
pos=pos + (0.1, 0, 0), type=self.part_type_to_be_glued)
else:
- p2 = self.s.part.add(
+ self.s.part.add(
pos=pos + (0.1, 0, 0), type=self.part_type_to_be_glued)
- p1 = self.s.part.add(
+ self.s.part.add(
pos=pos + (0, 0, 0), type=self.part_type_to_attach_vs_to)
# 2 non-virtual + 1 virtual + one that doesn't take part
@@ -508,7 +505,6 @@ def test_glue_to_surface_random(self):
# Analysis
virtual_sites = self.s.part.select(virtual=True)
non_virtual = self.s.part.select(virtual=False)
- to_be_glued = self.s.part.select(type=self.part_type_to_be_glued)
after_glueing = self.s.part.select(type=self.part_type_after_glueing)
# One virtual site per glued particle?
@@ -583,7 +579,6 @@ def test_bind_three_particles(self):
self.s.part.clear()
dx = np.array((1, 0, 0))
dy = np.array((0, 1, 0))
- dz = np.array((0, 0, 1))
a = np.array((0.499, 0.499, 0.499))
b = a + 0.1 * dx
c = a + 0.03 * dx + 0.03 * dy
diff --git a/testsuite/python/constant_pH.py b/testsuite/python/constant_pH.py
index bcab5058ed9..6c98bd8312e 100644
--- a/testsuite/python/constant_pH.py
+++ b/testsuite/python/constant_pH.py
@@ -21,7 +21,7 @@
"""
import unittest as ut
import numpy as np
-import espressomd # pylint: disable=import-error
+import espressomd
from espressomd import reaction_ensemble
@@ -73,23 +73,20 @@ def ideal_alpha(cls, pH):
def test_ideal_titration_curve(self):
N0 = ReactionEnsembleTest.N0
- temperature = ReactionEnsembleTest.temperature
type_A = ReactionEnsembleTest.type_A
type_H = ReactionEnsembleTest.type_H
type_HA = ReactionEnsembleTest.type_HA
- box_l = ReactionEnsembleTest.system.box_l
system = ReactionEnsembleTest.system
RE = ReactionEnsembleTest.RE
# chemical warmup - get close to chemical equilibrium before we start
# sampling
RE.reaction(40 * N0)
- volume = np.prod(self.system.box_l) # cuboid box
average_NH = 0.0
average_NHA = 0.0
average_NA = 0.0
num_samples = 1000
- for i in range(num_samples):
+ for _ in range(num_samples):
RE.reaction(10)
average_NH += system.number_of_particles(type=type_H)
average_NHA += system.number_of_particles(type=type_HA)
diff --git a/testsuite/python/constraint_shape_based.py b/testsuite/python/constraint_shape_based.py
index 455b80dc12c..f1ecd09f516 100644
--- a/testsuite/python/constraint_shape_based.py
+++ b/testsuite/python/constraint_shape_based.py
@@ -66,8 +66,8 @@ def test_sphere(self):
* (rad + distance),
math.cos(theta_angle) * (rad + distance)]) + rad
- shape_dist, shape_dist_vec = sphere_shape.call_method(
- "calc_distance", position=pos.tolist())
+ shape_dist, _ = sphere_shape.calc_distance(
+ position=pos.tolist())
self.assertAlmostEqual(shape_dist, -distance)
def test_ellipsoid(self):
@@ -245,8 +245,8 @@ def test_cylinder(self):
phi_rot_point = np.dot(
phi_rot_matrix, start_point - center) + center
- shape_dist, shape_dist_vec = cylinder_shape_finite.call_method(
- "calc_distance", position=phi_rot_point.tolist())
+ shape_dist, _ = cylinder_shape_finite.calc_distance(
+ position=phi_rot_point.tolist())
dist = -distance
if distance > 0.0:
@@ -642,8 +642,7 @@ def test_rhomboid(self):
[x + (self.box_l + length[0] - x_range) / 2.0,
y + (self.box_l + length[1] - y_range) / 2.0,
z + (self.box_l + length[2] - z_range) / 2.0])
- shape_dist, shape_dist_vec = rhomboid_shape.call_method(
- "calc_distance",
+ shape_dist, shape_dist_vec = rhomboid_shape.calc_distance(
position=pos.tolist())
outside = False
@@ -837,8 +836,7 @@ def test_torus(self):
phi_rot_matrix,
theta_rot_point - center) + center
- shape_dist, shape_dist_vec = torus_shape.call_method(
- "calc_distance",
+ shape_dist, _ = torus_shape.calc_distance(
position=phi_rot_point.tolist())
self.assertAlmostEqual(shape_dist, distance)
diff --git a/testsuite/python/coulomb_cloud_wall.py b/testsuite/python/coulomb_cloud_wall.py
index 850b1a32f59..611d8ffaca7 100644
--- a/testsuite/python/coulomb_cloud_wall.py
+++ b/testsuite/python/coulomb_cloud_wall.py
@@ -16,7 +16,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
-import os
import unittest as ut
import unittest_decorators as utx
import numpy as np
diff --git a/testsuite/python/coulomb_mixed_periodicity.py b/testsuite/python/coulomb_mixed_periodicity.py
index 509dbedc408..e7e950b876f 100644
--- a/testsuite/python/coulomb_mixed_periodicity.py
+++ b/testsuite/python/coulomb_mixed_periodicity.py
@@ -16,7 +16,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
-import os
import unittest as ut
import unittest_decorators as utx
import numpy as np
diff --git a/testsuite/python/data/gen_coulomb_2d_ref_data.py b/testsuite/python/data/gen_coulomb_2d_ref_data.py
index 233b47aff2b..c5e36626a8c 100644
--- a/testsuite/python/data/gen_coulomb_2d_ref_data.py
+++ b/testsuite/python/data/gen_coulomb_2d_ref_data.py
@@ -14,21 +14,19 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-import sys
-from scipy import *
-import numpy.linalg as linalg
+import scipy
box_l = 10
-data = genfromtxt("coulomb_mixed_periodicity_system.data")
+data = scipy.genfromtxt("coulomb_mixed_periodicity_system.data")
n = data.shape[0]
pos = data[:, 1:4]
q = data[:, 4]
-forces = zeros((n, 3))
+forces = scipy.zeros((n, 3))
energy = 0.
-q1q2 = outer(q, q)
+q1q2 = scipy.outer(q, q)
images = 2000
for i in range(n):
@@ -36,24 +34,25 @@
for y in range(-images, images + 1, 1):
if x**2 + y**2 > images**2:
continue
- pos_diff = pos[i] - (pos + array((x, y, 0)) * box_l)
- r = sqrt(sum(pos_diff**2, 1))
+ pos_diff = pos[i] - (pos + scipy.array((x, y, 0)) * box_l)
+ r = scipy.sqrt(scipy.sum(pos_diff**2, 1))
r3 = r**3
qq = q1q2[i, :]
tmp = qq / r
- tmp[abs(tmp) == inf] = 0
- energy += sum(tmp)
+ tmp[abs(tmp) == scipy.inf] = 0
+ energy += scipy.sum(tmp)
pref = qq / r**3
pref = pref.reshape((n, 1))
- tmp = pos_diff * hstack((pref, pref, pref))
+ tmp = pos_diff * scipy.hstack((pref, pref, pref))
- forces += nan_to_num(tmp)
+ forces += scipy.nan_to_num(tmp)
-ids = arange(n)
+ids = scipy.arange(n)
forces *= -1
-savetxt("coulomb_mixed_periodicity_system.data",
- hstack((ids.reshape((n, 1)), pos, q.reshape((n, 1)), forces)))
+scipy.savetxt(
+ "coulomb_mixed_periodicity_system.data",
+ scipy.hstack((ids.reshape((n, 1)), pos, q.reshape((n, 1)), forces)))
diff --git a/testsuite/python/dawaanr-and-bh-gpu.py b/testsuite/python/dawaanr-and-bh-gpu.py
index 9c9da2847a9..974f16b4654 100644
--- a/testsuite/python/dawaanr-and-bh-gpu.py
+++ b/testsuite/python/dawaanr-and-bh-gpu.py
@@ -130,21 +130,21 @@ def test(self):
ratio_dawaanr_bh_gpu * np.array(bhgpu_t[i])),
msg='Torques on particle do not match. i={0} dawaanr_t={1} '
'ratio_dawaanr_bh_gpu*bhgpu_t={2}'.format(
- i, np.array(dawaanr_t[i]),
- ratio_dawaanr_bh_gpu * np.array(bhgpu_t[i])))
+ i, np.array(dawaanr_t[i]),
+ ratio_dawaanr_bh_gpu * np.array(bhgpu_t[i])))
self.assertTrue(
self.vectorsTheSame(
np.array(dawaanr_f[i]),
ratio_dawaanr_bh_gpu * np.array(bhgpu_f[i])),
msg='Forces on particle do not match: i={0} dawaanr_f={1} '
'ratio_dawaanr_bh_gpu*bhgpu_f={2}'.format(
- i, np.array(dawaanr_f[i]),
- ratio_dawaanr_bh_gpu * np.array(bhgpu_f[i])))
+ i, np.array(dawaanr_f[i]),
+ ratio_dawaanr_bh_gpu * np.array(bhgpu_f[i])))
self.assertLessEqual(
abs(dawaanr_e - bhgpu_e * ratio_dawaanr_bh_gpu),
abs(1E-3 * dawaanr_e),
msg='Energies for dawaanr {0} and bh_gpu {1} do not match.'
- .format(dawaanr_e, ratio_dawaanr_bh_gpu * bhgpu_e))
+ .format(dawaanr_e, ratio_dawaanr_bh_gpu * bhgpu_e))
self.system.integrator.run(steps=0, recalc_forces=True)
diff --git a/testsuite/python/domain_decomposition.py b/testsuite/python/domain_decomposition.py
index 223584b94cc..e074e765950 100644
--- a/testsuite/python/domain_decomposition.py
+++ b/testsuite/python/domain_decomposition.py
@@ -38,7 +38,7 @@ def test_resort(self):
# And now change their positions
for i in range(n_part):
- self.system.part[i].pos = pos = np.random.random(3)
+ self.system.part[i].pos = np.random.random(3)
# Distribute the particles on the nodes
part_dist = self.system.cell_system.resort()
diff --git a/testsuite/python/dpd.py b/testsuite/python/dpd.py
index c6ddbd50050..637d9ccf4bf 100644
--- a/testsuite/python/dpd.py
+++ b/testsuite/python/dpd.py
@@ -231,7 +231,7 @@ def test_linear_weight_function(self):
trans_weight_function=1, trans_gamma=gamma, trans_r_cut=1.4)
def omega(dist, r_cut):
- return (1. - dist / r_cut)
+ return 1. - dist / r_cut
s.part.add(id=0, pos=[5, 5, 5], type=0, v=[0, 0, 0])
v = [.5, .8, .3]
@@ -448,7 +448,7 @@ def calc_stress(dist, vel_diff):
def test_momentum_conservation(self):
r_cut = 1.0
gamma = 5.
- r_cut = 2.9
+ r_cut = 2.9
s = self.s
s.thermostat.set_dpd(kT=1.3, seed=42)
@@ -460,7 +460,7 @@ def test_momentum_conservation(self):
weight_function=1, gamma=gamma, r_cut=r_cut,
trans_weight_function=1, trans_gamma=gamma / 2.0, trans_r_cut=r_cut)
momentum = np.matmul(s.part[:].v.T, s.part[:].mass)
- for i in range(10):
+ for _ in range(10):
s.integrator.run(25)
np.testing.assert_array_less(np.zeros((3, 3)), np.abs(s.part[:].f))
np.testing.assert_allclose(
diff --git a/testsuite/python/drude.py b/testsuite/python/drude.py
index d3f7ed54638..39bb2f70cd2 100644
--- a/testsuite/python/drude.py
+++ b/testsuite/python/drude.py
@@ -61,7 +61,6 @@ def test(self):
# TIMESTEP
fs_to_md_time = 1.0e-2
time_step_fs = 0.5
- time_step_ns = time_step_fs * 1e-6
dt = time_step_fs * fs_to_md_time
# COM TEMPERATURE
@@ -214,7 +213,7 @@ def measure_dipole_moments():
system.integrator.run(115)
- for i in range(100):
+ for _ in range(100):
system.integrator.run(1)
dm_pf6.append(dipole_moment(0, 1))
diff --git a/testsuite/python/ek_charged_plate.py b/testsuite/python/ek_charged_plate.py
index f6f293a0fe8..09bac464366 100644
--- a/testsuite/python/ek_charged_plate.py
+++ b/testsuite/python/ek_charged_plate.py
@@ -40,11 +40,10 @@ def test(self):
box_x = 20
box_y = 20
box_z = 20
- system.box_l = box_l = [box_x, box_y, box_z]
+ system.box_l = [box_x, box_y, box_z]
system.cell_system.skin = 0.2
system.time_step = 0.1
system.periodicity = [1, 1, 1]
- coulomb_accuracy = 1.0e-4
bjerrum_length = 2.13569
agrid = 0.5
diff --git a/testsuite/python/ek_common.py b/testsuite/python/ek_common.py
index 9e21c758386..9107a3fc019 100644
--- a/testsuite/python/ek_common.py
+++ b/testsuite/python/ek_common.py
@@ -22,18 +22,15 @@
def solve(xi, d, bjerrum_length, sigma, valency):
- pi = math.pi
el_char = 1.0
- return xi * math.tan(xi * d / 2.0) + 2.0 * pi * \
+ return xi * math.tan(xi * d / 2.0) + 2.0 * math.pi * \
bjerrum_length * sigma / (valency * el_char)
# function to calculate the density
def density(x, xi, bjerrum_length):
- pi = math.pi
- kb = 1.0
- return (xi * xi) / (2.0 * pi * bjerrum_length *
+ return (xi * xi) / (2.0 * math.pi * bjerrum_length *
math.cos(xi * x) * math.cos(xi * x))
# function to calculate the velocity
@@ -47,16 +44,14 @@ def velocity(
force,
viscosity_kinematic,
density_water):
- pi = math.pi
return force * math.log(math.cos(xi * x) / math.cos(xi * d / 2.0)) / \
- (2.0 * pi * bjerrum_length * viscosity_kinematic * density_water)
+ (2.0 * math.pi * bjerrum_length * viscosity_kinematic * density_water)
# function to calculate the nonzero component of the pressure tensor
def pressure_tensor_offdiagonal(x, xi, bjerrum_length, force):
- pi = math.pi
- return force * xi * math.tan(xi * x) / (2.0 * pi * bjerrum_length)
+ return force * xi * math.tan(xi * x) / (2.0 * math.pi * bjerrum_length)
# function to calculate the hydrostatic pressure
diff --git a/testsuite/python/ek_eof_one_species_base.py b/testsuite/python/ek_eof_one_species_base.py
index 35e52b02b81..0d58e852400 100644
--- a/testsuite/python/ek_eof_one_species_base.py
+++ b/testsuite/python/ek_eof_one_species_base.py
@@ -51,7 +51,7 @@
('valency', 1.0)])
-def bisection(params):
+def bisection():
# initial parameters for bisection scheme
size = math.pi / (2.0 * params_base['width'])
pnt0 = 0.0
@@ -60,7 +60,7 @@ def bisection(params):
# the bisection scheme
tol = 1.0e-08
- while (size > tol):
+ while size > tol:
val0 = ek_common.solve(
pnt0,
params_base['width'],
@@ -81,7 +81,7 @@ def bisection(params):
params_base['valency'])
if (val0 < 0.0 and val1 > 0.0):
- if (valm < 0.0):
+ if valm < 0.0:
pnt0 = pntm
size = size / 2.0
pntm = pnt0 + size
@@ -90,7 +90,7 @@ def bisection(params):
size = size / 2.0
pntm = pnt1 - size
elif (val0 > 0.0 and val1 < 0.0):
- if (valm < 0.0):
+ if valm < 0.0:
pnt1 = pntm
size = size / 2.0
pntm = pnt1 - size
@@ -109,7 +109,7 @@ def bisection(params):
class ek_eof_one_species(ut.TestCase):
system = espressomd.System(box_l=[1.0, 1.0, 1.0])
system.seed = system.cell_system.get_state()['n_nodes'] * [1234]
- xi = bisection(params_base)
+ xi = bisection()
def run_test(self, params):
system = self.system
@@ -173,7 +173,6 @@ def run_test(self, params):
params_base['agrid'] >= params_base['padding'] and i *
params_base['agrid'] < system.box_l[params['non_periodic_dir']] -
params_base['padding']):
- xvalue = i * params_base['agrid'] - params_base['padding']
position = i * params_base['agrid'] - params_base['padding'] - \
params_base['width'] / 2.0 + params_base['agrid'] / 2.0
diff --git a/testsuite/python/ek_fluctuations.py b/testsuite/python/ek_fluctuations.py
index 1bcd84d72dd..e86c7937919 100644
--- a/testsuite/python/ek_fluctuations.py
+++ b/testsuite/python/ek_fluctuations.py
@@ -46,7 +46,7 @@ def test(self):
diff = 1.0
agrid = 1.0
- system.box_l = box_l = [box_x, box_y, box_z]
+ system.box_l = [box_x, box_y, box_z]
system.time_step = time_step
system.cell_system.skin = 0.2
system.thermostat.turn_off()
@@ -82,7 +82,7 @@ def test(self):
count = 0
# Integrate
- for t in range(sample_steps):
+ for _ in range(sample_steps):
system.integrator.run(integration_steps)
for i in range(box_x):
for j in range(box_y):
diff --git a/testsuite/python/electrostaticInteractions.py b/testsuite/python/electrostaticInteractions.py
index 2c74c721bec..13eb6c5047c 100644
--- a/testsuite/python/electrostaticInteractions.py
+++ b/testsuite/python/electrostaticInteractions.py
@@ -21,7 +21,7 @@
import numpy as np
import espressomd
-from espressomd import electrostatics
+import espressomd.electrostatics
@utx.skipIfMissingFeatures(["ELECTROSTATICS"])
diff --git a/testsuite/python/engine_lb.py b/testsuite/python/engine_lb.py
index 7b32fac744c..af30d7a663a 100644
--- a/testsuite/python/engine_lb.py
+++ b/testsuite/python/engine_lb.py
@@ -28,7 +28,7 @@ class SwimmerTest():
'dens': 1.1,
'visc': 1.2,
'kT': 0,
- 'tau': system.time_step}
+ 'tau': system.time_step}
gamma = 0.3
lbf = None
@@ -40,7 +40,7 @@ def add_all_types_of_swimmers(
"""Places all combinations of pusher/puller and f_swim/v_swim
in a box, either in the corners or around the center
"""
- system = self.system
+ system = self.system
plus_x = np.sqrt([.5, 0, .5, 0])
plus_y = np.sqrt([0, 0, .5, .5])
plus_z = np.sqrt([.5, 0, 0, .5])
@@ -80,7 +80,7 @@ def test_conflicting_parameters(self):
"""
swimmer = self.system.part.add(pos=[3] * 3)
with self.assertRaises(Exception):
- swimmer.swimming = {"v_swim": 0.3, "f_swim": 0.6}
+ swimmer.swimming = {"v_swim": 0.3, "f_swim": 0.6}
def test_momentum_conservation(self):
"""friction as well as 'active' forces apply to particles
@@ -90,7 +90,7 @@ def test_momentum_conservation(self):
self.system.integrator.run(20, reuse_forces=True)
tot_mom = self.system.analysis.linear_momentum(include_particles=True,
include_lbfluid=True)
- np.testing.assert_allclose(tot_mom, 3 * [0.], atol=self.tol)
+ np.testing.assert_allclose(tot_mom, 3 * [0.], atol=self.tol)
def test_particle_forces(self):
"""run through all swimmers to check expected forces
@@ -106,7 +106,7 @@ def test_particle_forces(self):
# due to dt/2 time-shift between force calculation and LB-update,
# v_swimmer has to be calculated at the half step
v_swimmer = swimmer.v + \
- 0.5 * self.system.time_step * swimmer.f / swimmer.mass
+ 0.5 * self.system.time_step * swimmer.f / swimmer.mass
# for friction coupling, the old fluid at the new position is used
v_fluid = self.lbf.get_interpolated_velocity(
swimmer.pos + self.system.time_step * v_swimmer)
@@ -126,7 +126,7 @@ def check_fluid_force(self, swimmer):
@utx.skipIfMissingFeatures(["ENGINE", "ROTATION", "MASS"])
-class SwimmerTestCPU(SwimmerTest, ut.TestCase):
+class SwimmerTestCPU(SwimmerTest, ut.TestCase):
def setUp(self):
self.tol = 1e-10
@@ -145,15 +145,15 @@ def test_rotfric_exception(self):
# with rot_fric it is not
with self.assertRaises(Exception):
self.system.part.add(pos=[0, 0, 0], rotation=3 * [True],
- swimming={"f_swim": 0.1,
- "mode": "pusher",
+ swimming={"f_swim": 0.1,
+ "mode": "pusher",
"rotational_friction": 0.3})
self.system.integrator.run(3)
@utx.skipIfMissingGPU()
@utx.skipIfMissingFeatures(["ENGINE", "ROTATION", "MASS"])
-class SwimmerTestGPU(SwimmerTest, ut.TestCase):
+class SwimmerTestGPU(SwimmerTest, ut.TestCase):
def setUp(self):
self.tol = 1e-5
@@ -162,11 +162,11 @@ def setUp(self):
self.system.thermostat.set_lb(LB_fluid=self.lbf, gamma=self.gamma)
def test_particle_torques(self):
- """setup shear flow and check if resulting torques match
+ """setup shear flow and check if resulting torques match
the formulae in the core
"""
- bottom = shapes.Wall(normal=[0, 0, 1],
+ bottom = shapes.Wall(normal=[0, 0, 1],
dist=self.LB_params['agrid'])
top = shapes.Wall(normal=[0, 0, -1],
dist=-self.system.box_l[2] + self.LB_params['agrid'])
@@ -186,12 +186,12 @@ def test_particle_torques(self):
director = swimmer.director
dip_len = swimmer.swimming["dipole_length"]
mode_fac = 1. if swimmer.swimming["mode"] == "puller" else -1.
- source_pos = swimmer.pos + mode_fac * dip_len * director
+ source_pos = swimmer.pos + mode_fac * dip_len * director
v_center = self.lbf.get_interpolated_velocity(swimmer.pos)
v_source = self.lbf.get_interpolated_velocity(source_pos)
diff = v_center - v_source
- cross = np.cross(diff, director)
+ cross = np.cross(diff, director)
# half-step omega with isotropic rinertia
omega_part = swimmer.omega_lab + 0.5 * self.system.time_step * \
swimmer.torque_lab / swimmer.rinertia[0]
@@ -204,7 +204,7 @@ def test_particle_torques(self):
np.testing.assert_allclose(
swimmer.torque_lab,
torque,
- atol=self.tol)
+ atol=self.tol)
if __name__ == "__main__":
diff --git a/testsuite/python/exclusions.py b/testsuite/python/exclusions.py
index 68cdd26ee6f..8ea7eb3f3dd 100644
--- a/testsuite/python/exclusions.py
+++ b/testsuite/python/exclusions.py
@@ -54,7 +54,7 @@ def test_transfer(self):
self.s.part[0].exclusions = [1, 2, 3]
- for i in range(15):
+ for _ in range(15):
self.s.integrator.run(100)
self.assertTrue((self.s.part[0].exclusions == [1, 2, 3]).all())
diff --git a/testsuite/python/experimental_decorator.py b/testsuite/python/experimental_decorator.py
index deb1268d4de..725fdca8db0 100644
--- a/testsuite/python/experimental_decorator.py
+++ b/testsuite/python/experimental_decorator.py
@@ -34,10 +34,10 @@ class RequireExperimental(ut.TestCase):
def test(self):
if espressomd.has_features("EXPERIMENTAL_FEATURES"):
- x = A(1, 3.0)
+ _ = A(1, 3.0)
else:
- with self.assertRaisesRegexp(Exception, "because"):
- x = A(1, 3.0)
+ with self.assertRaisesRegex(Exception, "because"):
+ _ = A(1, 3.0)
if __name__ == "__main__":
diff --git a/testsuite/python/h5md.py b/testsuite/python/h5md.py
index 21db021b232..3657677acd4 100644
--- a/testsuite/python/h5md.py
+++ b/testsuite/python/h5md.py
@@ -25,7 +25,7 @@
import unittest as ut
import unittest_decorators as utx
import numpy as np
-import espressomd # pylint: disable=import-error
+import espressomd
import h5py # h5py has to be imported *after* espressomd (MPI)
from espressomd.interactions import Virtual
@@ -130,7 +130,7 @@ class H5mdTestOrdered(CommonTests):
@classmethod
def setUpClass(cls):
write_ordered = True
- from espressomd.io.writer import h5md # pylint: disable=import-error
+ from espressomd.io.writer import h5md
h5 = h5md.H5md(
filename="test.h5",
write_pos=True,
@@ -170,7 +170,7 @@ class H5mdTestUnordered(CommonTests):
@classmethod
def setUpClass(cls):
write_ordered = False
- from espressomd.io.writer import h5md # pylint: disable=import-error
+ from espressomd.io.writer import h5md
h5 = h5md.H5md(
filename="test.h5",
write_pos=True,
diff --git a/testsuite/python/interactions_bond_angle.py b/testsuite/python/interactions_bond_angle.py
index 3a674422b48..4ace8005dd5 100644
--- a/testsuite/python/interactions_bond_angle.py
+++ b/testsuite/python/interactions_bond_angle.py
@@ -19,7 +19,6 @@
import espressomd
import numpy as np
import unittest as ut
-import unittest_decorators as utx
class InteractionsAngleBondTest(ut.TestCase):
@@ -129,7 +128,7 @@ def run_test(self, bond_instance, force_func, energy_func, phi0):
# No pressure (isotropic compression preserves angles)
self.assertAlmostEqual(
self.system.analysis.pressure()["bonded"], 0, delta=1E-12)
- # Stress tensor trace=0 (isotropic compression preserves angles,
+ # Stress tensor trace=0 (isotropic compression preserves angles,
# consistency with pressure)
self.assertAlmostEqual(
np.trace(self.system.analysis.stress_tensor()["bonded"]), 0, delta=1E-12)
diff --git a/testsuite/python/interactions_bonded.py b/testsuite/python/interactions_bonded.py
index 94a109aca77..1a2610ae19c 100644
--- a/testsuite/python/interactions_bonded.py
+++ b/testsuite/python/interactions_bonded.py
@@ -184,7 +184,7 @@ def run_test(self, bond_instance, force_func, energy_func, min_dist,
if test_breakage:
self.system.part[1].pos = self.system.part[0].pos \
+ self.axis * cutoff * (1.01)
- with self.assertRaisesRegexp(Exception, "Encountered errors during integrate"):
+ with self.assertRaisesRegex(Exception, "Encountered errors during integrate"):
self.system.integrator.run(recalc_forces=True, steps=0)
diff --git a/testsuite/python/interactions_dihedral.py b/testsuite/python/interactions_dihedral.py
index c6272c6d076..3013d6804a5 100644
--- a/testsuite/python/interactions_dihedral.py
+++ b/testsuite/python/interactions_dihedral.py
@@ -17,7 +17,6 @@
# along with this program. If not, see .
#
import unittest as ut
-import unittest_decorators as utx
import numpy as np
import espressomd
@@ -170,7 +169,6 @@ def test_tabulated_dihedral(self):
N = 111
d_phi = 2 * np.pi / N
# tabulated values for the range [0, 2*pi]
- tab_phi = [i * d_phi for i in range(N + 1)]
tab_energy = [np.cos(i * d_phi) for i in range(N + 1)]
tab_force = [np.cos(i * d_phi) for i in range(N + 1)]
diff --git a/testsuite/python/interactions_non-bonded.py b/testsuite/python/interactions_non-bonded.py
index 8df904b6e87..804ed735a99 100644
--- a/testsuite/python/interactions_non-bonded.py
+++ b/testsuite/python/interactions_non-bonded.py
@@ -446,8 +446,6 @@ def test_buckingham(self):
b_disc = 1.03
b_cut = 2.253
b_shift = 0.133
- b_f1 = 0.123
- b_f2 = 0.123
self.system.non_bonded_inter[0, 0].buckingham.set_params(
a=b_a, b=b_b, c=b_c, d=b_d, discont=b_disc, cutoff=b_cut,
@@ -612,8 +610,9 @@ def gradient(func, x0, dx=1.0e-7):
the approximated gradient of func at x0
"""
- def partial_x(x): return (func(x0 + x) - func(x0 - x)) / (
- 2.0 * np.linalg.norm(x))
+ def partial_x(x):
+ return (func(x0 + x) - func(x0 - x)) / (
+ 2.0 * np.linalg.norm(x))
delta = np.array([dx, 0.0, 0.0])
return np.array([partial_x(np.roll(delta, i)) for i in range(3)])
diff --git a/testsuite/python/langevin_thermostat.py b/testsuite/python/langevin_thermostat.py
index addce4a977c..7132c8fbe30 100644
--- a/testsuite/python/langevin_thermostat.py
+++ b/testsuite/python/langevin_thermostat.py
@@ -131,7 +131,7 @@ def test_02__friction_trans(self):
system.thermostat.set_langevin(kT=0, gamma=gamma_t_i, seed=41)
system.time = 0
- for i in range(100):
+ for _ in range(100):
system.integrator.run(10)
if espressomd.has_features("PARTICLE_ANISOTROPY"):
np.testing.assert_allclose(
@@ -175,7 +175,7 @@ def test_03__friction_rot(self):
rinertia = np.copy(system.part[0].rinertia)
else:
rinertia = np.array((1, 1, 1))
- for i in range(100):
+ for _ in range(100):
system.integrator.run(10)
if espressomd.has_features("PARTICLE_ANISOTROPY"):
np.testing.assert_allclose(
@@ -423,7 +423,6 @@ def test_06__diffusion(self):
# Decide on effective gamma rotation, since for rotation it is
# direction dependent
eff_gamma_rot = None
- per_part_eff_gamma_rot = None
if espressomd.has_features("PARTICLE_ANISOTROPY"):
eff_gamma_rot = gamma_rot_a
eff_per_part_gamma_rot = per_part_gamma_rot_a
diff --git a/testsuite/python/layered.py b/testsuite/python/layered.py
index acb34cd5006..9632828cf18 100644
--- a/testsuite/python/layered.py
+++ b/testsuite/python/layered.py
@@ -38,7 +38,7 @@ def test_resort(self):
# And now change their positions
for i in range(n_part):
- self.S.part[i].pos = pos = np.random.random(3)
+ self.S.part[i].pos = np.random.random(3)
# Distribute the particles on the nodes
part_dist = self.S.cell_system.resort()
diff --git a/testsuite/python/lb.py b/testsuite/python/lb.py
index 7a28de5ee1e..c2a91a27882 100644
--- a/testsuite/python/lb.py
+++ b/testsuite/python/lb.py
@@ -14,7 +14,6 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-import itertools
import unittest as ut
import unittest_decorators as utx
import numpy as np
@@ -110,7 +109,7 @@ def test_mass_momentum_thermostat(self):
all_temp_fluid = []
# Integration
- for i in range(self.params['int_times']):
+ for _ in range(self.params['int_times']):
self.system.integrator.run(self.params['int_steps'])
# Summation vars
@@ -245,7 +244,7 @@ def test_lb_node_set_get(self):
ext_force_density=[0, 0, 0])
self.system.actors.add(self.lbf)
- self.assertEqual(self.lbf.shape,
+ self.assertEqual(self.lbf.shape,
(
int(self.system.box_l[0] / self.params["agrid"]),
int(self.system.box_l[1] / self.params["agrid"]),
@@ -294,13 +293,13 @@ def test_grid_index(self):
ext_force_density=[0, 0, 0])
self.system.actors.add(self.lbf)
with self.assertRaises(ValueError):
- v = self.lbf[
+ _ = self.lbf[
int(self.params['box_l'] / self.params['agrid']) + 1, 0, 0].velocity
with self.assertRaises(ValueError):
- v = self.lbf[
+ _ = self.lbf[
0, int(self.params['box_l'] / self.params['agrid']) + 1, 0].velocity
with self.assertRaises(ValueError):
- v = self.lbf[
+ _ = self.lbf[
0, 0, int(self.params['box_l'] / self.params['agrid']) + 1].velocity
def test_incompatible_agrid(self):
diff --git a/testsuite/python/lb_boundary.py b/testsuite/python/lb_boundary.py
index e1e848a8048..8f9c139d893 100644
--- a/testsuite/python/lb_boundary.py
+++ b/testsuite/python/lb_boundary.py
@@ -69,10 +69,8 @@ def test_empty(self):
def test_clear(self):
lbb = self.system.lbboundaries
- b1 = lbb.add(
- espressomd.lbboundaries.LBBoundary(shape=self.wall_shape1))
- b2 = lbb.add(
- espressomd.lbboundaries.LBBoundary(shape=self.wall_shape1))
+ lbb.add(espressomd.lbboundaries.LBBoundary(shape=self.wall_shape1))
+ lbb.add(espressomd.lbboundaries.LBBoundary(shape=self.wall_shape1))
lbb.clear()
diff --git a/testsuite/python/lb_get_u_at_pos.py b/testsuite/python/lb_get_u_at_pos.py
index 61dc72b9779..72c2826c982 100644
--- a/testsuite/python/lb_get_u_at_pos.py
+++ b/testsuite/python/lb_get_u_at_pos.py
@@ -32,8 +32,8 @@ class TestLBGetUAtPos(ut.TestCase):
"""
@classmethod
- def setUpClass(self):
- self.params = {
+ def setUpClass(cls):
+ cls.params = {
'tau': 0.01,
'agrid': 0.5,
'box_l': [12.0, 12.0, 12.0],
@@ -42,31 +42,31 @@ def setUpClass(self):
'friction': 2.0,
'gamma': 1.5
}
- self.system = espressomd.System(box_l=[1.0, 1.0, 1.0])
- self.system.box_l = self.params['box_l']
- self.system.cell_system.skin = 0.4
- self.system.time_step = 0.01
- self.n_nodes_per_dim = int(self.system.box_l[0] / self.params['agrid'])
- for p in range(self.n_nodes_per_dim):
+ cls.system = espressomd.System(box_l=[1.0, 1.0, 1.0])
+ cls.system.box_l = cls.params['box_l']
+ cls.system.cell_system.skin = 0.4
+ cls.system.time_step = 0.01
+ cls.n_nodes_per_dim = int(cls.system.box_l[0] / cls.params['agrid'])
+ for p in range(cls.n_nodes_per_dim):
# Set particles exactly between two LB nodes in x direction.
- self.system.part.add(id=p,
- pos=[(p + 1) * self.params['agrid'],
- 0.5 * self.params['agrid'],
- 0.5 * self.params['agrid']])
- self.lb_fluid = lb.LBFluidGPU(
- visc=self.params['viscosity'],
- dens=self.params['dens'],
- agrid=self.params['agrid'],
- tau=self.params['tau'],
+ cls.system.part.add(id=p,
+ pos=[(p + 1) * cls.params['agrid'],
+ 0.5 * cls.params['agrid'],
+ 0.5 * cls.params['agrid']])
+ cls.lb_fluid = lb.LBFluidGPU(
+ visc=cls.params['viscosity'],
+ dens=cls.params['dens'],
+ agrid=cls.params['agrid'],
+ tau=cls.params['tau'],
)
- self.system.actors.add(self.lb_fluid)
- self.vels = np.zeros((self.n_nodes_per_dim, 3))
- self.vels[:, 0] = np.arange(self.n_nodes_per_dim, dtype=float)
- self.interpolated_vels = self.vels.copy()
- self.interpolated_vels[:, 0] += 0.5
- for n in range(self.n_nodes_per_dim):
- self.lb_fluid[n, 0, 0].velocity = self.vels[n, :]
- self.system.integrator.run(0)
+ cls.system.actors.add(cls.lb_fluid)
+ cls.vels = np.zeros((cls.n_nodes_per_dim, 3))
+ cls.vels[:, 0] = np.arange(cls.n_nodes_per_dim, dtype=float)
+ cls.interpolated_vels = cls.vels.copy()
+ cls.interpolated_vels[:, 0] += 0.5
+ for n in range(cls.n_nodes_per_dim):
+ cls.lb_fluid[n, 0, 0].velocity = cls.vels[n, :]
+ cls.system.integrator.run(0)
def test_get_u_at_pos(self):
"""
diff --git a/testsuite/python/lb_shear.py b/testsuite/python/lb_shear.py
index e1b35d41834..2673252a5ec 100644
--- a/testsuite/python/lb_shear.py
+++ b/testsuite/python/lb_shear.py
@@ -37,8 +37,8 @@
# Box size will be H +2 AGRID to make room for walls.
# The number of grid cells should be divisible by four and 3 in all directions
# for testing on multiple mpi nodes.
-H = 12 * AGRID
-W = 6 * AGRID
+H = 12 * AGRID
+W = 6 * AGRID
SHEAR_VELOCITY = 0.3
LB_PARAMS = {'agrid': AGRID,
@@ -118,7 +118,7 @@ def check_profile(self, shear_plane_normal, shear_direction):
t0 = self.system.time
sample_points = int(H / AGRID - 1)
- for i in range(9):
+ for _ in range(9):
self.system.integrator.run(50)
v_expected = shear_flow(
@@ -164,7 +164,7 @@ def check_profile(self, shear_plane_normal, shear_direction):
np.copy(wall1.get_force()),
-np.copy(wall2.get_force()),
atol=1E-4)
- np.testing.assert_allclose(np.copy(wall1.get_force()),
+ np.testing.assert_allclose(np.copy(wall1.get_force()),
shear_direction * SHEAR_VELOCITY / H * W**2 * VISC, atol=2E-4)
def test(self):
diff --git a/testsuite/python/lb_stokes_sphere.py b/testsuite/python/lb_stokes_sphere.py
index 97af8c25db3..feb5b90c4e9 100644
--- a/testsuite/python/lb_stokes_sphere.py
+++ b/testsuite/python/lb_stokes_sphere.py
@@ -27,22 +27,22 @@
# boundaries, where the velocity is fixed to $v.
#
import espressomd
-from espressomd import lb, lbboundaries, shapes, has_features
+from espressomd import lbboundaries, shapes
import unittest as ut
import unittest_decorators as utx
import numpy as np
# Define the LB Parameters
TIME_STEP = 0.4
-AGRID = 0.6
-KVISC = 6
-DENS = 2.3
+AGRID = 0.6
+KVISC = 6
+DENS = 2.3
LB_PARAMS = {'agrid': AGRID,
'dens': DENS,
'visc': KVISC,
'tau': TIME_STEP}
# System setup
-radius = 8 * AGRID
+radius = 8 * AGRID
box_width = 62 * AGRID
real_width = box_width + 2 * AGRID
box_length = 62 * AGRID
diff --git a/testsuite/python/lb_switch.py b/testsuite/python/lb_switch.py
index cd9a83f0ed7..29765c26189 100644
--- a/testsuite/python/lb_switch.py
+++ b/testsuite/python/lb_switch.py
@@ -33,7 +33,6 @@ def switch_test(self, GPU=False):
system = self.system
system.actors.clear()
system.part.add(pos=[1., 1., 1.], v=[1., 0, 0], fix=[1, 1, 1])
- ext_force_density = [0.2, 0.3, 0.15]
lb_fluid_params = {'agrid': 2.0, 'dens': 1.0, 'visc': 1.0, 'tau': 0.03}
friction_1 = 1.5
diff --git a/testsuite/python/mass-and-rinertia_per_particle.py b/testsuite/python/mass-and-rinertia_per_particle.py
index 20a27123ee4..b1f2f21146c 100644
--- a/testsuite/python/mass-and-rinertia_per_particle.py
+++ b/testsuite/python/mass-and-rinertia_per_particle.py
@@ -20,7 +20,6 @@
from numpy.random import uniform
import espressomd
import math
-import random
@utx.skipIfMissingFeatures(["MASS", "PARTICLE_ANISOTROPY",
@@ -33,7 +32,7 @@ class ThermoTest(ut.TestCase):
kT = 0.0
gamma_global = np.zeros((3))
gamma_global_rot = np.zeros((3))
- # Test ranges
+ # Test ranges
gamma_min = 5.
gamma_max = 10.
@@ -243,7 +242,7 @@ def check_dissipation(self, n):
"""
tol = 1.2E-3
- for step in range(100):
+ for _ in range(100):
self.system.integrator.run(2)
for i in range(n):
for k in range(2):
diff --git a/testsuite/python/minimize_energy.py b/testsuite/python/minimize_energy.py
index 0cce0e38c3b..b6542633157 100644
--- a/testsuite/python/minimize_energy.py
+++ b/testsuite/python/minimize_energy.py
@@ -79,7 +79,7 @@ def test_relaxation(self):
self.system.analysis.energy()["total"], 0, places=10)
np.testing.assert_allclose(np.copy(self.system.part[:].f), 0.)
if self.test_rotation:
- np.testing.assert_allclose(np.copy(self.system.part[:].dip),
+ np.testing.assert_allclose(np.copy(self.system.part[:].dip),
np.hstack((-np.ones((self.n_part, 1)), np.zeros((self.n_part, 1)), np.zeros((self.n_part, 1)))), atol=1E-9)
def test_rescaling(self):
diff --git a/testsuite/python/mmm1d.py b/testsuite/python/mmm1d.py
index 98bce1deff2..4768ff15b5a 100644
--- a/testsuite/python/mmm1d.py
+++ b/testsuite/python/mmm1d.py
@@ -24,7 +24,7 @@
import espressomd
-if(not espressomd.has_features(("ELECTROSTATICS"))):
+if not espressomd.has_features("ELECTROSTATICS"):
sys.exit()
@@ -102,7 +102,7 @@ def test_with_analytical_result(self, prefactor=1.0, accuracy=1e-4):
abs(f_measured[2] - target_force_z_config),
accuracy,
msg="Measured force in z has a deviation which is too big compared to analytical result "
- + str(abs(f_measured[2] - target_force_z_config)))
+ + str(abs(f_measured[2] - target_force_z_config)))
self.assertLess(
abs(energy_measured - target_energy_config),
self.allowed_error,
@@ -110,11 +110,11 @@ def test_with_analytical_result(self, prefactor=1.0, accuracy=1e-4):
def test_bjerrum_length_change(self):
self.system.part.clear()
- self.system.actors.clear() # tear down previous actors
+ self.system.actors.clear() # tear down previous actors
prefactor = 2
mmm1d = self.MMM1D(prefactor=prefactor, maxPWerror=1e-20)
- self.system.actors.add(mmm1d)
- self.test_with_analytical_result(prefactor=prefactor, accuracy=0.0017)
+ self.system.actors.add(mmm1d)
+ self.test_with_analytical_result(prefactor=prefactor, accuracy=0.0017)
@utx.skipIfMissingFeatures(["ELECTROSTATICS", "MMM1D_GPU"])
diff --git a/testsuite/python/npt.py b/testsuite/python/npt.py
index 1f5829de32c..3fa4d08db05 100644
--- a/testsuite/python/npt.py
+++ b/testsuite/python/npt.py
@@ -20,7 +20,6 @@
import unittest_decorators as utx
import numpy as np
import espressomd
-from espressomd import thermostat
import tests_common
diff --git a/testsuite/python/observable_cylindrical.py b/testsuite/python/observable_cylindrical.py
index 01f1704fb3c..6590e74a502 100644
--- a/testsuite/python/observable_cylindrical.py
+++ b/testsuite/python/observable_cylindrical.py
@@ -93,7 +93,7 @@ def set_particles(self):
(len(self.params['ids']) + 1) - self.params['center'][2]])
v_y = (position[0] * np.sqrt(position[0]**2 + position[1]**2) *
self.v_phi + position[1] * self.v_r) / np.sqrt(
- position[0]**2 + position[1]**2)
+ position[0]**2 + position[1]**2)
v_x = (self.v_r * np.sqrt(position[0]**2 + position[1]**2)
- position[1] * v_y) / position[0]
velocity = np.array([v_x, v_y, self.v_z])
diff --git a/testsuite/python/observable_cylindricalLB.py b/testsuite/python/observable_cylindricalLB.py
index 973a8fc30db..98d8148ef12 100644
--- a/testsuite/python/observable_cylindricalLB.py
+++ b/testsuite/python/observable_cylindricalLB.py
@@ -14,7 +14,6 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-import sys
import numpy as np
import unittest as ut
import unittest_decorators as utx
@@ -101,7 +100,7 @@ def set_fluid_velocity(self):
self.v_phi = 2.5
self.v_z = 1.5
node_positions = np.arange(-4.5, 5.0, 1.0)
- for i, value in enumerate(node_positions):
+ for i, _ in enumerate(node_positions):
position = np.array(
[node_positions[i], node_positions[i], node_positions[i]])
v_y = (position[0] * np.sqrt(position[0]**2 + position[1]**2) * self.v_phi +
diff --git a/testsuite/python/observable_profileLB.py b/testsuite/python/observable_profileLB.py
index 90630d871c2..4ee4e8df700 100644
--- a/testsuite/python/observable_profileLB.py
+++ b/testsuite/python/observable_profileLB.py
@@ -86,8 +86,10 @@ def test_velocity_profile(self):
for z in range(obs_data.shape[2]):
self.assertAlmostEqual(
obs_data[x, y, z, 0], float(x), places=5)
- self.assertEqual(obs.n_values(), LB_VELOCITY_PROFILE_PARAMS[
- 'n_x_bins'] * LB_VELOCITY_PROFILE_PARAMS['n_y_bins'] * LB_VELOCITY_PROFILE_PARAMS['n_z_bins'] * 3)
+ self.assertEqual(obs.n_values(),
+ LB_VELOCITY_PROFILE_PARAMS['n_x_bins'] *
+ LB_VELOCITY_PROFILE_PARAMS['n_y_bins'] *
+ LB_VELOCITY_PROFILE_PARAMS['n_z_bins'] * 3)
def test_error_sampling_delta_of_0(self):
lb_velocity_params_local = copy.copy(LB_VELOCITY_PROFILE_PARAMS)
@@ -95,7 +97,7 @@ def test_error_sampling_delta_of_0(self):
lb_velocity_params_local['sampling_delta_y'] = 0.0
lb_velocity_params_local['sampling_delta_z'] = 0.0
with self.assertRaises(RuntimeError):
- obs2 = espressomd.observables.LBVelocityProfile(
+ _ = espressomd.observables.LBVelocityProfile(
**lb_velocity_params_local)
def test_error_if_no_LB(self):
diff --git a/testsuite/python/observables.py b/testsuite/python/observables.py
index a6a69e3ac17..059dab180b8 100644
--- a/testsuite/python/observables.py
+++ b/testsuite/python/observables.py
@@ -77,11 +77,11 @@ def func(self):
part_data = getattr(self.system.part[id_list], pprop_name)
# Reshape and aggregate to linear array
if len(part_data.shape) > 1:
- if (agg_type == "average"):
+ if agg_type == "average":
part_data = np.average(part_data, 0)
- if (agg_type == "sum"):
+ if agg_type == "sum":
part_data = np.sum(part_data, 0)
- if (agg_type == 'com'):
+ if agg_type == 'com':
part_data = calc_com_x(self.system, pprop_name)
part_data = part_data.flatten()
diff --git a/testsuite/python/oif_volume_conservation.py b/testsuite/python/oif_volume_conservation.py
index e0524b6ef7b..4aed1b271a2 100644
--- a/testsuite/python/oif_volume_conservation.py
+++ b/testsuite/python/oif_volume_conservation.py
@@ -55,7 +55,6 @@ def test(self):
print("initial diameter = " + str(diameter_init))
# OIF object is being stretched by factor 1.5
- maxCycle = 500
system.part[:].pos = (system.part[:].pos - 5) * 1.5 + 5
diameter_stretched = cell0.diameter()
@@ -63,7 +62,7 @@ def test(self):
# main integration loop
# OIF object is let to relax into relaxed shape of the sphere
- for i in range(3):
+ for _ in range(3):
system.integrator.run(steps=90)
diameter_final = cell0.diameter()
print("final diameter = " + str(diameter_final))
diff --git a/testsuite/python/p3m_electrostatic_pressure.py b/testsuite/python/p3m_electrostatic_pressure.py
index 6c0af34534c..79229305340 100644
--- a/testsuite/python/p3m_electrostatic_pressure.py
+++ b/testsuite/python/p3m_electrostatic_pressure.py
@@ -90,7 +90,7 @@ def setUp(self):
num_part = 40
mass = 1
- for i in range(num_part):
+ for _ in range(num_part):
self.system.part.add(
pos=np.random.random(3) * self.system.box_l, q=1,
v=np.sqrt(self.kT / mass) * np.random.normal(loc=[0, 0, 0]))
@@ -117,7 +117,6 @@ def setUp(self):
def test_p3m_pressure(self):
pressures_via_virial = []
- pressures_via_volume_scaling = []
p3m = electrostatics.P3M(
prefactor=2.0,
accuracy=1e-3,
@@ -131,7 +130,7 @@ def test_p3m_pressure(self):
num_samples = 100
pressure_via_volume_scaling = pressureViaVolumeScaling(
self.system, self.kT)
- for i in range(num_samples):
+ for _ in range(num_samples):
self.system.integrator.run(100)
pressures_via_virial.append(
self.system.analysis.pressure()['total'])
diff --git a/testsuite/python/particle.py b/testsuite/python/particle.py
index eeb2cb40f7e..59ed98f54a5 100644
--- a/testsuite/python/particle.py
+++ b/testsuite/python/particle.py
@@ -269,7 +269,7 @@ def test_parallel_property_setters(self):
except AttributeError:
print("Skipping read-only", p)
# Cause a different mpi callback to uncover deadlock immediately
- x = getattr(s.part[:], p)
+ _ = getattr(s.part[:], p)
def test_zz_remove_all(self):
for id in self.system.part[:].id:
diff --git a/testsuite/python/polymer.py b/testsuite/python/polymer.py
index 3cb80a0ebca..8af8aa7d7a2 100644
--- a/testsuite/python/polymer.py
+++ b/testsuite/python/polymer.py
@@ -18,7 +18,7 @@
import numpy as np
import espressomd
from espressomd import polymer
-from espressomd.shapes import Wall
+import espressomd.shapes
class PolymerPositions(ut.TestCase):
@@ -166,7 +166,7 @@ def test_respect_constraints_wall(self):
w = espressomd.shapes.Wall(normal=[0., 0., 1.], dist=0.5 * self.box_l)
wall_constraint = espressomd.constraints.ShapeBasedConstraint(shape=w)
- c = self.system.constraints.add(wall_constraint)
+ self.system.constraints.add(wall_constraint)
positions = polymer.positions(
n_polymers=num_poly, beads_per_chain=num_mono,
diff --git a/testsuite/python/reaction_ensemble.py b/testsuite/python/reaction_ensemble.py
index 25060710f9c..04a49c14ccd 100644
--- a/testsuite/python/reaction_ensemble.py
+++ b/testsuite/python/reaction_ensemble.py
@@ -21,7 +21,7 @@
"""
import unittest as ut
import numpy as np
-import espressomd # pylint: disable=import-error
+import espressomd
from espressomd import reaction_ensemble
@@ -86,12 +86,9 @@ def test_ideal_titration_curve(self):
type_A = ReactionEnsembleTest.type_A
type_H = ReactionEnsembleTest.type_H
type_HA = ReactionEnsembleTest.type_HA
- box_l = ReactionEnsembleTest.system.box_l
system = ReactionEnsembleTest.system
gamma = ReactionEnsembleTest.gamma
- nubar = ReactionEnsembleTest.nubar
- volume = ReactionEnsembleTest.volume
RE = ReactionEnsembleTest.RE
target_alpha = ReactionEnsembleTest.target_alpha
@@ -103,7 +100,7 @@ def test_ideal_titration_curve(self):
average_NHA = 0.0
average_NA = 0.0
num_samples = 1000
- for i in range(num_samples):
+ for _ in range(num_samples):
RE.reaction(10)
average_NH += system.number_of_particles(type=type_H)
average_NHA += system.number_of_particles(type=type_HA)
diff --git a/testsuite/python/rotate_system.py b/testsuite/python/rotate_system.py
index 6d116f20011..b06cd66c301 100644
--- a/testsuite/python/rotate_system.py
+++ b/testsuite/python/rotate_system.py
@@ -23,7 +23,7 @@
"""
import unittest as ut
import numpy as np
-import espressomd # pylint: disable=import-error
+import espressomd
class RotateSystemTest(ut.TestCase):
diff --git a/testsuite/python/rotation_per_particle.py b/testsuite/python/rotation_per_particle.py
index 0fd48a7aaa9..17b6d070432 100644
--- a/testsuite/python/rotation_per_particle.py
+++ b/testsuite/python/rotation_per_particle.py
@@ -20,7 +20,6 @@
import unittest_decorators as utx
import espressomd
import numpy as np
-from numpy import random
@utx.skipIfMissingFeatures("ROTATION")
diff --git a/testsuite/python/rotational-diffusion-aniso.py b/testsuite/python/rotational-diffusion-aniso.py
index 67e58635bce..e2d8e0e5d15 100644
--- a/testsuite/python/rotational-diffusion-aniso.py
+++ b/testsuite/python/rotational-diffusion-aniso.py
@@ -29,7 +29,7 @@ class RotDiffAniso(ut.TestCase):
# Handle for espresso system
system = espressomd.System(box_l=[1.0, 1.0, 1.0])
system.cell_system.skin = 5.0
- system.seed = range(system.cell_system.get_state()["n_nodes"])
+ system.seed = range(system.cell_system.get_state()["n_nodes"])
# The NVT thermostat parameters
kT = 0.0
@@ -118,7 +118,6 @@ def check_rot_diffusion(self, n):
"""
# Global diffusivity tensor in the body frame:
D = self.kT / self.gamma_global
- dt0 = self.J / self.gamma_global
# Thermalizing...
therm_steps = 100
@@ -151,7 +150,7 @@ def check_rot_diffusion(self, n):
self.system.time = 0.0
int_steps = 20
loops = 100
- for step in range(loops):
+ for _ in range(loops):
self.system.integrator.run(steps=int_steps)
dcosjj = np.zeros((3))
dcosjj2 = np.zeros((3))
diff --git a/testsuite/python/rotational_inertia.py b/testsuite/python/rotational_inertia.py
index db2a97b85bc..13d833de641 100644
--- a/testsuite/python/rotational_inertia.py
+++ b/testsuite/python/rotational_inertia.py
@@ -148,7 +148,7 @@ def test_energy_and_momentum_conservation(self):
E0 = self.energy(p)
m0 = self.momentum(p)
system.time_step = 0.001
- for i in range(1000):
+ for _ in range(1000):
system.integrator.run(100)
self.assertAlmostEqual(self.energy(p), E0, places=3)
self.assertAlmostEqual(self.momentum(p), m0, places=3)
diff --git a/testsuite/python/scafacos_dipoles_1d_2d.py b/testsuite/python/scafacos_dipoles_1d_2d.py
index 1f312154a26..a2697d3c747 100644
--- a/testsuite/python/scafacos_dipoles_1d_2d.py
+++ b/testsuite/python/scafacos_dipoles_1d_2d.py
@@ -20,7 +20,6 @@
# reference data from direct summation. In 2d, reference data from the mdlc
# test case is used
-import os
import numpy as np
import unittest as ut
import unittest_decorators as utx
@@ -40,7 +39,6 @@ def test_scafacos(self):
n_particle = 100
particle_radius = 0.5
- dipole_lambda = 3.0
#################################################
diff --git a/testsuite/python/script_interface_object_params.py b/testsuite/python/script_interface_object_params.py
index de0d95167d3..0c346dbace2 100644
--- a/testsuite/python/script_interface_object_params.py
+++ b/testsuite/python/script_interface_object_params.py
@@ -16,8 +16,6 @@
# along with this program. If not, see .
import unittest as ut
-import espressomd
-
from espressomd.shapes import Wall, Sphere
from espressomd.constraints import ShapeBasedConstraint
diff --git a/testsuite/python/stress.py b/testsuite/python/stress.py
index a47a7e59682..e1c7ace5e21 100644
--- a/testsuite/python/stress.py
+++ b/testsuite/python/stress.py
@@ -23,7 +23,7 @@
from espressomd.interactions import FeneBond
from espressomd.observables import StressTensor
-from tests_common import fene_force, fene_potential, fene_force2
+from tests_common import fene_force2
import numpy as np
@@ -33,13 +33,13 @@
# analytical result for convective stress
-def stress_kinetic(vel, box_l):
+def stress_kinetic(vel):
return np.einsum('ij,ik->jk', vel, vel) / np.prod(system.box_l)
# analytical result for stress originating from bond force
-def stress_bonded(pos, box_l):
+def stress_bonded(pos):
stress = np.zeros([3, 3])
for p1, p2 in zip(pos[0::2], pos[1::2]):
r = p1 - p2
@@ -50,7 +50,7 @@ def stress_bonded(pos, box_l):
# analytical result for stress originating from non-bonded force
-def stress_nonbonded(particle_pairs, box_l):
+def stress_nonbonded(particle_pairs):
stress = np.zeros([3, 3])
for p1, p2 in particle_pairs:
if (p1.type == 0 and p2.type == 0) or (p1.type == 1 and p2.type == 2):
@@ -62,7 +62,7 @@ def stress_nonbonded(particle_pairs, box_l):
return stress
-def stress_nonbonded_inter(particle_pairs, box_l):
+def stress_nonbonded_inter(particle_pairs):
stress = np.zeros([3, 3])
for p1, p2 in particle_pairs:
if p1.type == 1 and p2.type == 2 and p1.mol_id != p2.mol_id:
@@ -74,7 +74,7 @@ def stress_nonbonded_inter(particle_pairs, box_l):
return stress
-def stress_nonbonded_intra(particle_pairs, box_l):
+def stress_nonbonded_intra(particle_pairs):
stress = np.zeros([3, 3])
for p1, p2 in particle_pairs:
if p1.type == 0 and p2.type == 0 and p1.mol_id == p2.mol_id:
@@ -94,8 +94,7 @@ class Stress(ut.TestCase):
def test(self):
# system parameters
- box_l = 10.0
- system.box_l = [box_l, box_l, box_l]
+ system.box_l = 3 * [10.0]
skin = 0.4
time_step = 0.01
system.time_step = time_step
@@ -160,13 +159,13 @@ def test(self):
'non_bonded_intra', 0, 0]
sim_pressure_total = system.analysis.pressure()['total']
- anal_stress_kinetic = stress_kinetic(vel, box_l)
- anal_stress_bonded = stress_bonded(pos, box_l)
- anal_stress_nonbonded = stress_nonbonded(system.part.pairs(), box_l)
+ anal_stress_kinetic = stress_kinetic(vel)
+ anal_stress_bonded = stress_bonded(pos)
+ anal_stress_nonbonded = stress_nonbonded(system.part.pairs())
anal_stress_nonbonded_inter = stress_nonbonded_inter(
- system.part.pairs(), box_l)
+ system.part.pairs())
anal_stress_nonbonded_intra = stress_nonbonded_intra(
- system.part.pairs(), box_l)
+ system.part.pairs())
anal_stress_total = anal_stress_kinetic + \
anal_stress_bonded + anal_stress_nonbonded
anal_pressure_kinetic = np.einsum('ii', anal_stress_kinetic) / 3.0
@@ -243,8 +242,7 @@ def get_anal_stress_fene(self, pos_1, pos_2, k, d_r_max, r_0):
def test_fene(self):
# system parameters
- box_l = 10.0
- system.box_l = [box_l, box_l, box_l]
+ system.box_l = 3 * [10.0]
skin = 0.4
time_step = 0.01
system.time_step = time_step
diff --git a/testsuite/python/test_checkpoint.py b/testsuite/python/test_checkpoint.py
index 9656500f512..66ec0f451b8 100644
--- a/testsuite/python/test_checkpoint.py
+++ b/testsuite/python/test_checkpoint.py
@@ -15,7 +15,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-import subprocess
import unittest as ut
import unittest_decorators as utx
import numpy as np
@@ -57,9 +56,9 @@ def test_LB(self):
lbf.load_checkpoint(cpt_path.format(""), cpt_mode)
precision = 9 if "LB.CPU" in modes else 5
m = np.pi / 12
- nx = lbf.shape[0]
- ny = lbf.shape[1]
- nz = lbf.shape[2]
+ nx = lbf.shape[0]
+ ny = lbf.shape[1]
+ nz = lbf.shape[2]
grid_3D = np.fromfunction(
lambda i, j, k: np.cos(i * m) * np.cos(j * m) * np.cos(k * m),
(nx, ny, nz), dtype=float)
@@ -72,7 +71,7 @@ def test_LB(self):
decimal=precision)
state = lbf.get_params()
reference = {'agrid': 0.5, 'visc': 1.3, 'dens': 1.5, 'tau': 0.01}
- for key, val in reference.items():
+ for key in reference:
self.assertTrue(key in state)
self.assertAlmostEqual(reference[key], state[key], delta=1E-7)
@@ -102,12 +101,12 @@ def test_EK(self):
reference = {'agrid': 0.5, 'lb_density': 26.15,
'viscosity': 1.7, 'friction': 0.0,
'T': 1.1, 'prefactor': 0.88, 'stencil': "linkcentered"}
- for key, val in reference.items():
+ for key in reference:
self.assertTrue(key in state)
self.assertAlmostEqual(reference[key], state[key], delta=1E-5)
state_species = ek_species.get_params()
reference_species = {'density': 0.4, 'D': 0.02, 'valency': 0.3}
- for key, val in reference_species.items():
+ for key in reference_species:
self.assertTrue(key in state_species)
self.assertAlmostEqual(
reference_species[key],
@@ -224,13 +223,13 @@ def test_non_bonded_inter(self):
def test_bonded_inter(self):
state = system.part[1].bonds[0][0].params
reference = {'r_0': 0.0, 'k': 1.0}
- for key in reference.keys():
+ for key in reference:
self.assertAlmostEqual(state[key], reference[key], delta=1E-10)
if 'THERM.LB' not in modes:
state = system.part[1].bonds[1][0].params
reference = {'temp_com': 0., 'gamma_com': 0., 'temp_distance': 0.2,
'gamma_distance': 0.5, 'r_cut': 2.0, 'seed': 51}
- for key in reference.keys():
+ for key in reference:
self.assertAlmostEqual(state[key], reference[key], delta=1E-10)
@utx.skipIfMissingFeatures(['VIRTUAL_SITES', 'VIRTUAL_SITES_RELATIVE'])
diff --git a/testsuite/python/tests_common.py b/testsuite/python/tests_common.py
index dc074fe34e3..8955c76f732 100644
--- a/testsuite/python/tests_common.py
+++ b/testsuite/python/tests_common.py
@@ -34,8 +34,8 @@ def params_match(inParams, outParams):
return False
else:
if outParams[k] != inParams[k]:
- print("Mismatch in parameter ", k, inParams[
- k], outParams[k], type(inParams[k]), type(outParams[k]))
+ print("Mismatch in parameter ", k, inParams[k],
+ outParams[k], type(inParams[k]), type(outParams[k]))
return False
return True
@@ -351,7 +351,7 @@ def lj_generic_potential(r, eps, sig, cutoff, offset=0., shift=0., e1=12.,
def lj_generic_force(espressomd, r, eps, sig, cutoff, offset=0., e1=12, e2=6,
b1=4., b2=4., delta=0., lam=1., generic=True):
f = 1.
- if (r >= offset + cutoff):
+ if r >= offset + cutoff:
f = 0.
else:
h = (r - offset)**2 + delta * (1. - lam) * sig**2
@@ -382,10 +382,10 @@ def lj_cos_potential(r, eps, sig, cutoff, offset):
V = 0.
r_min = offset + np.power(2., 1. / 6.) * sig
r_cut = cutoff + offset
- if (r < r_min):
+ if r < r_min:
V = lj_potential(r, eps=eps, sig=sig,
cutoff=cutoff, offset=offset, shift=0.)
- elif (r < r_cut):
+ elif r < r_cut:
alpha = np.pi / \
(np.power(r_cut - offset, 2) - np.power(r_min - offset, 2))
beta = np.pi - np.power(r_min - offset, 2) * alpha
@@ -398,10 +398,10 @@ def lj_cos_force(espressomd, r, eps, sig, cutoff, offset):
f = 0.
r_min = offset + np.power(2., 1. / 6.) * sig
r_cut = cutoff + offset
- if (r < r_min):
+ if r < r_min:
f = lj_force(espressomd, r, eps=eps, sig=sig,
cutoff=cutoff, offset=offset)
- elif (r < r_cut):
+ elif r < r_cut:
alpha = np.pi / \
(np.power(r_cut - offset, 2) - np.power(r_min - offset, 2))
beta = np.pi - np.power(r_min - offset, 2) * alpha
@@ -416,10 +416,10 @@ def lj_cos2_potential(r, eps, sig, offset, width):
V = 0.
r_min = offset + np.power(2., 1. / 6.) * sig
r_cut = r_min + width
- if (r < r_min):
+ if r < r_min:
V = lj_potential(r, eps=eps, sig=sig,
offset=offset, cutoff=r_cut, shift=0.)
- elif (r < r_cut):
+ elif r < r_cut:
V = -eps * np.power(np.cos(np.pi /
(2. * width) * (r - r_min)), 2)
return V
@@ -429,10 +429,10 @@ def lj_cos2_force(espressomd, r, eps, sig, offset, width):
f = 0.
r_min = offset + np.power(2., 1. / 6.) * sig
r_cut = r_min + width
- if (r < r_min):
+ if r < r_min:
f = lj_force(espressomd, r, eps=eps,
sig=sig, cutoff=r_cut, offset=offset)
- elif (r < r_cut):
+ elif r < r_cut:
f = - np.pi * eps * \
np.sin(np.pi * (r - r_min) / width) / (2. * width)
return f
@@ -442,7 +442,7 @@ def lj_cos2_force(espressomd, r, eps, sig, offset, width):
def smooth_step_potential(r, eps, sig, cutoff, d, n, k0):
V = 0.
- if (r < cutoff):
+ if r < cutoff:
V = np.power(d / r, n) + eps / \
(1 + np.exp(2 * k0 * (r - sig)))
return V
@@ -450,7 +450,7 @@ def smooth_step_potential(r, eps, sig, cutoff, d, n, k0):
def smooth_step_force(r, eps, sig, cutoff, d, n, k0):
f = 0.
- if (r < cutoff):
+ if r < cutoff:
f = n * d / r**2 * np.power(d / r, n - 1) + 2 * k0 * eps * np.exp(
2 * k0 * (r - sig)) / (1 + np.exp(2 * k0 * (r - sig))**2)
return f
@@ -460,10 +460,10 @@ def smooth_step_force(r, eps, sig, cutoff, d, n, k0):
def bmhtf_potential(r, a, b, c, d, sig, cutoff):
V = 0.
- if (r == cutoff):
+ if r == cutoff:
V = a * np.exp(b * (sig - r)) - c * np.power(
r, -6) - d * np.power(r, -8)
- if (r < cutoff):
+ if r < cutoff:
V = a * np.exp(b * (sig - r)) - c * np.power(
r, -6) - d * np.power(r, -8)
V -= bmhtf_potential(cutoff, a, b, c, d, sig, cutoff)
@@ -472,7 +472,7 @@ def bmhtf_potential(r, a, b, c, d, sig, cutoff):
def bmhtf_force(r, a, b, c, d, sig, cutoff):
f = 0.
- if (r < cutoff):
+ if r < cutoff:
f = a * b * np.exp(b * (sig - r)) - 6 * c * np.power(
r, -7) - 8 * d * np.power(r, -9)
return f
@@ -482,17 +482,17 @@ def bmhtf_force(r, a, b, c, d, sig, cutoff):
def morse_potential(r, eps, alpha, cutoff, rmin=0):
V = 0.
- if (r < cutoff):
+ if r < cutoff:
V = eps * (np.exp(-2. * alpha * (r - rmin)) -
2 * np.exp(-alpha * (r - rmin)))
- V -= eps * (np.exp(-2. * alpha * (cutoff - rmin)
- ) - 2 * np.exp(-alpha * (cutoff - rmin)))
+ V -= eps * (np.exp(-2. * alpha * (cutoff - rmin)) -
+ 2 * np.exp(-alpha * (cutoff - rmin)))
return V
def morse_force(r, eps, alpha, cutoff, rmin=0):
f = 0.
- if (r < cutoff):
+ if r < cutoff:
f = 2. * np.exp((rmin - r) * alpha) * \
(np.exp((rmin - r) * alpha) - 1) * alpha * eps
return f
@@ -502,7 +502,7 @@ def morse_force(r, eps, alpha, cutoff, rmin=0):
def buckingham_potential(r, a, b, c, d, cutoff, discont, shift):
V = 0.
- if (r < discont):
+ if r < discont:
m = - buckingham_force(
discont, a, b, c, d, cutoff, discont, shift)
c = buckingham_potential(
@@ -516,7 +516,7 @@ def buckingham_potential(r, a, b, c, d, cutoff, discont, shift):
def buckingham_force(r, a, b, c, d, cutoff, discont, shift):
f = 0.
- if (r < discont):
+ if r < discont:
f = buckingham_force(
discont, a, b, c, d, cutoff, discont, shift)
if (r >= discont) and (r < cutoff):
@@ -529,14 +529,14 @@ def buckingham_force(r, a, b, c, d, cutoff, discont, shift):
def soft_sphere_potential(r, a, n, cutoff, offset=0):
V = 0.
- if (r < offset + cutoff):
+ if r < offset + cutoff:
V = a * np.power(r - offset, -n)
return V
def soft_sphere_force(r, a, n, cutoff, offset=0):
f = 0.
- if ((r > offset) and (r < offset + cutoff)):
+ if (r > offset) and (r < offset + cutoff):
f = n * a * np.power(r - offset, -(n + 1))
return f
@@ -545,14 +545,14 @@ def soft_sphere_force(r, a, n, cutoff, offset=0):
def hertzian_potential(r, eps, sig):
V = 0.
- if (r < sig):
+ if r < sig:
V = eps * np.power(1 - r / sig, 5. / 2.)
return V
def hertzian_force(r, eps, sig):
f = 0.
- if (r < sig):
+ if r < sig:
f = 5. / 2. * eps / sig * np.power(1 - r / sig, 3. / 2.)
return f
@@ -561,14 +561,14 @@ def hertzian_force(r, eps, sig):
def gaussian_potential(r, eps, sig, cutoff):
V = 0.
- if (r < cutoff):
+ if r < cutoff:
V = eps * np.exp(-np.power(r / sig, 2) / 2)
return V
def gaussian_force(r, eps, sig, cutoff):
f = 0.
- if (r < cutoff):
+ if r < cutoff:
f = eps * r / sig**2 * np.exp(-np.power(r / sig, 2) / 2)
return f
@@ -585,14 +585,14 @@ def gay_berne_potential(r_ij, u_i, u_j, epsilon_0, sigma_0, mu, nu, k_1, k_2):
sigma = sigma_0 \
/ np.sqrt(
(1 - 0.5 * chi * (
- (r_u_i + r_u_j)**2 / (1 + chi * u_i_u_j) +
- (r_u_i - r_u_j)**2 / (1 - chi * u_i_u_j))))
+ (r_u_i + r_u_j)**2 / (1 + chi * u_i_u_j) +
+ (r_u_i - r_u_j)**2 / (1 - chi * u_i_u_j))))
epsilon = epsilon_0 *\
(1 - chi**2 * u_i_u_j**2)**(-nu / 2.) *\
(1 - chi_d / 2. * (
- (r_u_i + r_u_j)**2 / (1 + chi_d * u_i_u_j) +
- (r_u_i - r_u_j)**2 / (1 - chi_d * u_i_u_j)))**mu
+ (r_u_i + r_u_j)**2 / (1 + chi_d * u_i_u_j) +
+ (r_u_i - r_u_j)**2 / (1 - chi_d * u_i_u_j)))**mu
rr = np.linalg.norm((np.linalg.norm(r_ij) - sigma + sigma_0) / sigma_0)
diff --git a/testsuite/python/thermalized_bond.py b/testsuite/python/thermalized_bond.py
index f254c308e9f..42d67f88b11 100644
--- a/testsuite/python/thermalized_bond.py
+++ b/testsuite/python/thermalized_bond.py
@@ -143,7 +143,7 @@ def test_dist_langevin(self):
v_stored = np.zeros((N2 * loops, 3))
for i in range(loops):
self.system.integrator.run(12)
- v_dist = self.system.part[1::2].v - self.system.part[::2].v
+ v_dist = self.system.part[1::2].v - self.system.part[::2].v
v_stored[i * N2:(i + 1) * N2, :] = v_dist
v_minmax = 5
diff --git a/testsuite/python/thole.py b/testsuite/python/thole.py
index e1dfa9283ef..3b710464fb8 100644
--- a/testsuite/python/thole.py
+++ b/testsuite/python/thole.py
@@ -57,7 +57,6 @@ def setUp(self):
def test(self):
res_dForce = []
res_dEnergy = []
- Es = []
ns = 100
for i in range(1, ns):
x = 20.0 * i / ns
diff --git a/testsuite/python/time_series.py b/testsuite/python/time_series.py
index 859a189c2d8..db4e6c584df 100644
--- a/testsuite/python/time_series.py
+++ b/testsuite/python/time_series.py
@@ -23,7 +23,7 @@
"""
import unittest as ut
import numpy as np
-import espressomd # pylint: disable=import-error
+import espressomd
from espressomd.observables import ParticlePositions
from espressomd.accumulators import TimeSeries
diff --git a/testsuite/python/unittest_decorators.py b/testsuite/python/unittest_decorators.py
index ea3c78f9ee9..5658037d19b 100644
--- a/testsuite/python/unittest_decorators.py
+++ b/testsuite/python/unittest_decorators.py
@@ -16,8 +16,7 @@
# along with this program. If not, see .
import sys
import unittest
-import espressomd # pylint: disable=import-error
-from espressomd.utils import to_str
+import espressomd
def _id(x):
@@ -30,7 +29,7 @@ def skipIfMissingFeatures(*args):
if not espressomd.has_features(*args):
missing_features = espressomd.missing_features(*args)
return unittest.skip("Skipping test: missing feature{} {}".format(
- 's' if len(missing_features) else '', ', '.join(missing_features)))
+ 's' if missing_features else '', ', '.join(missing_features)))
return _id
@@ -45,7 +44,7 @@ def skipIfMissingModules(*args):
missing_modules = set(args) - set(sys.modules.keys())
if missing_modules:
return unittest.skip("Skipping test: missing python module{} {}".format(
- 's' if len(missing_modules) else '', ', '.join(missing_modules)))
+ 's' if missing_modules else '', ', '.join(missing_modules)))
return _id
@@ -54,6 +53,4 @@ def skipIfMissingGPU():
if not espressomd.gpu_available():
return unittest.skip("Skipping test: no GPU available")
- devices = espressomd.cuda_init.CudaInitHandle().device_list
- current_device_id = espressomd.cuda_init.CudaInitHandle().device
return _id
diff --git a/testsuite/python/virtual_sites_tracers.py b/testsuite/python/virtual_sites_tracers.py
index cf9e0ba7c6b..c18bd798cf8 100644
--- a/testsuite/python/virtual_sites_tracers.py
+++ b/testsuite/python/virtual_sites_tracers.py
@@ -18,7 +18,6 @@
#
import unittest as ut
import unittest_decorators as utx
-import espressomd
from espressomd import lb
from virtual_sites_tracers_common import VirtualSitesTracersCommon
diff --git a/testsuite/python/virtual_sites_tracers_common.py b/testsuite/python/virtual_sites_tracers_common.py
index bf1ed171d21..df12cfed449 100644
--- a/testsuite/python/virtual_sites_tracers_common.py
+++ b/testsuite/python/virtual_sites_tracers_common.py
@@ -16,7 +16,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
-import unittest_decorators as utx
import espressomd
from espressomd import lb, shapes, lbboundaries
import numpy as np
@@ -35,8 +34,6 @@ class VirtualSitesTracersCommon:
system.cell_system.skin = 0.1
def reset_lb(self, ext_force_density=(0, 0, 0)):
- box_height = 10
- box_lw = 8
self.system.actors.clear()
self.system.lbboundaries.clear()
self.lbf = self.LBClass(
@@ -52,7 +49,7 @@ def reset_lb(self, ext_force_density=(0, 0, 0)):
walls = [lbboundaries.LBBoundary() for k in range(2)]
walls[0].set_params(shape=shapes.Wall(normal=[0, 0, 1], dist=0.5))
walls[1].set_params(shape=shapes.Wall(normal=[0, 0, -1],
- dist=-box_height - 0.5))
+ dist=-self.box_height - 0.5))
for wall in walls:
self.system.lbboundaries.add(wall)
@@ -73,8 +70,6 @@ def test_advection(self):
self.reset_lb(ext_force_density=[0.1, 0, 0])
# System setup
system = self.system
- box_lw = self.box_lw
- box_height = self.box_height
system.virtual_sites = VirtualSitesInertialessTracers()
@@ -86,7 +81,7 @@ def test_advection(self):
system.time = 0
# Perform integration
- for i in range(3):
+ for _ in range(3):
system.integrator.run(100)
# compute expected position
X = self.lbf.get_interpolated_velocity(
@@ -156,7 +151,7 @@ def test_tribend(self):
# Perform integration
last_angle = self.compute_angle()
- for i in range(6):
+ for _ in range(6):
system.integrator.run(430)
angle = self.compute_angle()
self.assertLess(angle, last_angle)
@@ -243,7 +238,7 @@ def test_triel(self):
self.assertAlmostEqual(dist2strong, np.sqrt(2), delta=0.1)
def test_zz_without_lb(self):
- """Check behaviour without lb. Ignore non-virtual particles, complain on
+ """Check behaviour without lb. Ignore non-virtual particles, complain on
virtual ones.
"""
@@ -255,5 +250,5 @@ def test_zz_without_lb(self):
p = system.part.add(pos=(0, 0, 0))
system.integrator.run(1)
p.virtual = True
- with(self.assertRaises(Exception)):
+ with self.assertRaises(Exception):
system.integrator.run(1)
diff --git a/testsuite/python/virtual_sites_tracers_gpu.py b/testsuite/python/virtual_sites_tracers_gpu.py
index 14b6e875f74..1e982c7904f 100644
--- a/testsuite/python/virtual_sites_tracers_gpu.py
+++ b/testsuite/python/virtual_sites_tracers_gpu.py
@@ -18,7 +18,6 @@
#
import unittest as ut
import unittest_decorators as utx
-import espressomd
from espressomd import lb
from virtual_sites_tracers_common import VirtualSitesTracersCommon
diff --git a/testsuite/python/wang_landau_reaction_ensemble.py b/testsuite/python/wang_landau_reaction_ensemble.py
index 4d3f451a46a..4b2f5ebe4ab 100644
--- a/testsuite/python/wang_landau_reaction_ensemble.py
+++ b/testsuite/python/wang_landau_reaction_ensemble.py
@@ -24,7 +24,6 @@
import espressomd
from espressomd.interactions import HarmonicBond
from espressomd import reaction_ensemble
-from espressomd import system
import numpy.testing as npt
@@ -103,7 +102,7 @@ def test_wang_landau_output(self):
while True:
try:
self.WLRE.reaction()
- for i in range(2):
+ for _ in range(2):
self.WLRE.displacement_mc_move_for_particles_of_type(3)
except reaction_ensemble.WangLandauHasConverged: # only catch my exception
break
diff --git a/testsuite/python/widom_insertion.py b/testsuite/python/widom_insertion.py
index 353892f3666..21ba39a4989 100644
--- a/testsuite/python/widom_insertion.py
+++ b/testsuite/python/widom_insertion.py
@@ -22,7 +22,7 @@
import unittest as ut
import unittest_decorators as utx
import numpy as np
-import espressomd # pylint: disable=import-error
+import espressomd
from espressomd import reaction_ensemble
from tests_common import lj_potential
@@ -55,7 +55,7 @@ class WidomInsertionTest(ut.TestCase):
LJ_SIG,
LJ_CUT,
LJ_SHIFT) / TEMPERATURE),
- x=radius)
+ x=radius)
# numerical solution for V_lj=0 => corresponds to the volume (as exp(0)=1)
integreateRest = (BOX_L**3 - 4.0 / 3.0 * np.pi * LJ_CUT**3)
@@ -73,7 +73,7 @@ class WidomInsertionTest(ut.TestCase):
volume = np.prod(system.box_l) # cuboid box
Widom = reaction_ensemble.WidomInsertion(
- temperature=TEMPERATURE, seed=1)
+ temperature=TEMPERATURE, seed=1)
def setUp(self):
self.system.part.add(id=0, pos=0.5 * self.system.box_l,
@@ -90,8 +90,7 @@ def setUp(self):
product_coefficients=[1],
default_charges={self.TYPE_HA: self.CHARGE_HA})
- def test_widom_insertion(self):
- TYPE_HA = WidomInsertionTest.TYPE_HA
+ def test_widom_insertion(self):
system = WidomInsertionTest.system
Widom = WidomInsertionTest.Widom
target_mu_ex = WidomInsertionTest.target_mu_ex
@@ -99,7 +98,7 @@ def test_widom_insertion(self):
system.seed = system.cell_system.get_state()[
'n_nodes'] * [np.random.randint(5)]
num_samples = 100000
- for i in range(num_samples):
+ for _ in range(num_samples):
# 0 for insertion reaction
Widom.measure_excess_chemical_potential(0)
mu_ex = Widom.measure_excess_chemical_potential(0)
diff --git a/testsuite/python/writevtf.py b/testsuite/python/writevtf.py
index e86734006dd..c3af78754a9 100644
--- a/testsuite/python/writevtf.py
+++ b/testsuite/python/writevtf.py
@@ -20,11 +20,10 @@
"""
Testmodule for the VTF file writing.
"""
-import os
import sys
import unittest as ut
import numpy as np
-import espressomd # pylint: disable=import-error
+import espressomd
from espressomd import interactions
from espressomd.io.writer import vtf
import tempfile
@@ -66,7 +65,7 @@ def test_pos(self):
if self.types_to_write == 'all':
simulation_pos = np.array(
[((i), float(i), float(i), float(i)) for i in range(npart)])
- elif (2 in self.types_to_write):
+ elif 2 in self.types_to_write:
simulation_pos = np.array(
[((i * 2), float(i * 2), float(i * 2), float(i * 2)) for i in range(npart // 2)])
@@ -78,7 +77,7 @@ def test_bonds(self):
"""Test if bonds have been written properly: just look at number of bonds"""
if self.types_to_write == 'all':
simulation_bonds = np.array([1, 2, 3]) # the two bonded particles
- elif (2 in self.types_to_write):
+ elif 2 in self.types_to_write:
types = [2]
simulation_bonds = np.array(2) # only this one is type 2
@@ -91,7 +90,7 @@ def test_atoms(self):
if self.types_to_write == 'all':
simulation_atoms = np.array(
[((i), (1 + (-1)**i)) for i in range(npart)])
- elif (2 in self.types_to_write):
+ elif 2 in self.types_to_write:
simulation_atoms = np.array([((i * 2), 2)
for i in range(npart // 2)])
diff --git a/testsuite/scripts/importlib_wrapper.py b/testsuite/scripts/importlib_wrapper.py
index ef946b4f680..4abea6a4fe4 100644
--- a/testsuite/scripts/importlib_wrapper.py
+++ b/testsuite/scripts/importlib_wrapper.py
@@ -145,8 +145,7 @@ def configure_and_import(filepath,
def set_cmd(code, filepath, cmd_arguments):
- assert isinstance(cmd_arguments, list) \
- or isinstance(cmd_arguments, tuple)
+ assert isinstance(cmd_arguments, (list, tuple))
sys_argv = list(map(str, cmd_arguments))
sys_argv.insert(0, os.path.basename(filepath))
re_import_sys = re.compile("^import[\t\ ]+sys[\t\ ]*$", re.M)
diff --git a/testsuite/scripts/samples/test_MDAnalysisIntegration.py b/testsuite/scripts/samples/test_MDAnalysisIntegration.py
index c9cef5e4eaf..37c1b2000ee 100644
--- a/testsuite/scripts/samples/test_MDAnalysisIntegration.py
+++ b/testsuite/scripts/samples/test_MDAnalysisIntegration.py
@@ -19,7 +19,7 @@
import importlib_wrapper
try:
- import MDAnalysis
+ import MDAnalysis # pylint: disable=unused-import
except ImportError:
sample = importlib_wrapper.MagicMock()
skipIfMissingFeatures = ut.skip(
diff --git a/testsuite/scripts/tutorials/test_11-ferrofluid_2.py b/testsuite/scripts/tutorials/test_11-ferrofluid_2.py
index 184e4b3947b..f87569ea970 100644
--- a/testsuite/scripts/tutorials/test_11-ferrofluid_2.py
+++ b/testsuite/scripts/tutorials/test_11-ferrofluid_2.py
@@ -17,7 +17,6 @@
import unittest as ut
import importlib_wrapper
-import numpy as np
tutorial, skipIfMissingFeatures = importlib_wrapper.configure_and_import(
diff --git a/testsuite/scripts/tutorials/test_11-ferrofluid_3.py b/testsuite/scripts/tutorials/test_11-ferrofluid_3.py
index 543e65224f0..27fad4455f6 100644
--- a/testsuite/scripts/tutorials/test_11-ferrofluid_3.py
+++ b/testsuite/scripts/tutorials/test_11-ferrofluid_3.py
@@ -17,7 +17,6 @@
import unittest as ut
import importlib_wrapper
-import numpy as np
# value of a reference simulation (10000 equilibration steps; 200000