Skip to content

Commit

Permalink
fix #390
Browse files Browse the repository at this point in the history
  • Loading branch information
daler committed Aug 12, 2023
1 parent 588c76b commit 936f10a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pybedtools/cbedtools.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from cpython.version cimport PY_MAJOR_VERSION
from libcpp.string cimport string
import numpy as np

# Python byte strings automatically coerce to/from C++ strings.

Expand All @@ -24,7 +25,7 @@ cdef _cppstr(s):
#
# C++ uses bytestrings. PY2 strings need no conversion; bare PY3 strings
# are unicode and so must be encoded to bytestring.
if isinstance(s, int):
if isinstance(s, integer_types):
s = str(s)
if isinstance(s, unicode):
s = s.encode('UTF-8')
Expand All @@ -37,9 +38,9 @@ cdef _pystr(string s):
return s.decode('UTF-8', 'strict')

if PY_MAJOR_VERSION < 3:
integer_types = (int, long)
integer_types = (int, long, np.int64)
else:
integer_types = (int,)
integer_types = (int, np.int64)

"""
bedtools.pyx: A Cython wrapper for the BEDTools BedFile class
Expand Down
6 changes: 6 additions & 0 deletions pybedtools/test/test_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -913,3 +913,9 @@ def test_issue_365():
# tabs in user's original file or maybe copying from UCSC
a = pybedtools.example_bedtool('example.narrowPeak')
a[0]

def test_issue_390():
# Previously raised AttributeError: 'numpy.int64' object has no attribute 'isdigit'
# Fix was to include np.int64 as an integer type in cbedtools.pyx.
import numpy as np
pybedtools.BedTool([['chr1', np.int64(1), np.int64(2)]])

0 comments on commit 936f10a

Please sign in to comment.