Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rwood-97 committed Nov 21, 2024
1 parent a4024ff commit a7c3e84
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
9 changes: 6 additions & 3 deletions tests/test_text_spotting/test_deepsolo_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

from mapreader import DeepSoloRunner
from mapreader.load import MapImages
from mapreader.spot_text.dataclasses import Prediction

# use cloned DeepSolo path if running in github actions
DEEPSOLO_PATH = (
Expand Down Expand Up @@ -142,8 +143,9 @@ def test_deepsolo_run_all(init_runner, mock_response):
assert isinstance(out, dict)
assert "patch-0-0-800-40-#mapreader_text.png#.png" in out.keys()
assert isinstance(out["patch-0-0-800-40-#mapreader_text.png#.png"], list)
assert isinstance(out["patch-0-0-800-40-#mapreader_text.png#.png"][0], Prediction)
# dataframe
out = runner._dict_to_dataframe(runner.patch_predictions, geo=False, parent=False)
out = runner._dict_to_dataframe(runner.patch_predictions)
assert isinstance(out, pd.DataFrame)
assert set(out.columns) == set(["image_id", "geometry", "text", "score"])
assert "patch-0-0-800-40-#mapreader_text.png#.png" in out["image_id"].values
Expand All @@ -156,8 +158,9 @@ def test_deepsolo_convert_to_parent(runner_run_all, mock_response):
assert isinstance(out, dict)
assert "mapreader_text.png" in out.keys()
assert isinstance(out["mapreader_text.png"], list)
assert isinstance(out["mapreader_text.png"][0], Prediction)
# dataframe
out = runner._dict_to_dataframe(runner.parent_predictions, geo=False, parent=True)
out = runner._dict_to_dataframe(runner.parent_predictions)
assert isinstance(out, pd.DataFrame)
assert set(out.columns) == set(
["image_id", "patch_id", "geometry", "text", "score"]
Expand All @@ -173,7 +176,7 @@ def test_deepsolo_convert_to_parent_coords(runner_run_all, mock_response):
assert "mapreader_text.png" in out.keys()
assert isinstance(out["mapreader_text.png"], list)
# dataframe
out = runner._dict_to_dataframe(runner.geo_predictions, geo=True, parent=True)
out = runner._dict_to_dataframe(runner.geo_predictions)
assert isinstance(out, gpd.GeoDataFrame)
assert set(out.columns) == set(
["image_id", "patch_id", "geometry", "crs", "text", "score"]
Expand Down
6 changes: 3 additions & 3 deletions tests/test_text_spotting/test_dptext_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def test_dptext_run_all(init_runner, mock_response):
assert "patch-0-0-800-40-#mapreader_text.png#.png" in out.keys()
assert isinstance(out["patch-0-0-800-40-#mapreader_text.png#.png"], list)
# dataframe
out = runner._dict_to_dataframe(runner.patch_predictions, geo=False, parent=False)
out = runner._dict_to_dataframe(runner.patch_predictions)
assert isinstance(out, pd.DataFrame)
assert set(out.columns) == set(["image_id", "geometry", "score"])
assert "patch-0-0-800-40-#mapreader_text.png#.png" in out["image_id"].values
Expand All @@ -158,7 +158,7 @@ def test_dptext_convert_to_parent(runner_run_all, mock_response):
assert "mapreader_text.png" in out.keys()
assert isinstance(out["mapreader_text.png"], list)
# dataframe
out = runner._dict_to_dataframe(runner.parent_predictions, geo=False, parent=True)
out = runner._dict_to_dataframe(runner.parent_predictions)
assert isinstance(out, pd.DataFrame)
assert set(out.columns) == set(["image_id", "patch_id", "geometry", "score"])
assert "mapreader_text.png" in out["image_id"].values
Expand All @@ -172,7 +172,7 @@ def test_dptext_convert_to_parent_coords(runner_run_all, mock_response):
assert "mapreader_text.png" in out.keys()
assert isinstance(out["mapreader_text.png"], list)
# dataframe
out = runner._dict_to_dataframe(runner.geo_predictions, geo=True, parent=True)
out = runner._dict_to_dataframe(runner.geo_predictions)
assert isinstance(out, gpd.GeoDataFrame)
assert set(out.columns) == set(["image_id", "patch_id", "geometry", "crs", "score"])
assert "mapreader_text.png" in out["image_id"].values
Expand Down
6 changes: 3 additions & 3 deletions tests/test_text_spotting/test_maptext_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def test_maptext_run_all(init_runner, mock_response):
assert "patch-0-0-800-40-#mapreader_text.png#.png" in out.keys()
assert isinstance(out["patch-0-0-800-40-#mapreader_text.png#.png"], list)
# dataframe
out = runner._dict_to_dataframe(runner.patch_predictions, geo=False, parent=False)
out = runner._dict_to_dataframe(runner.patch_predictions)
assert isinstance(out, pd.DataFrame)
assert set(out.columns) == set(["image_id", "geometry", "text", "score"])
assert "patch-0-0-800-40-#mapreader_text.png#.png" in out["image_id"].values
Expand All @@ -158,7 +158,7 @@ def test_maptext_convert_to_parent(runner_run_all, mock_response):
assert "mapreader_text.png" in out.keys()
assert isinstance(out["mapreader_text.png"], list)
# dataframe
out = runner._dict_to_dataframe(runner.parent_predictions, geo=False, parent=True)
out = runner._dict_to_dataframe(runner.parent_predictions)
assert isinstance(out, pd.DataFrame)
assert set(out.columns) == set(
["image_id", "patch_id", "geometry", "text", "score"]
Expand All @@ -174,7 +174,7 @@ def test_maptext_convert_to_parent_coords(runner_run_all, mock_response):
assert "mapreader_text.png" in out.keys()
assert isinstance(out["mapreader_text.png"], list)
# dataframe
out = runner._dict_to_dataframe(runner.geo_predictions, geo=True, parent=True)
out = runner._dict_to_dataframe(runner.geo_predictions)
assert isinstance(out, gpd.GeoDataFrame)
assert set(out.columns) == set(
["image_id", "patch_id", "geometry", "crs", "text", "score"]
Expand Down

0 comments on commit a7c3e84

Please sign in to comment.