Skip to content

Commit

Permalink
refactor: fix ruff errors
Browse files Browse the repository at this point in the history
  • Loading branch information
pstorozenko committed Apr 29, 2024
1 parent 7d794b0 commit 165a605
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions respiratory_disease_tapyr/helpers/map_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def determine_circle_radius(num: float) -> int:
coefficients = [1.1, 0.8, 0.75]
final_coef = 0.2

for bin, coef in zip(bins, coefficients):
for bin, coef in zip(bins, coefficients, strict=True):
if num in bin:
return int(num * coef)
return int(num * final_coef)
Expand Down Expand Up @@ -46,7 +46,7 @@ def determine_circle_color(num: float) -> str:
]
final_color = "#08589E"

for bin, color in zip(bins, colors):
for bin, color in zip(bins, colors, strict=True):
if num in bin:
return color
return final_color
Expand Down Expand Up @@ -81,7 +81,7 @@ def add_polygons(
polygons_layer.clear_layers()
combined_data = merge(polygon_data, points_data, left_on="id", right_on="Code")
geo_data = dataframe_to_geojson(combined_data)
choro_data = dict(zip(combined_data["id"], combined_data["Death.Rate"]))
choro_data = dict(zip(combined_data["id"], combined_data["Death.Rate"], strict=True))
choropleth_layer = Choropleth(
geo_data=geo_data,
choro_data=choro_data,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
gdf = geopandas.read_file("data/countries.geojson")

# important not to use `to_dict()` methid
json = eval(gdf.set_index("id").to_json())
json = eval(gdf.set_index("id").to_json()) # noqa: S307

ids = list(map(lambda feature: feature["id"], json["features"]))
types = list(map(lambda feature: feature["geometry"]["type"], json["features"]))
coordinates = list(map(lambda feature: feature["geometry"]["coordinates"], json["features"]))

df = pd.DataFrame({"id": ids, "type": types, "coordinates": coordinates})
df = pd.DataFrame({"id": ids, "type": types, "coordinates": coordinates}) # noqa: PD901
df.to_csv("data/countries.csv", index=False)
2 changes: 1 addition & 1 deletion respiratory_disease_tapyr/view/plot/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from respiratory_disease_tapyr.helpers.plot_utils import create_figure
from respiratory_disease_tapyr.logic.data_loading import plot_data_oecd, plot_data_world_bank

country_choices = plot_data_oecd["Entity"].unique().tolist() + ["World"]
country_choices = [*plot_data_oecd["Entity"].unique().tolist(), "World"]


@module.server
Expand Down
2 changes: 1 addition & 1 deletion respiratory_disease_tapyr/view/plot/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
)
from respiratory_disease_tapyr.logic.data_loading import plot_data_oecd

country_choices = plot_data_oecd["Entity"].unique().tolist() + ["World"]
country_choices = [*plot_data_oecd["Entity"].unique().tolist(), "World"]


@module.ui
Expand Down

0 comments on commit 165a605

Please sign in to comment.