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

Fix bytestring issues in Python3 #2898

Merged
merged 1 commit into from Jun 12, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/python/espressomd/electrostatics.pxd
Expand Up @@ -23,7 +23,7 @@ include "myconfig.pxi"
from espressomd.system cimport *
cimport numpy as np
from espressomd.utils cimport *
from espressomd.utils import is_valid_type
from espressomd.utils import is_valid_type, to_str

cdef extern from "SystemInterface.hpp":
cdef cppclass SystemInterface:
Expand Down Expand Up @@ -135,7 +135,7 @@ IF ELECTROSTATICS:
response = p3m_adaptive_tune(& log)
handle_errors("Error in p3m_adaptive_tune")
if log.strip():
print(log)
print(to_str(log))
return response

cdef inline python_p3m_set_params(p_r_cut, p_mesh, p_cao, p_alpha, p_accuracy):
Expand Down Expand Up @@ -224,9 +224,9 @@ IF ELECTROSTATICS:
if MMM1D_sanity_checks() == 1:
handle_errors(
"MMM1D Sanity check failed: wrong periodicity or wrong cellsystem, PRTFM")
resp = mmm1d_tune( & log)
resp = mmm1d_tune(& log)
if resp:
print(log)
print(to_str(log))
return resp

IF ELECTROSTATICS:
Expand Down
4 changes: 2 additions & 2 deletions src/python/espressomd/electrostatics.pyx
Expand Up @@ -28,7 +28,7 @@ IF SCAFACOS == 1:
from .scafacos import ScafacosConnector
from . cimport scafacos
from espressomd.utils cimport handle_errors
from espressomd.utils import is_valid_type
from espressomd.utils import is_valid_type, to_str
from . cimport checks
from .c_analyze cimport partCfg, PartCfg
from .particle_data cimport particle
Expand Down Expand Up @@ -66,7 +66,7 @@ IF ELECTROSTATICS == 1:

def _deactivate_method(self):
deactivate_method()
handle_errors("Coulom method deactivation")
handle_errors("Coulomb method deactivation")

def tune(self, **tune_params_subset):
if tune_params_subset is not None:
Expand Down
4 changes: 2 additions & 2 deletions src/python/espressomd/magnetostatics.pyx
Expand Up @@ -26,7 +26,7 @@ IF SCAFACOS == 1:
from . cimport scafacos

from espressomd.utils cimport handle_errors
from espressomd.utils import is_valid_type
from espressomd.utils import is_valid_type, to_str

IF DIPOLES == 1:
cdef class MagnetostaticInteraction(Actor):
Expand Down Expand Up @@ -173,7 +173,7 @@ IF DP3M == 1:
if resp:
raise Exception(
"failed to tune dipolar P3M parameters to required accuracy")
print(log)
print(to_str(log))
self._params.update(self._get_params_from_es_core())

def _activate_method(self):
Expand Down
10 changes: 6 additions & 4 deletions src/python/espressomd/utils.pyx
Expand Up @@ -61,7 +61,7 @@ cpdef check_type_or_throw_except(x, n, t, msg):
checking is done on the elements, and all elements are checked. Integers
are accepted when a float was asked for.

"""
"""
# Check whether x is an array/list/tuple or a single value
if n > 1:
if hasattr(x, "__getitem__"):
Expand Down Expand Up @@ -254,13 +254,15 @@ cpdef handle_errors(msg):

"""
errors = mpi_gather_runtime_errors()
# print all errors and warnings
for err in errors:
err.print()

# raise an exception with the first error
for err in errors:
# Cast because cython does not support typed enums completely
if < int > err.level() == <int > ERROR:
raise Exception("{}: {}".format(msg, err.format()))
# Cast because cython does not support typed enums completely
if < int > err.level() == < int > ERROR:
raise Exception("{}: {}".format(msg, to_str(err.format())))


def nesting_level(obj):
Expand Down