Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
srush committed Aug 30, 2019
1 parent 48f2e6b commit 038e52d
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion torch_struct/test_algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from .deptree import deptree_inside, deptree, deptree_check, deptree_nonproj
from .linearchain import linearchain, linearchain_forward, linearchain_check, hmm
from .semimarkov import semimarkov, semimarkov_forward, semimarkov_check
from .semirings import LogSemiring, MaxSemiring
from .semirings import LogSemiring, MaxSemiring, StdSemiring, SampledSemiring
import torch
from hypothesis import given, settings
from hypothesis.strategies import integers
Expand All @@ -11,6 +11,17 @@
tint = integers(min_value=1, max_value=2)


@given(smint, smint, smint)
def test_simple(batch, N, C):
vals = torch.ones(batch, N, C, C)
semiring = StdSemiring

alpha, _ = linearchain_forward(vals, semiring)
assert (alpha == pow(C, N + 1)).all()

sample = linearchain(vals, SampledSemiring)


@given(smint, smint, smint)
@settings(max_examples=50)
def test_linearchain(batch, N, C):
Expand Down

0 comments on commit 038e52d

Please sign in to comment.