Skip to content

Commit

Permalink
Clean uint32 test
Browse files Browse the repository at this point in the history
  • Loading branch information
alanocallaghan committed Nov 1, 2024
1 parent 35d5d21 commit 78074e0
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions tests/images/test_labeled_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
large_metadata = ImageMetadata(
"/path/to/img.tiff",
"Image name",
(ImageShape(1000, 500),),
(ImageShape(500, 250),),
PixelCalibration(
PixelLength.create_microns(2.5),
PixelLength.create_microns(2.5)
Expand Down Expand Up @@ -397,24 +397,27 @@ def test_read_polygon_in_single_channel_image_without_label_map_with_downsample(

def test_label_can_hold_many_values():
downsample = 1
max_objects = 500
random.seed(42)
max_objects = 1000
random.seed(1)
def rands():
x = random.randint(0, int(large_metadata.shape.x / downsample))
y = random.randint(0, int(large_metadata.shape.x / downsample))
return (
random.randint(0, int(sample_metadata.shape.x / downsample)),
random.randint(0, int(sample_metadata.shape.y / downsample))
(x, y),
(x + 1, y),
(x + 1, y + 1),
(x, y + 1)
)

coords = [(rands(), rands(), rands(), rands()) for i in range(max_objects)]
coords = list(set(coords))
coords = [rands() for i in range(max_objects)]

n_objects = len(coords)
features = [ImageFeature(geojson.Polygon([coords[i]]), Classification("Some classification")) for i in range(n_objects)]
labeled_server = LabeledImageServer(large_metadata, features, multichannel=False, downsample=downsample)

image = labeled_server.read_region(1, Region2D(0, 0, labeled_server.metadata.width, labeled_server.metadata.height))

assert np.max(image) > 255
assert np.max(image) == max_objects


def test_single_channel_labeled_image_with_region_request():
Expand Down

0 comments on commit 78074e0

Please sign in to comment.