-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Factor code from WCT test helper ssss-pdsp.py into more proper wcpy.
- Loading branch information
1 parent
a90b916
commit d456b6b
Showing
7 changed files
with
906 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import numpy as np | ||
from wirecell.util.bbox import * | ||
|
||
|
||
def test_slice(): | ||
assert slice(0,4) == union_slice(slice(0,4), slice(1,2)) # inside | ||
assert slice(0,4) == union_slice(slice(1,2), slice(0,4)) # outside | ||
assert slice(0,4) == union_slice(slice(0,1), slice(2,4)) # gap | ||
assert slice(0,4) == union_slice(slice(0,4), slice(1,4)) # overlap | ||
|
||
def test_slice(): | ||
assert np.all(np.array([0,1,2,3]) == union_array(slice(0,4), slice(1,2), order="ascending")) | ||
assert np.all(np.array([1,0,2,3]) == union_array(slice(1,2), slice(0,4), order="seen")) | ||
assert np.all(np.array([1,0,1,2,3]) == union_array(slice(1,2), slice(0,4), order=None)) | ||
assert np.all(np.array([2,3,0]) == union_array(slice(2,4), slice(0,1), order="seen")) | ||
assert np.all(np.array([3,2,1,0]) == union_array(slice(0,4), slice(1,4), order="descending")) | ||
|
||
def test_bbox(): | ||
bb1 = (slice(0,2), slice(10,12)) | ||
bb2 = (slice(3,5), slice(13,15)) | ||
u1 = union(bb1, bb2, form="slices") | ||
assert slice(0,5) == u1[0] | ||
assert slice(10,15) == u1[1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env pytest | ||
|
||
from wirecell.util.peaks import * | ||
from wirecell.util.codec import JsonEncoder | ||
|
||
def roundtrip_dataclass(DCType): | ||
t = DCType() | ||
d = t.to_dict() | ||
print(d) | ||
j = json.dumps(d, cls=JsonEncoder) | ||
d2 = json.loads(j) | ||
print(d2) | ||
assert d == d2 | ||
t2 = DCType.from_dict(d2) | ||
|
||
|
||
def test_dataclasses(): | ||
roundtrip_dataclass(Peak1d) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.