Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove residual Python2-specific code #3026

Merged
merged 9 commits into from
Jul 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 5 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)


Expand All @@ -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()
Expand Down
5 changes: 0 additions & 5 deletions maintainer/CI/build_cmake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/config/defines.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from sys import argv


class Defines(object):
class Defines:

def __init__(self, compiler, flags=[]):
self._compiler = compiler
Expand Down
4 changes: 2 additions & 2 deletions src/config/featuredefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import re


class SyntaxError(object):
class SyntaxError:

def __init__(self, message, instead):
self.message = message
Expand All @@ -45,7 +45,7 @@ def toCPPExpr(expr):
return expr


class defs(object):
class defs:

def __init__(self, filename):
# complete set of all defined features
Expand Down
2 changes: 1 addition & 1 deletion src/python/espressomd/MDA_ESP/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
)


class Stream(object):
class Stream:

"""
Create an object that provides a MDAnalysis topology and a coordinate reader
Expand Down
2 changes: 1 addition & 1 deletion src/python/espressomd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions src/python/espressomd/actors.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/python/espressomd/analyze.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion src/python/espressomd/cellsystem.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/python/espressomd/checkpointing.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@


# Convenient Checkpointing for ESPResSo
class Checkpoint(object):
class Checkpoint:

"""Checkpoint handling (reading and writing).

Expand Down
24 changes: 13 additions & 11 deletions src/python/espressomd/cluster_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
"""
Expand All @@ -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
----------
Expand All @@ -70,17 +70,19 @@ 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.

"""
_so_name = "ClusterAnalysis::ClusterStructure"
_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):
Expand All @@ -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")
Expand Down Expand Up @@ -126,15 +128,15 @@ def clusters(self):
return self._clusters


class Clusters(object):
class Clusters:

"""Access to the clusters in the cluster structure.

Access is as follows:

* Number of clusters: len(clusters)
* Access a cluster via its id: clusters[id]
* Iterate over clusters:::
* Iterate over clusters::

for c in clusters:

Expand Down
20 changes: 10 additions & 10 deletions src/python/espressomd/collision_detection.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand Down Expand Up @@ -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.
Expand All @@ -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"]]
Expand All @@ -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])

Expand Down
2 changes: 1 addition & 1 deletion src/python/espressomd/comfixed.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""

Expand Down
Loading