Skip to content

Commit

Permalink
tests: update tests for qupath 0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ap-- committed Dec 3, 2022
1 parent 5ffd064 commit 8f70b61
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,18 @@ paquo to use that version. Currently, paquo supports every version of QuPath fro
`0.2.0` to the most recent. _(We even support older `0.2.0-mX` versions but no guarantees)._

```shell
> paquo get_qupath --install-path "/some/path/on/your/machine" 0.3.2
# downloading: https://github.com/qupath/qupath/releases/download/v0.3.2/QuPath-0.3.2-Linux.tar.xz
> paquo get_qupath --install-path "/some/path/on/your/machine" 0.4.0
# downloading: https://github.com/qupath/qupath/releases/download/v0.4.0/QuPath-0.4.0-Linux.tar.xz
# progress ................... OK
# extracting: [...]/QuPath-0.3.2-Linux.tar.xz
# available at: /some/path/on/your/machine/QuPath-0.3.2
# extracting: [...]/QuPath-0.4.0-Linux.tar.xz
# available at: /some/path/on/your/machine/QuPath-0.4.0
#
# use via environment variable:
# $ export PAQUO_QUPATH_DIR=/some/path/on/your/machine/QuPath-0.3.2
# $ export PAQUO_QUPATH_DIR=/some/path/on/your/machine/QuPath-0.4.0
#
# use via .paquo.toml config file:
# qupath_dir="/some/path/on/your/machine/QuPath-0.3.2"
/some/path/on/your/machine/QuPath-0.3.2
# qupath_dir="/some/path/on/your/machine/QuPath-0.4.0"
/some/path/on/your/machine/QuPath-0.4.0
```


Expand Down
12 changes: 7 additions & 5 deletions paquo/tests/test_hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def test_geojson_roundtrip_via_geojson(empty_hierarchy):

# qupath version v0.4.0 made changes to the geojson format
# 1. the 'id' key is added again but seems to be a UUID for each annotation
TEST_ANNOTATION_POLYGON_VERSION_0_4_0_snapshot = [{
TEST_ANNOTATION_POLYGON_VERSION_0_4_0 = [{
'type': 'Feature',
'id': '7d254d72-a9a0-43a6-a455-3fa99e83b7af',
'geometry': {
Expand All @@ -193,10 +193,10 @@ def test_geojson_roundtrip_via_geojson(empty_hierarchy):
'properties': {
'classification': {
'name': 'Tumor',
'colorRGB': -3670016
'color': [200, 0, 0],
},
'isLocked': False,
'object_type': 'annotation',
'objectType': 'annotation',
}
}]

Expand All @@ -208,7 +208,7 @@ def example_annotation(qupath_version):
elif qupath_version < QuPathVersion("0.4.0"):
yield deepcopy(TEST_ANNOTATION_POLYGON_VERSION_0_3_0_rc1_plus)
else:
yield deepcopy(TEST_ANNOTATION_POLYGON_VERSION_0_4_0_snapshot)
yield deepcopy(TEST_ANNOTATION_POLYGON_VERSION_0_4_0)


def is_uuid(x):
Expand All @@ -224,7 +224,7 @@ def is_uuid(x):
"input_annotation", [
pytest.param(TEST_ANNOTATION_POLYGON_VERSION_0_2_3, id='v0.2.3'),
pytest.param(TEST_ANNOTATION_POLYGON_VERSION_0_3_0_rc1_plus, id='v0.3.0rc1'),
pytest.param(TEST_ANNOTATION_POLYGON_VERSION_0_4_0_snapshot, id='v0.4.0+snapshot'),
pytest.param(TEST_ANNOTATION_POLYGON_VERSION_0_4_0, id='v0.4.0'),
]
)
def test_geojson_roundtrip_via_annotations(empty_hierarchy, example_annotation, input_annotation, qupath_version):
Expand All @@ -239,6 +239,8 @@ def test_geojson_roundtrip_via_annotations(empty_hierarchy, example_annotation,
out_id = output[0].pop("id", "")
test_id = example_annotation[0].pop("id", "")
assert is_uuid(out_id) and is_uuid(test_id)
# isLocked is not exported
del example_annotation[0]["properties"]["isLocked"]
assert output == example_annotation


Expand Down
14 changes: 11 additions & 3 deletions paquo/tests/test_pathobjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ def test_geojson_serialization(path_annotation, qupath_version):
# bad practice
if qupath_version <= QuPathVersion("0.2.3"):
assert geo_json["id"] == "PathAnnotationObject"
else:
elif qupath_version < QuPathVersion("0.4.0"):
assert geo_json["properties"]["object_type"] == "annotation"
else:
assert geo_json["properties"]["objectType"] == "annotation"

assert "geometry" in geo_json
geom = geo_json["geometry"]
Expand All @@ -76,7 +78,10 @@ def test_geojson_serialization(path_annotation, qupath_version):
assert "properties" in geo_json
prop = geo_json["properties"]

assert prop["isLocked"] == path_annotation.locked
if qupath_version < QuPathVersion("0.4.0"):
assert prop["isLocked"] == path_annotation.locked
else:
assert "isLocked" not in prop

# bad practice
if qupath_version <= QuPathVersion("0.2.3"):
Expand All @@ -89,7 +94,10 @@ def test_geojson_serialization(path_annotation, qupath_version):
assert prop["measurements"] == measurements

assert prop["classification"]["name"] == path_annotation.path_class.name
assert prop["classification"]["colorRGB"] == path_annotation.path_class.color.to_java_rgba()
if qupath_version < QuPathVersion("0.4.0"):
assert prop["classification"]["colorRGB"] == path_annotation.path_class.color.to_java_rgba()
else:
assert tuple(prop["classification"]["color"]) == path_annotation.path_class.color.to_rgb()


def test_annotation_object():
Expand Down

0 comments on commit 8f70b61

Please sign in to comment.