Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Tests/test_geocode.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def test_reverse_geocode_gsp(self):
"""
Test the `reverse_geocode_gsp` function with several test cases.
"""
gsp_regions = ["BRED_1", "DEWP"]
gsp_regions = [("BRED_1", "_G"), ("DEWP", "_N")]
latlons = [(53.33985, -2.051880), (55.950095, -3.178485)]
with Geocoder() as geo:
assert_equal(
Expand Down
3 changes: 3 additions & 0 deletions geocode/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,9 @@ def reverse_geocode(
)
joined.update(nearest, overwrite=False)
joined["region_id"] = joined["region_id"].where(pd.notna(joined["region_id"]), None)
if "GSPGroup" in joined.columns:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what the if condition is for? won't this always evaluate to True?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't be True when reverse geo-coding llsoa and nuts

joined["GSPGroup"] = joined["GSPGroup"].replace({pd.NA: None})
return list(zip(joined["region_id"], joined["GSPGroup"]))
return joined["region_id"].tolist()
Comment on lines +283 to 284
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think its desirable to sometime return a list of strings and other times to return a list of tuples. I think we should always return a list of tuples, or else introduce a parameter to determine whether to return the GSPGroup or not (though the latter smells a little)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since llsoa and nuts doesn't need to return a list of tuples, I think we should come up with something else. Is it okay to make a separate function for reverse geo-coding gsp?



Expand Down