diff --git a/CMakeLists.txt b/CMakeLists.txt index f63196e82b2..a9f7d037219 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -235,7 +235,7 @@ if(WITH_CUDA) endif() endif(WITH_CUDA) -find_package(PythonInterp 3.2 REQUIRED) +find_package(PythonInterp 3.3 REQUIRED) if(WITH_PYTHON) find_package(Cython 0.23 REQUIRED) @@ -253,25 +253,15 @@ if(WITH_PYTHON) OUTPUT_VARIABLE PYTHON_INSTDIR OUTPUT_STRIP_TRAILING_WHITESPACE) endif(NOT PYTHON_INSTDIR) - if(PYTHON_VERSION_MAJOR EQUAL 2) - set( - CYTHON_FLAGS "-2" - CACHE STRING "Flags used by the Cython compiler during all build types.") - else() - set( - CYTHON_FLAGS "-3" + + set(CYTHON_FLAGS "-3" CACHE STRING "Flags used by the Cython compiler during all build types.") - endif() if(WARNINGS_ARE_ERRORS) set(CYTHON_FLAGS "--warning-errors;${CYTHON_FLAGS}") endif() - if(PYTHON_VERSION_MAJOR EQUAL 2) - find_program(IPYTHON_EXECUTABLE NAMES ipython2 ipython jupyter) - else() - find_program(IPYTHON_EXECUTABLE NAMES ipython3 ipython jupyter) - endif() + find_program(IPYTHON_EXECUTABLE NAMES jupyter ipython3 ipython) endif(WITH_PYTHON) @@ -280,7 +270,7 @@ if(FFTW3_FOUND) set(FFTW 3) endif(FFTW3_FOUND) -# If we build either interface turn on script interface +# If we build Python bindings, turn on script interface if(WITH_PYTHON) set(WITH_SCRIPT_INTERFACE ON) endif() diff --git a/maintainer/CI/build_cmake.sh b/maintainer/CI/build_cmake.sh index 76a21fd462c..2d5779c2d62 100755 --- a/maintainer/CI/build_cmake.sh +++ b/maintainer/CI/build_cmake.sh @@ -164,8 +164,6 @@ pep8_command () { pep8 "$@" elif hash pycodestyle 2> /dev/null; then pycodestyle "$@" - elif hash pycodestyle-2 2> /dev/null; then - pycodestyle-2 "$@" elif hash pycodestyle-3 2> /dev/null; then pycodestyle-3 "$@" else @@ -192,8 +190,6 @@ pylint_command () { pylint "$@" elif hash pylint3 2> /dev/null; then pylint3 "$@" - elif hash pylint-2 2> /dev/null; then - pylint-2 "$@" elif hash pylint-3 2> /dev/null; then pylint-3 "$@" else @@ -206,7 +202,6 @@ if [ $(pylint_command --version | grep -o 'pylint.*[0-9]\.[0-9]\.[0-9]' | awk '{ else score_option='' fi -pylint_command ${score_option} --reports=no --disable=all --enable=C1001 $(find . -name '*.py*') || { echo -e "\nOld-style classes found.\nPlease convert to new-style:\nclass C: => class C(object):\n" && exit 1; } if [ ${insource} = false ]; then if [ ! -d "${builddir}" ]; then diff --git a/src/config/defines.py b/src/config/defines.py index 17d66ff551d..5f62721874d 100644 --- a/src/config/defines.py +++ b/src/config/defines.py @@ -19,7 +19,7 @@ from sys import argv -class Defines(object): +class Defines: def __init__(self, compiler, flags=[]): self._compiler = compiler diff --git a/src/config/featuredefs.py b/src/config/featuredefs.py index 599551e9ed1..951200e397a 100644 --- a/src/config/featuredefs.py +++ b/src/config/featuredefs.py @@ -24,7 +24,7 @@ import re -class SyntaxError(object): +class SyntaxError: def __init__(self, message, instead): self.message = message @@ -45,7 +45,7 @@ def toCPPExpr(expr): return expr -class defs(object): +class defs: def __init__(self, filename): # complete set of all defined features diff --git a/src/python/espressomd/MDA_ESP/__init__.py b/src/python/espressomd/MDA_ESP/__init__.py index 2b41f2e2656..86d4ec436c1 100644 --- a/src/python/espressomd/MDA_ESP/__init__.py +++ b/src/python/espressomd/MDA_ESP/__init__.py @@ -71,7 +71,7 @@ ) -class Stream(object): +class Stream: """ Create an object that provides a MDAnalysis topology and a coordinate reader diff --git a/src/python/espressomd/__init__.py b/src/python/espressomd/__init__.py index efa794f3c37..e5a8ae56a97 100644 --- a/src/python/espressomd/__init__.py +++ b/src/python/espressomd/__init__.py @@ -31,7 +31,7 @@ class FeaturesError(Exception): def __init__(self, missing_features_list): message = "Missing features " + ", ".join(missing_features_list) - super(FeaturesError, self).__init__(message) + super().__init__(message) def has_features(*args): diff --git a/src/python/espressomd/actors.pyx b/src/python/espressomd/actors.pyx index b995f149035..2264a837b59 100644 --- a/src/python/espressomd/actors.pyx +++ b/src/python/espressomd/actors.pyx @@ -2,7 +2,7 @@ include "myconfig.pxi" from .highlander import ThereCanOnlyBeOne from .utils import handle_errors -cdef class Actor(object): +cdef class Actor: """ Abstract base class for interactions affecting particles in the system, @@ -169,7 +169,7 @@ cdef class Actor(object): "Subclasses of %s must define the _deactivate_method() method." % self._get_interaction_type()) -class Actors(object): +class Actors: """ Container for :class:`Actor` objects. diff --git a/src/python/espressomd/analyze.pyx b/src/python/espressomd/analyze.pyx index 817b3ac2652..e297830530a 100644 --- a/src/python/espressomd/analyze.pyx +++ b/src/python/espressomd/analyze.pyx @@ -40,7 +40,7 @@ from .system import System from espressomd.utils import is_valid_type -class Analysis(object): +class Analysis: def __init__(self, system): if not isinstance(system, System): diff --git a/src/python/espressomd/cellsystem.pyx b/src/python/espressomd/cellsystem.pyx index 7980ca260b4..61dfda8596b 100644 --- a/src/python/espressomd/cellsystem.pyx +++ b/src/python/espressomd/cellsystem.pyx @@ -24,7 +24,7 @@ import numpy as np from espressomd.utils cimport handle_errors from espressomd.utils import is_valid_type -cdef class CellSystem(object): +cdef class CellSystem: def set_domain_decomposition( self, use_verlet_lists=True, diff --git a/src/python/espressomd/checkpointing.py b/src/python/espressomd/checkpointing.py index f790da8f883..6358675f550 100644 --- a/src/python/espressomd/checkpointing.py +++ b/src/python/espressomd/checkpointing.py @@ -31,7 +31,7 @@ # Convenient Checkpointing for ESPResSo -class Checkpoint(object): +class Checkpoint: """Checkpoint handling (reading and writing). diff --git a/src/python/espressomd/cluster_analysis.py b/src/python/espressomd/cluster_analysis.py index 191d6529e9c..eaaa28e1c14 100644 --- a/src/python/espressomd/cluster_analysis.py +++ b/src/python/espressomd/cluster_analysis.py @@ -29,7 +29,7 @@ class Cluster(ScriptInterfaceHelper): Returns list of particle ids in the cluster particles(): - Returns an instance of ParticleSlice containing the paritlces in the cluster + Returns an instance of ParticleSlice containing the particles in the cluster size(): Returns the number of particles in the cluster @@ -42,9 +42,9 @@ class Cluster(ScriptInterfaceHelper): fractal_dimension(dr=None): estimates the cluster's fractal dimension by fitting the number of particles - :math:`n` in spheres of growing radius around the cetner of mass + :math:`n` in spheres of growing radius around the center of mass to :math:`c*r_g^d`, where :math:`r_g` is the radius of gyration of the particles - witin the sphere, and :math:`d` is the fractal dimensoin. + within the sphere, and :math:`d` is the fractal dimension. `dr`: Minimum increment for the radius of the spheres. Return value: (fractal_dimension, mean_square_residual) """ @@ -61,7 +61,7 @@ def particles(self): @script_interface_register class ClusterStructure(ScriptInterfaceHelper): - """Cluster structure of a simulation system, and access to cluster anaylsis + """Cluster structure of a simulation system, and access to cluster analysis Attributes ---------- @@ -70,9 +70,11 @@ class ClusterStructure(ScriptInterfaceHelper): clusters: behaves like a read-only dictionary Access to individual clusters in the cluster structure either via - cluster[i], wher i is a (non-consecutive) integer cluster id - or via iteration: - for pair in clusters: + cluster[i], where i is a (non-consecutive) integer cluster id + or via iteration:: + + for pair in clusters: + where pair contains the numeric id and the corresponding cluster object. """ @@ -80,7 +82,7 @@ class ClusterStructure(ScriptInterfaceHelper): _so_creation_policy = "LOCAL" def __init__(self, *args, **kwargs): - super(type(self), self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self._clusters = Clusters(self) def run_for_all_pairs(self): @@ -92,7 +94,7 @@ def run_for_all_pairs(self): def run_for_bonded_particles(self): """ - Runts the cluster analysis, considering only pairs of particles connected ba a pair-bond. + Runs the cluster analysis, considering only pairs of particles connected by a pair-bond. """ return self.call_method("run_for_bonded_particles") @@ -126,7 +128,7 @@ def clusters(self): return self._clusters -class Clusters(object): +class Clusters: """Access to the clusters in the cluster structure. @@ -134,7 +136,7 @@ class Clusters(object): * Number of clusters: len(clusters) * Access a cluster via its id: clusters[id] - * Iterate over clusters::: + * Iterate over clusters:: for c in clusters: diff --git a/src/python/espressomd/collision_detection.pyx b/src/python/espressomd/collision_detection.pyx index 3bbe1b0a2ae..e4d1cee5005 100644 --- a/src/python/espressomd/collision_detection.pyx +++ b/src/python/espressomd/collision_detection.pyx @@ -34,7 +34,7 @@ class CollisionDetection(ScriptInterfaceHelper): # If no mode is specified at construction, use off. if "mode" not in kwargs: kwargs["mode"] = "off" - super(type(self), self).__init__() + super().__init__() self.set_params(**kwargs) def validate(self): @@ -48,7 +48,7 @@ class CollisionDetection(ScriptInterfaceHelper): # Do not allow setting of individual attributes def __setattr__(self, *args, **kwargs): raise Exception( - "Please et all parameters at once via collision_detection.set_params()") + "Please set all parameters at once via collision_detection.set_params()") # Override to call validate after parameter update def set_params(self, **kwargs): @@ -76,13 +76,13 @@ class CollisionDetection(ScriptInterfaceHelper): Particle type of the virtual sites being created on collision (virtual sites based modes) part_type_to_be_glued : :obj:`int` - particle type for "glue_to_surface|" mode. See user guide. + particle type for "glue_to_surface" mode. See user guide. part_type_to_attach_vs_to : :obj:`int` - particle type for "glue_to_surface|" mode. See user guide. + particle type for "glue_to_surface" mode. See user guide. part_type_after_glueing : :obj:`int` - particle type for "glue_to_surface|" mode. See user guide. + particle type for "glue_to_surface" mode. See user guide. distance_glued_particle_to_vs : :obj:`float` Distance for "glue_to_surface" mode. See user guide. @@ -103,7 +103,7 @@ class CollisionDetection(ScriptInterfaceHelper): # Completeness of parameter set if not (set(kwargs.keys()) == set(self._params_for_mode(kwargs["mode"]))): raise Exception("Parameter set does not match mode. ", kwargs[ - "mode"], "requries ", self._params_for_mode(kwargs["mode"])) + "mode"], "requires ", self._params_for_mode(kwargs["mode"])) # Mode kwargs["mode"] = self._int_mode[kwargs["mode"]] @@ -113,21 +113,21 @@ class CollisionDetection(ScriptInterfaceHelper): if name in kwargs: if isinstance(kwargs[name], BondedInteraction): kwargs[name] = kwargs[name]._bond_id - super(type(self), self).set_params(**kwargs) + super().set_params(**kwargs) self.validate() handle_errors("Validation of collision detection failed") def get_parameter(self, name): - #"""Gets a single parameter from the collision detection.""" + """Gets a single parameter from the collision detection.""" - res = super(type(self), self).get_parameter(name) + res = super().get_parameter(name) return self._convert_param(name, res) def get_params(self): """Returns the parameters of the collision detection as dict. """ - res = super(type(self), self).get_params() + res = super().get_params() for k in res.keys(): res[k] = self._convert_param(k, res[k]) diff --git a/src/python/espressomd/comfixed.py b/src/python/espressomd/comfixed.py index 4a7259021f8..88f137cc422 100644 --- a/src/python/espressomd/comfixed.py +++ b/src/python/espressomd/comfixed.py @@ -31,7 +31,7 @@ class ComFixed(ScriptInterfaceHelper): Parameters ---------- types : array_like - List of types of which the center of mass + List of types for which the center of mass should be fixed. """ diff --git a/src/python/espressomd/constraints.py b/src/python/espressomd/constraints.py index 3b6e99a3e10..f2b873088e6 100644 --- a/src/python/espressomd/constraints.py +++ b/src/python/espressomd/constraints.py @@ -234,9 +234,8 @@ class that can calculate the required grid dimensions and the coordinates. def __init__(self, field, **kwargs): shape, codim = self._unpack_dims(field) - super( - _Interpolated, self).__init__(_field_shape=shape, _field_codim=codim, - _field_data=field.flatten(), **kwargs) + super().__init__(_field_shape=shape, _field_codim=codim, + _field_data=field.flatten(), **kwargs) @classmethod def required_dims(cls, box_size, grid_spacing): @@ -338,7 +337,7 @@ class ForceField(_Interpolated): """ def __init__(self, field, **kwargs): - super(ForceField, self).__init__(field, **kwargs) + super().__init__(field, **kwargs) _codim = 3 _so_name = "Constraints::ForceField" @@ -366,7 +365,7 @@ class PotentialField(_Interpolated): """ def __init__(self, field, **kwargs): - super(PotentialField, self).__init__(field, **kwargs) + super().__init__(field, **kwargs) _codim = 1 _so_name = "Constraints::PotentialField" @@ -387,7 +386,7 @@ class Gravity(Constraint): """ def __init__(self, g): - super(Gravity, self).__init__(value=g) + super().__init__(value=g) @property def g(self): @@ -423,7 +422,7 @@ class LinearElectricPotential(Constraint): """ def __init__(self, E, phi0=0): - super(LinearElectricPotential, self).__init__(A=-E, b=phi0) + super().__init__(A=-E, b=phi0) @property def E(self): @@ -468,10 +467,8 @@ class ElectricPlaneWave(Constraint): _so_name = "Constraints::ElectricPlaneWave" def __init__(self, E0, k, omega, phi=0): - super(ElectricPlaneWave, self).__init__(amplitude=E0, - wave_vector=k, - frequency=omega, - phase=phi) + super().__init__(amplitude=E0, wave_vector=k, frequency=omega, + phase=phi) @property def E0(self): @@ -504,7 +501,7 @@ class FlowField(_Interpolated): """ def __init__(self, field, **kwargs): - super(FlowField, self).__init__(field, **kwargs) + super().__init__(field, **kwargs) _codim = 3 _so_name = "Constraints::FlowField" @@ -531,7 +528,7 @@ class HomogeneousFlowField(Constraint): """ def __init__(self, u, gamma): - super(HomogeneousFlowField, self).__init__(value=u, gamma=gamma) + super().__init__(value=u, gamma=gamma) @property def u(self): @@ -557,7 +554,7 @@ class ElectricPotential(_Interpolated): """ def __init__(self, field, **kwargs): - super(ElectricPotential, self).__init__(field, **kwargs) + super().__init__(field, **kwargs) _codim = 1 _so_name = "Constraints::ElectricPotential" diff --git a/src/python/espressomd/cuda_init.pyx b/src/python/espressomd/cuda_init.pyx index 9f8dadcaad9..15a7f888440 100644 --- a/src/python/espressomd/cuda_init.pyx +++ b/src/python/espressomd/cuda_init.pyx @@ -19,7 +19,7 @@ include "myconfig.pxi" from . cimport cuda_init -cdef class CudaInitHandle(object): +cdef class CudaInitHandle: def __init__(self): IF CUDA != 1: raise Exception("CUDA is not compiled in") diff --git a/src/python/espressomd/diamond.pyx b/src/python/espressomd/diamond.pyx index f3b3ac10f22..5b947ded044 100644 --- a/src/python/espressomd/diamond.pyx +++ b/src/python/espressomd/diamond.pyx @@ -3,7 +3,7 @@ from .interactions cimport bonded_ia_params from espressomd.utils cimport handle_errors from espressomd.utils import is_valid_type -cdef class Diamond(object): +cdef class Diamond: """ Class to create a diamond-like polymer network. diff --git a/src/python/espressomd/electrokinetics.pyx b/src/python/espressomd/electrokinetics.pyx index 22708aed49d..e5e70fc0b62 100644 --- a/src/python/espressomd/electrokinetics.pyx +++ b/src/python/espressomd/electrokinetics.pyx @@ -337,7 +337,7 @@ IF ELECTROKINETICS: def add_boundary(self, shape): raise Exception("This method is not implemented yet.") - cdef class ElectrokineticsRoutines(object): + cdef class ElectrokineticsRoutines: cdef Vector3i node def __init__(self, key): @@ -377,7 +377,7 @@ IF ELECTROKINETICS: def __set__(self, value): raise Exception("Not implemented.") - class Species(object): + class Species: """ Creates a species object that is passed to the ek instance. @@ -512,7 +512,7 @@ IF ELECTROKINETICS: def print_vtk_flux_link(self, path): ek_print_vtk_flux_link(self.id, utils.to_char_pointer(path)) - cdef class SpecieRoutines(object): + cdef class SpecieRoutines: cdef Vector3i node cdef int id diff --git a/src/python/espressomd/electrostatics.pyx b/src/python/espressomd/electrostatics.pyx index e02c11d7ef7..b4f46024504 100644 --- a/src/python/espressomd/electrostatics.pyx +++ b/src/python/espressomd/electrostatics.pyx @@ -229,7 +229,7 @@ IF P3M == 1: """ def __init__(self, *args, **kwargs): - super(type(self), self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) def validate_params(self): default_params = self.default_params() @@ -372,7 +372,7 @@ IF P3M == 1: """ def __init__(self, *args, **kwargs): - super(type(self), self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) def validate_params(self): default_params = self.default_params() @@ -791,6 +791,6 @@ IF ELECTROSTATICS: return {} def _deactivate_method(self): - super(Scafacos, self)._deactivate_method() + super()._deactivate_method() scafacos.free_handle() mpi_bcast_coulomb_params() diff --git a/src/python/espressomd/galilei.pyx b/src/python/espressomd/galilei.pyx index 3b3ee8aef83..fb52d176652 100644 --- a/src/python/espressomd/galilei.pyx +++ b/src/python/espressomd/galilei.pyx @@ -20,7 +20,7 @@ from . cimport galilei from .utils cimport make_array_locked -cdef class GalileiTransform(object): +cdef class GalileiTransform: def kill_particle_motion(self, rotation=False): """ diff --git a/src/python/espressomd/globals.pyx b/src/python/espressomd/globals.pyx index 841eee80142..b77efc73d2b 100644 --- a/src/python/espressomd/globals.pyx +++ b/src/python/espressomd/globals.pyx @@ -11,7 +11,7 @@ from globals cimport forcecap_get from espressomd.utils import array_locked, is_valid_type from espressomd.utils cimport Vector3d, make_array_locked -cdef class Globals(object): +cdef class Globals: property box_l: def __set__(self, _box_l): cdef Vector3d temp_box_l diff --git a/src/python/espressomd/integrate.pyx b/src/python/espressomd/integrate.pyx index 6b78dbe1dde..98dcbd6f8d3 100644 --- a/src/python/espressomd/integrate.pyx +++ b/src/python/espressomd/integrate.pyx @@ -22,7 +22,7 @@ import espressomd.code_info from espressomd.utils cimport * cimport globals -cdef class Integrator(object): +cdef class Integrator: """ Integrator class. diff --git a/src/python/espressomd/interactions.pyx b/src/python/espressomd/interactions.pyx index 44f00908a63..026cfbf7935 100644 --- a/src/python/espressomd/interactions.pyx +++ b/src/python/espressomd/interactions.pyx @@ -27,7 +27,7 @@ from globals cimport immersed_boundaries # Non-bonded interactions -cdef class NonBondedInteraction(object): +cdef class NonBondedInteraction: """ Represents an instance of a non-bonded interaction, such as Lennard-Jones. Either called with two particle type id, in which case, the interaction @@ -273,7 +273,7 @@ IF LENNARD_JONES == 1: Restricts the interaction to a minimal distance. """ - super(LennardJonesInteraction, self).set_params(**kwargs) + super().set_params(**kwargs) def _set_params_in_es_core(self): # Handle the case of shift="auto" @@ -367,7 +367,7 @@ IF WCA == 1: Determines the interaction length scale. """ - super(WCAInteraction, self).set_params(**kwargs) + super().set_params(**kwargs) def _set_params_in_es_core(self): if wca_set_params( @@ -539,7 +539,7 @@ IF LENNARD_JONES_GENERIC == 1: interaction. """ - super(GenericLennardJonesInteraction, self).set_params(**kwargs) + super().set_params(**kwargs) def valid_keys(self): """All parameters that can be set. @@ -595,7 +595,7 @@ IF LJCOS: offset : :obj:`float` Offset distance of the interaction. """ - super(LennardJonesCosInteraction, self).set_params(**kwargs) + super().set_params(**kwargs) def _set_params_in_es_core(self): if ljcos_set_params(self._part_types[0], self._part_types[1], @@ -675,7 +675,7 @@ IF LJCOS2: width : :obj:`float` Width of interaction. """ - super(LennardJonesCos2Interaction, self).set_params(**kwargs) + super().set_params(**kwargs) def _set_params_in_es_core(self): if ljcos2_set_params(self._part_types[0], @@ -744,7 +744,7 @@ IF HAT == 1: Cutoff distance of the interaction. """ - super(HatInteraction, self).set_params(**kwargs) + super().set_params(**kwargs) def _set_params_in_es_core(self): if hat_set_params(self._part_types[0], self._part_types[1], @@ -820,7 +820,7 @@ IF GAY_BERNE: Adjustable exponent. """ - super(GayBerneInteraction, self).set_params(**kwargs) + super().set_params(**kwargs) def _set_params_in_es_core(self): if gay_berne_set_params(self._part_types[0], self._part_types[1], @@ -908,7 +908,7 @@ IF DPD: Initial counter value (or seed) of the philox RNG. """ - super(DPDInteraction, self).set_params(**kwargs) + super().set_params(**kwargs) def _set_params_in_es_core(self): if dpd_set_params(self._part_types[0], self._part_types[1], @@ -1026,7 +1026,7 @@ IF SMOOTH_STEP == 1: Cutoff distance of the interaction. """ - super(SmoothStepInteraction, self).set_params(**kwargs) + super().set_params(**kwargs) def valid_keys(self): """All parameters that can be set. @@ -1128,7 +1128,7 @@ IF BMHTF_NACL == 1: Cutoff distance of the interaction. """ - super(BMHTFInteraction, self).set_params(**kwargs) + super().set_params(**kwargs) def valid_keys(self): """All parameters that can be set. @@ -1218,7 +1218,7 @@ IF MORSE == 1: Cutoff distance of the interaction. """ - super(MorseInteraction, self).set_params(**kwargs) + super().set_params(**kwargs) def valid_keys(self): """All parameters that can be set. @@ -1325,7 +1325,7 @@ IF BUCKINGHAM == 1: Constant potential shift. """ - super(BuckinghamInteraction, self).set_params(**kwargs) + super().set_params(**kwargs) def valid_keys(self): """All parameters that can be set. @@ -1415,7 +1415,7 @@ IF SOFT_SPHERE == 1: Offset distance of the interaction. """ - super(SoftSphereInteraction, self).set_params(**kwargs) + super().set_params(**kwargs) def valid_keys(self): """All parameters that can be set. @@ -1609,7 +1609,7 @@ IF HERTZIAN == 1: Parameter sigma which determines the length over which the potential decays. """ - super(HertzianInteraction, self).set_params(**kwargs) + super().set_params(**kwargs) def valid_keys(self): """All parameters that can be set. @@ -1695,7 +1695,7 @@ IF GAUSSIAN == 1: Cutoff distance of the interaction. """ - super(GaussianInteraction, self).set_params(**kwargs) + super().set_params(**kwargs) def valid_keys(self): """All parameters that can be set. @@ -1710,7 +1710,7 @@ IF GAUSSIAN == 1: return "eps", "sig", "cutoff" -class NonBondedInteractionHandle(object): +class NonBondedInteractionHandle: """ Provides access to all non-bonded interactions between two particle types. @@ -1792,7 +1792,7 @@ class NonBondedInteractionHandle(object): self.thole = TholeInteraction(_type1, _type2) -cdef class NonBondedInteractions(object): +cdef class NonBondedInteractions: """ Access to non-bonded interaction parameters via [i,j], where i,j are particle types. Returns a :class:`NonBondedInteractionHandle` object. @@ -1825,13 +1825,13 @@ cdef class NonBondedInteractions(object): reset_ia_params() -cdef class BondedInteraction(object): +cdef class BondedInteraction: """ Base class for bonded interactions. - Either called with an interaction id, in which case, the interaction - will represent the bonded interaction as it is defined in Espresso core - Or called with keyword arguments describing a new interaction. + Either called with an interaction id, in which case the interaction + will represent the bonded interaction as it is defined in Espresso core, + or called with keyword arguments describing a new interaction. """ @@ -1990,7 +1990,7 @@ cdef class BondedInteraction(object): return self._params == other._params -class BondedInteractionNotDefined(object): +class BondedInteractionNotDefined: def __init__(self, *args, **kwargs): raise Exception( @@ -2048,7 +2048,7 @@ class FeneBond(BondedInteraction): """ def __init__(self, *args, **kwargs): - super(FeneBond, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) def type_number(self): return BONDED_IA_FENE @@ -2110,7 +2110,7 @@ class HarmonicBond(BondedInteraction): """ def __init__(self, *args, **kwargs): - super(HarmonicBond, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) def type_number(self): return BONDED_IA_HARMONIC @@ -2163,7 +2163,7 @@ if ELECTROSTATICS: """ def __init__(self, *args, **kwargs): - super(BondedCoulomb, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) def type_number(self): return BONDED_IA_BONDED_COULOMB @@ -2206,7 +2206,7 @@ if ELECTROSTATICS: """ def __init__(self, *args, **kwargs): - super(BondedCoulombSRBond, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) def type_number(self): return BONDED_IA_BONDED_COULOMB_SR @@ -2258,7 +2258,7 @@ class ThermalizedBond(BondedInteraction): """ def __init__(self, *args, **kwargs): - super(ThermalizedBond, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) def type_number(self): return BONDED_IA_THERMALIZED_DIST @@ -2329,7 +2329,7 @@ IF THOLE: atoms that charge is not equal to the particle charge property. """ - super(TholeInteraction, self).set_params(**kwargs) + super().set_params(**kwargs) def _set_params_in_es_core(self): # Handle the case of shift="auto" @@ -2371,7 +2371,7 @@ IF ROTATION: """ def __init__(self, *args, **kwargs): - super(HarmonicDumbbellBond, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) def type_number(self): return BONDED_IA_HARMONIC_DUMBBELL @@ -2485,7 +2485,7 @@ IF BOND_CONSTRAINT == 1: """ def __init__(self, *args, **kwargs): - super(RigidBond, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) def type_number(self): return BONDED_IA_RIGID_BOND @@ -2593,7 +2593,7 @@ class Tabulated(BondedInteraction): """ def __init__(self, *args, **kwargs): - super(Tabulated, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) def type_number(self): return BONDED_IA_TABULATED @@ -2703,7 +2703,7 @@ IF TABULATED == 1: def __init__(self, *args, **kwargs): self.state = -1 - super(TabulatedNonBonded, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) def type_number(self): return "TABULATED_NONBONDED" @@ -2742,7 +2742,7 @@ IF TABULATED == 1: The force table. """ - super(TabulatedNonBonded, self).set_params(**kwargs) + super().set_params(**kwargs) def set_default_params(self): """Set parameters that are not required to their default value. @@ -2780,7 +2780,7 @@ IF LENNARD_JONES == 1: class SubtLJ(BondedInteraction): def __init__(self, *args, **kwargs): - super(SubtLJ, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) def type_number(self): return BONDED_IA_SUBT_LJ @@ -2823,7 +2823,7 @@ class Virtual(BondedInteraction): """ def __init__(self, *args, **kwargs): - super(Virtual, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) def type_number(self): return BONDED_IA_VIRTUAL_BOND @@ -3020,7 +3020,7 @@ class IBM_Triel(BondedInteraction): """ def __init__(self, *args, **kwargs): - super(IBM_Triel, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) def type_number(self): return BONDED_IA_IBM_TRIEL @@ -3073,7 +3073,7 @@ class IBM_Tribend(BondedInteraction): """ def __init__(self, *args, **kwargs): - super(IBM_Tribend, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) def type_number(self): return BONDED_IA_IBM_TRIBEND @@ -3121,7 +3121,7 @@ class IBM_VolCons(BondedInteraction): """ def __init__(self, *args, **kwargs): - super(IBM_VolCons, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) def type_number(self): return BONDED_IA_IBM_VOLUME_CONSERVATION @@ -3294,7 +3294,7 @@ class QuarticBond(BondedInteraction): """ def __init__(self, *args, **kwargs): - super(QuarticBond, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) def type_number(self): return BONDED_IA_QUARTIC @@ -3368,7 +3368,7 @@ IF ELECTROSTATICS: int(BONDED_IA_BONDED_COULOMB_SR)] = BondedCoulombSRBond -class BondedInteractions(object): +class BondedInteractions: """Represents the bonded interactions. @@ -3428,7 +3428,7 @@ class BondedInteractions(object): yield self[i] def add(self, bonded_ia): - """Add a bonded ia to the simulation>""" + """Add a bonded ia to the simulation""" self[bonded_ia_params.size()] = bonded_ia def __getstate__(self): diff --git a/src/python/espressomd/io/mpiio.py b/src/python/espressomd/io/mpiio.py index f7b43c4f535..12e7b85523a 100644 --- a/src/python/espressomd/io/mpiio.py +++ b/src/python/espressomd/io/mpiio.py @@ -17,7 +17,7 @@ from ..script_interface import PScriptInterface -class Mpiio(object): +class Mpiio: """MPI-IO object. diff --git a/src/python/espressomd/io/writer/h5md.py b/src/python/espressomd/io/writer/h5md.py index bd5fac68485..fc29279e466 100644 --- a/src/python/espressomd/io/writer/h5md.py +++ b/src/python/espressomd/io/writer/h5md.py @@ -19,18 +19,16 @@ import sys -from six import iteritems - from ...script_interface import PScriptInterface # pylint: disable=import from ...code_info import features if not 'H5MD' in features(): - class H5md(object): + class H5md: def __init__(self, *args, **kwargs): raise RuntimeError("H5md not available.") else: - class H5md(object): + class H5md: """H5md file object. @@ -74,7 +72,7 @@ def __init__(self, write_ordered=True, **kwargs): 'write_charge': 1 << 5} self.valid_params.append(self.what.keys()) self.what_bin = 0 - for i, j in iteritems(kwargs): + for i, j in kwargs.items(): if i in self.what.keys(): if isinstance(j, bool): if j: diff --git a/src/python/espressomd/lb.pyx b/src/python/espressomd/lb.pyx index 01f5b94dbe3..769b04fff05 100644 --- a/src/python/espressomd/lb.pyx +++ b/src/python/espressomd/lb.pyx @@ -343,7 +343,7 @@ IF CUDA: linear_velocity_interpolation(< double * >np.PyArray_GETPTR2(positions, 0, 0), < double * >np.PyArray_GETPTR2(velocities, 0, 0), length) return velocities * lb_lbfluid_get_lattice_speed() -cdef class LBFluidRoutines(object): +cdef class LBFluidRoutines: cdef Vector3i node def __init__(self, key): diff --git a/src/python/espressomd/magnetostatics.pyx b/src/python/espressomd/magnetostatics.pyx index 03c8651c688..263ec13ac5a 100644 --- a/src/python/espressomd/magnetostatics.pyx +++ b/src/python/espressomd/magnetostatics.pyx @@ -93,7 +93,7 @@ IF DP3M == 1: """Check validity of parameters. """ - super(DipolarP3M, self).validate_params() + super().validate_params() default_params = self.default_params() if not (self._params["r_cut"] >= 0 or self._params["r_cut"] == default_params["r_cut"]): @@ -186,7 +186,7 @@ IF DP3M == 1: def _deactivate_method(self): dp3m_deactivate() - super(type(self), self)._deactivate_method() + super()._deactivate_method() def python_dp3m_set_mesh_offset(self, mesh_off): cdef double mesh_offset[3] @@ -381,7 +381,7 @@ IF DIPOLES == 1: self._set_params_in_es_core() def _deactivate_method(self): - super(type(self), self)._deactivate_method() + super()._deactivate_method() deactivate_dipolar_direct_sum_gpu() def _set_params_in_es_core(self): @@ -412,7 +412,7 @@ IF DIPOLES == 1: self._set_params_in_es_core() def _deactivate_method(self): - super(type(self), self)._deactivate_method() + super()._deactivate_method() deactivate_dipolar_barnes_hut() def _set_params_in_es_core(self): diff --git a/src/python/espressomd/minimize_energy.pyx b/src/python/espressomd/minimize_energy.pyx index 0458481535a..57c7472d2c9 100644 --- a/src/python/espressomd/minimize_energy.pyx +++ b/src/python/espressomd/minimize_energy.pyx @@ -21,7 +21,7 @@ from . cimport minimize_energy from espressomd.utils import is_valid_type -cdef class MinimizeEnergy(object): +cdef class MinimizeEnergy: """ Initialize steepest descent energy minimization. diff --git a/src/python/espressomd/pair_criteria.py b/src/python/espressomd/pair_criteria.py index 3bf74d9f2c6..f3b5a355088 100644 --- a/src/python/espressomd/pair_criteria.py +++ b/src/python/espressomd/pair_criteria.py @@ -22,7 +22,7 @@ class _PairCriterion(ScriptInterfaceHelper): def decide(self, p1, p2): """Makes a decision based on the two particles specified. - p2,p2 : Instances of ParticleHandle or integers containing the particle id. + p1,p2 : Instances of ParticleHandle or integers containing the particle id. """ id1 = None id2 = None diff --git a/src/python/espressomd/particle_data.pxd b/src/python/espressomd/particle_data.pxd index fb9ff7df58c..a1dbeb73d4c 100644 --- a/src/python/espressomd/particle_data.pxd +++ b/src/python/espressomd/particle_data.pxd @@ -220,7 +220,7 @@ cdef extern from "rotation.hpp": Vector3d convert_vector_space_to_body(const particle & p, const Vector3d & v) void rotate_particle(int id, Vector3d axis, double angle) -cdef class ParticleHandle(object): +cdef class ParticleHandle: cdef public int _id cdef const particle * particle_data cdef int update_particle_data(self) except -1 diff --git a/src/python/espressomd/particle_data.pyx b/src/python/espressomd/particle_data.pyx index b33e43e9bab..2062459772a 100644 --- a/src/python/espressomd/particle_data.pyx +++ b/src/python/espressomd/particle_data.pyx @@ -57,7 +57,7 @@ for d in dir(ParticleHandle): if not d in ["pos_folded"]: particle_attributes.append(d) -cdef class ParticleHandle(object): +cdef class ParticleHandle: def __cinit__(self, int _id): self._id = _id @@ -152,7 +152,7 @@ cdef class ParticleHandle(object): def __set__(self, _pos): cdef double mypos[3] check_type_or_throw_except( - _pos, 3, float, "Postion must be 3 floats") + _pos, 3, float, "Position must be 3 floats") for i in range(3): mypos[i] = _pos[i] if place_particle(self._id, mypos) == -1: @@ -1575,7 +1575,7 @@ cdef class ParticleHandle(object): rotate_particle(self._id, a, angle) -cdef class _ParticleSliceImpl(object): +cdef class _ParticleSliceImpl: """Handles slice inputs. This base class should not be used directly. Use @@ -1699,10 +1699,10 @@ class ParticleSlice(_ParticleSliceImpl): if name != "_chunk_size" and not hasattr(ParticleHandle, name): raise AttributeError( "ParticleHandle does not have the attribute {}.".format(name)) - super(ParticleSlice, self).__setattr__(name, value) + super().__setattr__(name, value) -cdef class ParticleList(object): +cdef class ParticleList: """ Provides access to the particles via [i], where i is the particle id. Returns a ParticleHandle object. @@ -1856,7 +1856,7 @@ Set quat and scalar dipole moment (dipm) instead.") # done here. the code is from the pos:property of ParticleHandle cdef double mypos[3] check_type_or_throw_except( - P["pos"], 3, float, "Postion must be 3 floats.") + P["pos"], 3, float, "Position must be 3 floats.") for i in range(3): mypos[i] = P["pos"][i] if place_particle(P["id"], mypos) == -1: diff --git a/src/python/espressomd/reaction_ensemble.pyx b/src/python/espressomd/reaction_ensemble.pyx index 29043d77f7e..be2034a8edb 100644 --- a/src/python/espressomd/reaction_ensemble.pyx +++ b/src/python/espressomd/reaction_ensemble.pyx @@ -10,7 +10,7 @@ class WangLandauHasConverged(Exception): pass -cdef class ReactionAlgorithm(object): +cdef class ReactionAlgorithm: """ This class provides the base class for Reaction Algorithms like the Reaction Ensemble algorithm, the Wang-Landau @@ -390,7 +390,7 @@ cdef class ConstantpHEnsemble(ReactionAlgorithm): if(kwargs["reactant_coefficients"][0] != 1 or kwargs["product_coefficients"][0] != 1 or kwargs["product_coefficients"][1] != 1): raise ValueError( "All product and reactant coefficients must equal one in the constant pH method as implemented in Espresso.") - super(ConstantpHEnsemble, self).add_reaction(*args, **kwargs) + super().add_reaction(*args, **kwargs) property constant_pH: """ diff --git a/src/python/espressomd/script_interface.pyx b/src/python/espressomd/script_interface.pyx index 110de576c0f..247c07e3113 100644 --- a/src/python/espressomd/script_interface.pyx +++ b/src/python/espressomd/script_interface.pyx @@ -3,7 +3,7 @@ import numpy as np from espressomd.utils import is_valid_type, array_locked from espressomd.utils cimport Vector3d, make_array_locked -cdef class PObjectId(object): +cdef class PObjectId: """Python interface to a core ObjectId object.""" cdef ObjectId id @@ -14,7 +14,7 @@ cdef class PObjectId(object): else: raise NotImplementedError -cdef class PScriptInterface(object): +cdef class PScriptInterface: """ Python interface to a core ScriptInterface object. The core ScriptInterface @@ -278,8 +278,8 @@ class ScriptInterfaceHelper(PScriptInterface): _so_creation_policy = "GLOBAL" def __init__(self, **kwargs): - super(ScriptInterfaceHelper, self).__init__( - self._so_name, policy=self._so_creation_policy, **kwargs) + super().__init__(self._so_name, policy=self._so_creation_policy, + **kwargs) self.define_bound_methods() def __reduce__(self): diff --git a/src/python/espressomd/shapes.py b/src/python/espressomd/shapes.py index bbf7bbd22d7..64576fd5673 100644 --- a/src/python/espressomd/shapes.py +++ b/src/python/espressomd/shapes.py @@ -17,7 +17,7 @@ from .script_interface import ScriptInterfaceHelper, script_interface_register -class Shape(object): +class Shape: _so_bind_methods = ("calc_distance",) @@ -258,7 +258,7 @@ class Wall(Shape, ScriptInterfaceHelper): class SimplePore(Shape, ScriptInterfaceHelper): """ - Two parallel infinite planes, and a cylindrical orfice connecting them. + Two parallel infinite planes, and a cylindrical orifice connecting them. The cylinder and the planes are connected by torus segments with an adjustable radius. diff --git a/src/python/espressomd/system.pyx b/src/python/espressomd/system.pyx index 0e2ad359fac..f996117303d 100644 --- a/src/python/espressomd/system.pyx +++ b/src/python/espressomd/system.pyx @@ -74,7 +74,7 @@ if OIF_GLOBAL_FORCES: cdef bool _system_created = False -cdef class System(object): +cdef class System: """ The base class for espressomd.system.System(). .. note:: every attribute has to be declared at the class level. diff --git a/src/python/espressomd/thermostat.pyx b/src/python/espressomd/thermostat.pyx index 7db672966c3..86caace2e5e 100644 --- a/src/python/espressomd/thermostat.pyx +++ b/src/python/espressomd/thermostat.pyx @@ -52,7 +52,7 @@ def AssertThermostatType(*allowedthermostats): return decoratorfunction -cdef class Thermostat(object): +cdef class Thermostat: # We have to cdef the state variable because it is a cdef class cdef _state diff --git a/src/python/espressomd/utils.pyx b/src/python/espressomd/utils.pyx index f98f2360818..925edf88d12 100644 --- a/src/python/espressomd/utils.pyx +++ b/src/python/espressomd/utils.pyx @@ -19,7 +19,6 @@ cimport numpy as np cimport cython import numpy as np -from cpython.version cimport PY_MAJOR_VERSION from libcpp.vector cimport vector cdef np.ndarray create_nparray_from_int_list(const List[int] & il): @@ -145,14 +144,12 @@ def to_str(s): s : char* """ - if type(s) is unicode: + if isinstance(s, unicode): return < unicode > s - elif PY_MAJOR_VERSION >= 3 and isinstance(s, bytes): + elif isinstance(s, bytes): return (< bytes > s).decode('ascii') - elif isinstance(s, unicode): - return unicode(s) else: - return s + raise ValueError('Unknown string type {}'.format(type(s))) class array_locked(np.ndarray): diff --git a/src/python/espressomd/visualization.pyx b/src/python/espressomd/visualization.pyx index db417c0a31a..56bc87969e3 100644 --- a/src/python/espressomd/visualization.pyx +++ b/src/python/espressomd/visualization.pyx @@ -9,7 +9,7 @@ try: except BaseException as e: if isinstance(e, ImportError) or isinstance(e, RuntimeError) and \ e.args[0] == 'No pyface.toolkits plugin could be loaded for wx': - class mayaviLive(object): + class mayaviLive: deferred_ImportError = e def __init__(self, *args, **kwargs): @@ -20,7 +20,7 @@ except BaseException as e: try: from .visualization_opengl import openGLLive except ImportError as e: - class openGLLive(object): + class openGLLive: deferred_ImportError = e def __init__(self, *args, **kwargs): diff --git a/src/python/espressomd/visualization_mayavi.pyx b/src/python/espressomd/visualization_mayavi.pyx index 5fc45142cea..20bc823963f 100644 --- a/src/python/espressomd/visualization_mayavi.pyx +++ b/src/python/espressomd/visualization_mayavi.pyx @@ -29,7 +29,7 @@ output = vtk.vtkFileOutputWindow() output.SetFileName("/dev/null") vtk.vtkOutputWindow().SetInstance(output) -cdef class mayaviLive(object): +cdef class mayaviLive: """ This class provides live visualization using Enthought Mayavi. Use the update method to push your current simulation state after integrating. If diff --git a/src/python/espressomd/visualization_opengl.pyx b/src/python/espressomd/visualization_opengl.pyx index f59cc4f6706..dfee75a5574 100644 --- a/src/python/espressomd/visualization_opengl.pyx +++ b/src/python/espressomd/visualization_opengl.pyx @@ -19,7 +19,7 @@ from espressomd.particle_data import ParticleHandle from espressomd.interactions cimport BONDED_IA_DIHEDRAL, BONDED_IA_TABULATED -class openGLLive(object): +class openGLLive: """ This class provides live visualization using pyOpenGL. @@ -2220,7 +2220,7 @@ def draw_arrow(pos, d, radius, color, material, quality): # MOUSE EVENT MANAGER -class MouseFireEvent(object): +class MouseFireEvent: """Event type of mouse button used for mouse callbacks. @@ -2233,7 +2233,7 @@ class MouseFireEvent(object): DoubleClick = 4 -class MouseButtonEvent(object): +class MouseButtonEvent: """Mouse event used for mouse callbacks. Stores button and callback. @@ -2246,7 +2246,7 @@ class MouseButtonEvent(object): self.positional = positional -class MouseManager(object): +class MouseManager: """Handles mouse callbacks. @@ -2334,7 +2334,7 @@ class MouseManager(object): # KEYBOARD EVENT MANAGER -class KeyboardFireEvent(object): +class KeyboardFireEvent: """Event type of button used for keyboard callbacks. @@ -2345,7 +2345,7 @@ class KeyboardFireEvent(object): Released = 2 -class KeyboardButtonEvent(object): +class KeyboardButtonEvent: """Keyboard event used for keyboard callbacks. Stores button, event type and callback. @@ -2358,7 +2358,7 @@ class KeyboardButtonEvent(object): self.internal = internal -class KeyboardManager(object): +class KeyboardManager: """Handles keyboard callbacks. @@ -2425,7 +2425,7 @@ class KeyboardManager(object): # CAMERA -class Camera(object): +class Camera: def __init__(self): pass diff --git a/src/python/object_in_fluid/oif_classes.py b/src/python/object_in_fluid/oif_classes.py index 4ed724828b2..7d7ed73e2af 100644 --- a/src/python/object_in_fluid/oif_classes.py +++ b/src/python/object_in_fluid/oif_classes.py @@ -22,7 +22,7 @@ from espressomd.interactions import OifOutDirection -class FixedPoint(object): +class FixedPoint: """ Represents mesh points, not connected to any ESPResSo particle. @@ -47,7 +47,7 @@ def get_id(self): return self.id -class PartPoint(object): +class PartPoint: """ Represents mesh points, connected to ESPResSo particle. @@ -93,7 +93,7 @@ def unkill_motion(self): self.part.unfix() -class Edge(object): +class Edge: """ Represents edges in a mesh. @@ -110,7 +110,7 @@ def length(self): return vec_distance(self.A.get_pos(), self.B.get_pos()) -class Triangle(object): +class Triangle: """ Represents triangles in a mesh. @@ -130,7 +130,7 @@ def area(self): return area -class Angle(object): +class Angle: """ Represents angles in a mesh. @@ -154,7 +154,7 @@ def size(self): return angle_size -class ThreeNeighbors(object): +class ThreeNeighbors: """ Represents three best spatially distributed neighbors of a point in a mesh. @@ -177,7 +177,7 @@ def outer_normal(self): return outer_normal -class Mesh(object): +class Mesh: """ Represents a triangular mesh. @@ -717,7 +717,7 @@ def mirror(self, mirror_x=0, mirror_y=0, mirror_z=0, out_file_name=""): return 0 -class OifCellType(object): # analogous to oif_template +class OifCellType: # analogous to oif_template """ Represents a template for creating elastic objects. @@ -802,7 +802,7 @@ def print_info(self): print(" ") -class OifCell(object): +class OifCell: """ Represents a concrete elastic object. diff --git a/testsuite/cmake/BashUnitTests.sh b/testsuite/cmake/BashUnitTests.sh index 8159f016769..a7ec0bdeb97 100755 --- a/testsuite/cmake/BashUnitTests.sh +++ b/testsuite/cmake/BashUnitTests.sh @@ -37,10 +37,10 @@ ## # write tests ## function test_install() { ## assert_file_exists bin/main -## assert_file_exists lib/python2.7/site-packages/espressomd/__init__.py +## assert_file_exists lib/python3.6/site-packages/espressomd/__init__.py ## } ## function test_run() { -## assert_return_code python2 -c "import espressomd" +## assert_return_code python3 -c "import espressomd" ## } ## ## # run tests diff --git a/testsuite/python/actor.py b/testsuite/python/actor.py index 239301be70f..5ef4b63948c 100644 --- a/testsuite/python/actor.py +++ b/testsuite/python/actor.py @@ -34,7 +34,7 @@ def __init__(self, *args, **kwargs): self._deactivated = False self._validated = False - super(TestActor, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) def _get_params_from_es_core(self): return self._core_args diff --git a/testsuite/python/lb.py b/testsuite/python/lb.py index 12db1a88362..68666a5e633 100644 --- a/testsuite/python/lb.py +++ b/testsuite/python/lb.py @@ -25,7 +25,7 @@ import sys -class TestLB(object): +class TestLB: """ Basic tests of the Lattice Boltzmann implementation diff --git a/testsuite/python/lb_boundary.py b/testsuite/python/lb_boundary.py index 4538da66537..af4c5b6a4bc 100644 --- a/testsuite/python/lb_boundary.py +++ b/testsuite/python/lb_boundary.py @@ -23,7 +23,7 @@ from itertools import product -class LBBoundariesBase(object): +class LBBoundariesBase: system = espressomd.System(box_l=[10.0, 10.0, 10.0]) wall_shape1 = Wall(normal=[1., 0., 0.], dist=2.5) diff --git a/testsuite/python/lb_density.py b/testsuite/python/lb_density.py index 3bf79cac653..35580624048 100644 --- a/testsuite/python/lb_density.py +++ b/testsuite/python/lb_density.py @@ -37,7 +37,7 @@ 'seed': 23} -class LBMassCommon(object): +class LBMassCommon: """Base class of the test that holds the test logic.""" lbf = None diff --git a/testsuite/python/lb_interpolation.py b/testsuite/python/lb_interpolation.py index 3dd04ab84a3..8b3c5d54070 100644 --- a/testsuite/python/lb_interpolation.py +++ b/testsuite/python/lb_interpolation.py @@ -43,7 +43,7 @@ def velocity_profile(x): return V_BOUNDARY / (BOX_L - 2. * AGRID) * (x - AGRID) -class LBInterpolation(object): +class LBInterpolation: """ Couette flow profile along x in z-direction. Check that velocity at shear diff --git a/testsuite/python/lb_poiseuille.py b/testsuite/python/lb_poiseuille.py index 93df2dc494c..daa69e01ee8 100644 --- a/testsuite/python/lb_poiseuille.py +++ b/testsuite/python/lb_poiseuille.py @@ -61,7 +61,7 @@ def poiseuille_flow(z, H, ext_force_density, dyn_visc): return ext_force_density * 1. / (2 * dyn_visc) * (H**2.0 / 4.0 - z**2.0) -class LBPoiseuilleCommon(object): +class LBPoiseuilleCommon: """Base class of the test that holds the test logic.""" lbf = None diff --git a/testsuite/python/lb_poiseuille_cylinder.py b/testsuite/python/lb_poiseuille_cylinder.py index 35c4c5640e2..8e1dfd0d287 100644 --- a/testsuite/python/lb_poiseuille_cylinder.py +++ b/testsuite/python/lb_poiseuille_cylinder.py @@ -74,7 +74,7 @@ def poiseuille_flow(r, R, ext_force_density, dyn_visc): return ext_force_density * 1. / (4 * dyn_visc) * (R**2.0 - r**2.0) -class LBPoiseuilleCommon(object): +class LBPoiseuilleCommon: """Base class of the test that holds the test logic.""" lbf = None diff --git a/testsuite/python/lb_shear.py b/testsuite/python/lb_shear.py index 05c1d313548..694d608f525 100644 --- a/testsuite/python/lb_shear.py +++ b/testsuite/python/lb_shear.py @@ -79,7 +79,7 @@ def shear_flow(x, t, nu, v, h, k_max): return v * u -class LBShearCommon(object): +class LBShearCommon: """Base class of the test that holds the test logic.""" lbf = None diff --git a/testsuite/python/lb_stokes_sphere.py b/testsuite/python/lb_stokes_sphere.py index 3c2c7a4db99..4cbc489819f 100644 --- a/testsuite/python/lb_stokes_sphere.py +++ b/testsuite/python/lb_stokes_sphere.py @@ -50,7 +50,7 @@ v = [0, 0, 0.2 * c_s] # The boundary slip -class Stokes(object): +class Stokes: lbf = None system = espressomd.System(box_l=[real_width, real_width, box_length]) system.box_l = [real_width, real_width, box_length] diff --git a/testsuite/python/lb_streaming.py b/testsuite/python/lb_streaming.py index 66ba81dbf58..9ec81618e38 100644 --- a/testsuite/python/lb_streaming.py +++ b/testsuite/python/lb_streaming.py @@ -62,7 +62,7 @@ } -class LBStreamingCommon(object): +class LBStreamingCommon: """ Check the streaming step of the LB fluid implementation by setting all populations diff --git a/testsuite/python/lb_thermostat.py b/testsuite/python/lb_thermostat.py index b4c1247f401..e30472b9585 100644 --- a/testsuite/python/lb_thermostat.py +++ b/testsuite/python/lb_thermostat.py @@ -41,7 +41,7 @@ 'seed': 123} -class LBThermostatCommon(object): +class LBThermostatCommon: """Base class of the test that holds the test logic.""" lbf = None diff --git a/testsuite/python/linear_momentum_lb.py b/testsuite/python/linear_momentum_lb.py index fcba5bcd0d5..8864d8d17d2 100644 --- a/testsuite/python/linear_momentum_lb.py +++ b/testsuite/python/linear_momentum_lb.py @@ -41,7 +41,7 @@ 'ext_force_density': [0.1, 0.2, 0.3]} -class LinearMomentumTest(object): +class LinearMomentumTest: """Base class of the test that holds the test logic.""" lbf = None diff --git a/testsuite/python/mmm1d.py b/testsuite/python/mmm1d.py index e1c8d8d4f58..16dfdc0fbb1 100644 --- a/testsuite/python/mmm1d.py +++ b/testsuite/python/mmm1d.py @@ -28,7 +28,7 @@ sys.exit() -class ElectrostaticInteractionsTests(object): +class ElectrostaticInteractionsTests: # Handle to espresso system system = espressomd.System(box_l=[10.0] * 3) system.periodicity = [0, 0, 1] diff --git a/testsuite/python/observable_cylindricalLB.py b/testsuite/python/observable_cylindricalLB.py index 71404e49ea0..09881ea3c6c 100644 --- a/testsuite/python/observable_cylindricalLB.py +++ b/testsuite/python/observable_cylindricalLB.py @@ -35,7 +35,7 @@ } -class CylindricalLBObservableCommon(object): +class CylindricalLBObservableCommon: """ Testcase for the CylindricalLBObservable. diff --git a/testsuite/python/observable_profileLB.py b/testsuite/python/observable_profileLB.py index 73cf3f078e8..c11208caeec 100644 --- a/testsuite/python/observable_profileLB.py +++ b/testsuite/python/observable_profileLB.py @@ -60,7 +60,7 @@ 'allow_empty_bins': False} -class ObservableProfileLBCommon(object): +class ObservableProfileLBCommon: lbf = None system = espressomd.System(box_l=[12.0, 12.0, 12.0]) system.time_step = TIME_STEP diff --git a/testsuite/python/p3m_electrostatic_pressure.py b/testsuite/python/p3m_electrostatic_pressure.py index 2a02bd7ae4f..afbb1d79134 100644 --- a/testsuite/python/p3m_electrostatic_pressure.py +++ b/testsuite/python/p3m_electrostatic_pressure.py @@ -25,7 +25,7 @@ from espressomd import electrostatics -class pressureViaVolumeScaling(object): +class pressureViaVolumeScaling: def __init__(self, system, kbT): self.system = system diff --git a/testsuite/python/particle_slice.py b/testsuite/python/particle_slice.py index 75c5130b808..baf15064aee 100644 --- a/testsuite/python/particle_slice.py +++ b/testsuite/python/particle_slice.py @@ -27,7 +27,7 @@ class ParticleSliceTest(ut.TestCase): system = espressomd.System(box_l=[10, 10, 10]) def __init__(self, *args, **kwargs): - super(ParticleSliceTest, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self.system.part.clear() for i in range(4): self.system.part.add(pos=[0, 0, i]) diff --git a/testsuite/python/tests_common.py b/testsuite/python/tests_common.py index dd8ef0076b0..b3aa336fd8b 100644 --- a/testsuite/python/tests_common.py +++ b/testsuite/python/tests_common.py @@ -599,7 +599,7 @@ def gay_berne_potential(r_ij, u_i, u_j, epsilon_0, sigma_0, mu, nu, k_1, k_2): class DynamicDict(dict): def __getitem__(self, key): - value = super(DynamicDict, self).__getitem__(key) + value = super().__getitem__(key) return eval(value, self) if isinstance(value, str) else value diff --git a/testsuite/python/virtual_sites_tracers_common.py b/testsuite/python/virtual_sites_tracers_common.py index 9ec93d33150..078ebdf42cf 100644 --- a/testsuite/python/virtual_sites_tracers_common.py +++ b/testsuite/python/virtual_sites_tracers_common.py @@ -27,7 +27,7 @@ from espressomd.utils import handle_errors -class VirtualSitesTracersCommon(object): +class VirtualSitesTracersCommon: box_height = 10. box_lw = 8. system = espressomd.System(box_l=(box_lw, box_lw, box_height)) diff --git a/testsuite/scripts/importlib_wrapper.py b/testsuite/scripts/importlib_wrapper.py index 636f00348e3..f481c5e5019 100644 --- a/testsuite/scripts/importlib_wrapper.py +++ b/testsuite/scripts/importlib_wrapper.py @@ -21,10 +21,7 @@ import unittest import importlib import espressomd -if sys.version_info >= (3, 3): - from unittest.mock import MagicMock -else: - from mock import MagicMock +from unittest.mock import MagicMock def _id(x): @@ -231,9 +228,9 @@ def mock_es_visualization(code): try: {0}{1} except ImportError: - from {2} import MagicMock + from unittest.mock import MagicMock import espressomd - {3} = MagicMock() + {2} = MagicMock() """.lstrip() # cannot handle "from espressomd.visualization import *" re_es_vis_import_namespace = re.compile( @@ -257,7 +254,6 @@ def check_for_deferred_ImportError(line, alias): return "" def substitution_es_vis_import(m): - mock_module = "unittest.mock" if sys.version_info >= (3, 3) else "mock" aliases = [x for x in m.groups() if x is not None][0].split(',') guards = [] for alias in aliases: @@ -268,7 +264,7 @@ def substitution_es_vis_import(m): alias = alias.split(' as ')[1] alias = alias.strip() checks = check_for_deferred_ImportError(line, alias) - s = r_es_vis_mock.format(line, checks, mock_module, alias) + s = r_es_vis_mock.format(line, checks, alias) guards.append(s) return '\n'.join(guards) diff --git a/testsuite/scripts/test_importlib_wrapper.py b/testsuite/scripts/test_importlib_wrapper.py index de19c9b73f3..825eb25e6e8 100644 --- a/testsuite/scripts/test_importlib_wrapper.py +++ b/testsuite/scripts/test_importlib_wrapper.py @@ -91,7 +91,6 @@ def test_set_random_seeds(self): self.assertEqual(str_out, str_exp) def test_mock_es_visualization(self): - mock_module = "unittest.mock" if sys.version_info >= (3, 3) else "mock" statement = "import espressomd.visualization" expected = """ try: @@ -100,10 +99,10 @@ def test_mock_es_visualization(self): hasattr(espressomd.visualization.openGLLive, 'deferred_ImportError'): raise ImportError() except ImportError: - from {} import MagicMock + from unittest.mock import MagicMock import espressomd espressomd.visualization = MagicMock() -""".format(mock_module) +""" self.assertEqual(iw.mock_es_visualization(statement), expected[1:]) statement = "import espressomd.visualization as test" @@ -114,10 +113,10 @@ def test_mock_es_visualization(self): hasattr(test.openGLLive, 'deferred_ImportError'): raise ImportError() except ImportError: - from {} import MagicMock + from unittest.mock import MagicMock import espressomd test = MagicMock() -""".format(mock_module) +""" self.assertEqual(iw.mock_es_visualization(statement), expected[1:]) statement = "from espressomd import visualization" @@ -128,10 +127,10 @@ def test_mock_es_visualization(self): hasattr(visualization.openGLLive, 'deferred_ImportError'): raise ImportError() except ImportError: - from {} import MagicMock + from unittest.mock import MagicMock import espressomd visualization = MagicMock() -""".format(mock_module) +""" self.assertEqual(iw.mock_es_visualization(statement), expected[1:]) statement = "from espressomd import visualization as test" @@ -142,10 +141,10 @@ def test_mock_es_visualization(self): hasattr(test.openGLLive, 'deferred_ImportError'): raise ImportError() except ImportError: - from {} import MagicMock + from unittest.mock import MagicMock import espressomd test = MagicMock() -""".format(mock_module) +""" self.assertEqual(iw.mock_es_visualization(statement), expected[1:]) statement = "from espressomd import visualization_mayavi" @@ -153,10 +152,10 @@ def test_mock_es_visualization(self): try: from espressomd import visualization_mayavi except ImportError: - from {} import MagicMock + from unittest.mock import MagicMock import espressomd visualization_mayavi = MagicMock() -""".format(mock_module) +""" self.assertEqual(iw.mock_es_visualization(statement), expected[1:]) statement = "from espressomd import visualization_mayavi as test" @@ -164,10 +163,10 @@ def test_mock_es_visualization(self): try: from espressomd import visualization_mayavi as test except ImportError: - from {} import MagicMock + from unittest.mock import MagicMock import espressomd test = MagicMock() -""".format(mock_module) +""" self.assertEqual(iw.mock_es_visualization(statement), expected[1:]) statement = "from espressomd.visualization_mayavi import mayaviLive" @@ -175,10 +174,10 @@ def test_mock_es_visualization(self): try: from espressomd.visualization_mayavi import mayaviLive except ImportError: - from {} import MagicMock + from unittest.mock import MagicMock import espressomd mayaviLive = MagicMock() -""".format(mock_module) +""" self.assertEqual(iw.mock_es_visualization(statement), expected[1:]) statement = "from espressomd.visualization_mayavi import mayaviLive as test" @@ -186,10 +185,10 @@ def test_mock_es_visualization(self): try: from espressomd.visualization_mayavi import mayaviLive as test except ImportError: - from {} import MagicMock + from unittest.mock import MagicMock import espressomd test = MagicMock() -""".format(mock_module) +""" self.assertEqual(iw.mock_es_visualization(statement), expected[1:]) statement = "from espressomd.visualization_mayavi import a as b, c" @@ -207,7 +206,7 @@ def test_mock_es_visualization(self): from unittest.mock import MagicMock import espressomd c = MagicMock() -""".format(mock_module) +""" self.assertEqual(iw.mock_es_visualization(statement), expected[1:]) statement = "from espressomd.visualization import openGLLive" @@ -217,10 +216,10 @@ def test_mock_es_visualization(self): if hasattr(openGLLive, 'deferred_ImportError'): raise openGLLive.deferred_ImportError except ImportError: - from {} import MagicMock + from unittest.mock import MagicMock import espressomd openGLLive = MagicMock() -""".format(mock_module) +""" self.assertEqual(iw.mock_es_visualization(statement), expected[1:]) statement = "from espressomd.visualization import openGLLive as test" @@ -230,10 +229,10 @@ def test_mock_es_visualization(self): if hasattr(test, 'deferred_ImportError'): raise test.deferred_ImportError except ImportError: - from {} import MagicMock + from unittest.mock import MagicMock import espressomd test = MagicMock() -""".format(mock_module) +""" self.assertEqual(iw.mock_es_visualization(statement), expected[1:]) # test exceptions