Skip to content

Commit

Permalink
fix: fix the breaking change in hmmlearn (#1239)
Browse files Browse the repository at this point in the history
  • Loading branch information
njzjz committed Jul 20, 2021
1 parent aea357f commit 8ff6271
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion reacnetgenerator/_detect.py
Expand Up @@ -165,7 +165,7 @@ def _readNfunc(self, f):
iscompleted = True
stepaindex = index
N = [int(s) for s in line.split() if s.isdigit()][0]
atomtype = np.zeros(N, dtype=np.int)
atomtype = np.zeros(N, dtype=int)
else:
s = line.split()
atomtype[int(s[0])-1] = int(s[1])-1
Expand Down
3 changes: 2 additions & 1 deletion reacnetgenerator/_hmmfilter.py
Expand Up @@ -21,6 +21,7 @@
import tempfile
from contextlib import ExitStack

import numpy as np
from hmmlearn import hmm

from .utils import WriteBuffer, appendIfNotNone, bytestolist, listtobytes, run_mp, SharedRNGData
Expand Down Expand Up @@ -60,7 +61,7 @@ def _getoriginandhmm(self, item):
origin) if self.getoriginfile else None
hmmbytes = None
if self.runHMM:
hmmsignal = self._model.predict(origin)
hmmsignal = self._model.predict(origin).astype(np.int8)
if check_zero_signal(hmmsignal) or self.printfiltersignal:
hmmbytes = listtobytes(hmmsignal)
return originbytes, hmmbytes, line_c
Expand Down
4 changes: 2 additions & 2 deletions reacnetgenerator/_matrix.py
Expand Up @@ -71,8 +71,8 @@ def _printtable(self, allroute, timeaxis=None):
newreactions.append(reac)
sortedreactions = newreactions

table = np.zeros((maxsize, maxsize), dtype=np.int)
reactionnumber = np.zeros((2), dtype=np.int)
table = np.zeros((maxsize, maxsize), dtype=int)
reactionnumber = np.zeros((2), dtype=int)
with open(self.reactionfilename if timeaxis is None else f"{self.reactionfilename}.{timeaxis}", 'w') as f:
for reaction, n_reaction in sortedreactions:
f.write(f"{n_reaction} {'->'.join(reaction)}\n")
Expand Down
4 changes: 2 additions & 2 deletions reacnetgenerator/utils_np.pyx
Expand Up @@ -7,7 +7,7 @@ import numpy as np
cimport numpy as np
cimport cython

DTYPE = np.int
DTYPE = int
ctypedef np.int_t DTYPE_t
DTYPE8 = np.int8
ctypedef np.int8_t DTYPE8_t
Expand All @@ -31,7 +31,7 @@ cpdef idx_to_signal(DTYPE_t[:] idx, int step):

@cython.boundscheck(False)
@cython.wraparound(False)
cpdef check_zero_signal(DTYPE_t[:] signal):
cpdef check_zero_signal(DTYPE8_t[:] signal):
"""Benchmark for 1,000,000 loops (1000/2000):
Cython: 1.45 s
Python: 3.67 s
Expand Down

1 comment on commit 8ff6271

@vercel
Copy link

@vercel vercel bot commented on 8ff6271 Jul 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.