Skip to content

Commit

Permalink
fix and test integer freehand shapes
Browse files Browse the repository at this point in the history
  • Loading branch information
tdsmith committed Apr 1, 2015
1 parent 62a3bb2 commit 020a615
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
1 change: 0 additions & 1 deletion ijroi/ijroi.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ def getfloat():
if options & SUB_PIXEL_RESOLUTION == 0:
points[:, 1] += left
points[:, 0] += top
points -= 1

return points

Expand Down
Binary file added ijroi/tests/fixtures/freehand_integer.roi
Binary file not shown.
8 changes: 8 additions & 0 deletions ijroi/tests/fixtures/generate_fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,12 @@ for(var i = 0; i < 100; ++i) {
freehand_circle = PolygonRoi(x, y, 100, Roi.FREEROI);
RoiEncoder.save(freehand_circle, "freehand_circle.roi");

var xi = new java.lang.reflect.Array.newInstance(java.lang.Integer.TYPE, 3);
var yi = new java.lang.reflect.Array.newInstance(java.lang.Integer.TYPE, 3);
xi[0] = 1; xi[1] = 10; xi[2] = 10;
yi[0] = 1; yi[1] = 10; yi[2] = 1;

freehand_integer = PolygonRoi(xi, yi, 3, Roi.FREEROI);
RoiEncoder.save(freehand_integer, "freehand_integer.roi");

"Success";
8 changes: 8 additions & 0 deletions ijroi/tests/test_ijroi.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,11 @@ def test_freehand_circle():
with fixture.open("rb") as f:
circle = ijroi.read_roi(f)
assert abs(circle[:,1].mean()-10) < 0.01

def test_integer_freehand():
fixture = get_fixture("freehand_integer.roi")
with fixture.open("rb") as f:
freehand = ijroi.read_roi(f)
assert len(freehand) == 3
assert all(freehand[2, :] == [1, 10])
assert freehand.dtype == np.int16

0 comments on commit 020a615

Please sign in to comment.