Skip to content

Commit

Permalink
Simplify unicode wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
jngrad committed Jul 29, 2019
1 parent 66f5992 commit d94aa45
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/python/espressomd/utils.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit d94aa45

Please sign in to comment.