You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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]>
0 commit comments