Skip to content

Commit 905d409

Browse files
test: check crop works
1 parent 49dc7d6 commit 905d409

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

automated_test.py

+27-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import numpy as np
66

77
import osteoid
8-
from osteoid import Skeleton
8+
from osteoid import Skeleton, Bbox
99
from osteoid.exceptions import SkeletonDecodeError, SkeletonAttributeMixingError
1010

1111
def test_consolidate():
@@ -502,4 +502,30 @@ def test_paths():
502502
assert np.all(path[0] == path1)
503503
assert np.all(path[1] == path2)
504504

505+
def test_crop():
506+
skel = Skeleton(
507+
[ (0,0,0), (10,0,1), (20,0,2), (30,1,3) ],
508+
edges=[ (0,1), (1,2), (1,3) ],
509+
segid=1,
510+
)
511+
512+
bbx = Bbox([5,-1,0], [25,5,3])
513+
res = skel.crop(bbx)
514+
515+
assert np.all(res.vertices == np.array([(10,0,1), (20,0,2)]))
516+
517+
bbx = Bbox([100,-1,0], [200,5,3])
518+
res = skel.crop(bbx)
519+
assert len(res.vertices) == 0
520+
521+
bbx = Bbox([-100,-100,-100], [200,500,400])
522+
res = skel.crop(bbx)
523+
assert np.all(res.vertices == skel.vertices)
524+
525+
526+
527+
528+
529+
530+
505531

0 commit comments

Comments
 (0)