Skip to content

Commit be8e924

Browse files
fix: Sort cities according to the normalization function used when searching (#79)
* Sort cities according to the normalization function used when searching A binary search is used to find the city specified with -i/--city. Therefore, the cities array must be sorted accordingly to the comparison function used in the binary search. The currently used comparison function normalizes city names. In particular, all names are lowercased, which impacts their lexicographical order. Because of this, the following example fails without this patch, even though "Rio de Janeiro" is in data/cities.csv. $ astroterm -mi "Rio de Janeiro" ERROR: Could not find city "Rio de Janeiro" To fix it, use the normalized city names when sorting them in filter_cities.py. The normalization should match the one used at runtime. Then regenerate data/cities.csv with: $ python scripts/filter_cities.py cities15000.txt data/cities.csv 200000 (cities15000.txt downloaded today from: https://download.geonames.org/export/dump/cities15000.zip) * test: Add test for PR #79 - normalized city name lookup --------- Co-authored-by: Dalton Luce <[email protected]>
1 parent a9f8ff2 commit be8e924

File tree

4 files changed

+382
-282
lines changed

4 files changed

+382
-282
lines changed

0 commit comments

Comments
 (0)