Skip to content

float64_t support removed #43

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
12 changes: 6 additions & 6 deletions seqlearn/_decode/bestfirst.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ import numpy as np

np.import_array()

cdef np.float64_t NEGINF = -np.inf
cdef np.float64 NEGINF = -np.inf


@cython.boundscheck(False)
@cython.wraparound(False)
def bestfirst(np.ndarray[ndim=2, dtype=np.float64_t] score,
def bestfirst(np.ndarray[ndim=2, dtype=np.float64] score,
trans_score,
np.ndarray[ndim=2, dtype=np.float64_t] trans,
np.ndarray[ndim=1, dtype=np.float64_t, mode="c"] init,
np.ndarray[ndim=1, dtype=np.float64_t, mode="c"] final):
np.ndarray[ndim=2, dtype=np.float64] trans,
np.ndarray[ndim=1, dtype=np.float64, mode="c"] init,
np.ndarray[ndim=1, dtype=np.float64, mode="c"] final):
"""First-order heuristic best-first decoder.

See viterbi for the arguments. score may be overwritten.
Expand All @@ -24,7 +24,7 @@ def bestfirst(np.ndarray[ndim=2, dtype=np.float64_t] score,

cdef:
np.ndarray[ndim=1, dtype=np.npy_intp, mode="c"] path
np.float64_t candidate, maxval
np.float64 candidate, maxval
np.npy_intp i, j, maxind, n_samples, n_states

if trans_score is not None:
Expand Down
14 changes: 7 additions & 7 deletions seqlearn/_decode/viterbi.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ import numpy as np

np.import_array()

cdef np.float64_t NEGINF = -np.inf
cdef np.float64 NEGINF = -np.inf


@cython.boundscheck(False)
@cython.wraparound(False)
def viterbi(np.ndarray[ndim=2, dtype=np.float64_t] score,
np.ndarray[ndim=3, dtype=np.float64_t] trans_score,
np.ndarray[ndim=2, dtype=np.float64_t] b_trans,
np.ndarray[ndim=1, dtype=np.float64_t] init,
np.ndarray[ndim=1, dtype=np.float64_t] final):
def viterbi(np.ndarray[ndim=2, dtype=np.float64] score,
np.ndarray[ndim=3, dtype=np.float64] trans_score,
np.ndarray[ndim=2, dtype=np.float64] b_trans,
np.ndarray[ndim=1, dtype=np.float64] init,
np.ndarray[ndim=1, dtype=np.float64] final):
"""First-order Viterbi algorithm.

Parameters
Expand All @@ -41,7 +41,7 @@ def viterbi(np.ndarray[ndim=2, dtype=np.float64_t] score,

cdef np.ndarray[ndim=2, dtype=np.npy_intp, mode='c'] backp
cdef np.ndarray[ndim=1, dtype=np.npy_intp, mode='c'] path
cdef np.float64_t candidate, maxval
cdef np.float64 candidate, maxval
cdef np.npy_intp i, j, k, n_samples, n_states

n_samples, n_states = score.shape[0], score.shape[1]
Expand Down
4 changes: 2 additions & 2 deletions seqlearn/_utils/safeadd.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ np.import_array()

@cython.boundscheck(False)
@cython.wraparound(False)
def safe_add(np.ndarray[ndim=2, dtype=np.float64_t] A, B):
def safe_add(np.ndarray[ndim=2, dtype=np.float] A, B):
"""A += B where B is a sparse (CSR or CSC) matrix.

__rsub__ on a sparse matrix densifies prior to subtracting, making it
Expand All @@ -20,7 +20,7 @@ def safe_add(np.ndarray[ndim=2, dtype=np.float64_t] A, B):
"""

cdef:
np.ndarray[ndim=1, dtype=np.float64_t, mode="c"] data
np.ndarray[ndim=1, dtype=np.float, mode="c"] data
np.ndarray[ndim=1, dtype=int, mode="c"] indices
np.ndarray[ndim=1, dtype=int, mode="c"] indptr

Expand Down