Skip to content

Commit

Permalink
Merge pull request #617 from cmu-delphi/krivard/fix-covidcast-py-plot…
Browse files Browse the repository at this point in the history
…-tests

Fix plotting tests in python covidcast
  • Loading branch information
krivard committed Mar 29, 2023
2 parents 13c9c8b + 6360672 commit 781704c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Python-packages/covidcast-py/covidcast/plotting.py
Expand Up @@ -324,7 +324,7 @@ def _project_and_transform(data: gpd.GeoDataFrame,

alaska.geometry = alaska.geometry.scale(0.35, 0.35, origin=(0, 0)).translate(-1.8e6, -1.6e6)
hawaii.geometry = hawaii.geometry.translate(-1e6, -2e6)
pr.geometry = pr.geometry.translate(-0.9e6, 1e6).rotate(-16, origin=(0, 0))
pr.geometry = pr.geometry.translate(-1.2e6, 0.5e6)
return cont, alaska, pr, hawaii


Expand Down
Binary file not shown.
8 changes: 5 additions & 3 deletions Python-packages/covidcast-py/tests/test_plotting.py
Expand Up @@ -5,6 +5,8 @@
import matplotlib
import platform
import geopandas as gpd
# for some reason gpd.testing gives "no attribute" so we'll import it explicitly
import geopandas.testing as gpd_testing
import numpy as np
import pandas as pd
import pytest
Expand Down Expand Up @@ -195,23 +197,23 @@ def test__join_county_geo_df():
os.path.join(CURRENT_PATH,
"reference_data/expected__join_county_geo_df_no_mega_right.gpkg"),
dtype={"geo_value": str})
pd.testing.assert_frame_equal(expected_no_mega_r, no_mega_r)
gpd_testing.assert_geodataframe_equal(expected_no_mega_r, no_mega_r)

# test left join
no_mega_l = plotting._join_county_geo_df(test_input, "county_code", geo_info, "left")
expected_no_mega_l = gpd.read_file(
os.path.join(CURRENT_PATH,
"reference_data/expected__join_county_geo_df_no_mega_left.gpkg"),
dtype={"geo_value": str})
pd.testing.assert_frame_equal(expected_no_mega_l, no_mega_l)
gpd_testing.assert_geodataframe_equal(expected_no_mega_l, no_mega_l)

# test w/ megacounty combine
mega = plotting._join_county_geo_df(test_input, "county_code", geo_info, "left", True)
expected_mega = gpd.read_file(
os.path.join(CURRENT_PATH,
"reference_data/expected__join_county_geo_df_mega.gpkg"),
dtype={"geo_value": str})
pd.testing.assert_frame_equal(expected_mega, mega)
gpd_testing.assert_geodataframe_equal(expected_mega, mega)


def test__join_msa_geo_df():
Expand Down

0 comments on commit 781704c

Please sign in to comment.