mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-27 10:49:05 +01:00
Address code review feedback: remove unused code and fix imports
Co-authored-by: kuhyx <147418882+kuhyx@users.noreply.github.com>
This commit is contained in:
parent
e739b1b227
commit
e1afa45b66
@ -4,6 +4,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -71,14 +72,10 @@ class TestCreateDistrictMap:
|
|||||||
fig = create_district_map(district)
|
fig = create_district_map(district)
|
||||||
assert fig is not None
|
assert fig is not None
|
||||||
# Clean up
|
# Clean up
|
||||||
import matplotlib.pyplot as plt
|
|
||||||
|
|
||||||
plt.close(fig)
|
plt.close(fig)
|
||||||
|
|
||||||
def test_creates_figure_for_all_districts(self) -> None:
|
def test_creates_figure_for_all_districts(self) -> None:
|
||||||
"""Test that we can create maps for all districts."""
|
"""Test that we can create maps for all districts."""
|
||||||
import matplotlib.pyplot as plt
|
|
||||||
|
|
||||||
for district in WARSAW_DISTRICTS:
|
for district in WARSAW_DISTRICTS:
|
||||||
fig = create_district_map(district)
|
fig = create_district_map(district)
|
||||||
assert fig is not None
|
assert fig is not None
|
||||||
|
|||||||
@ -22,8 +22,6 @@ Output:
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import base64
|
|
||||||
from io import BytesIO
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import sys
|
import sys
|
||||||
from typing import TYPE_CHECKING, NamedTuple
|
from typing import TYPE_CHECKING, NamedTuple
|
||||||
@ -136,27 +134,6 @@ def create_district_map(district: District, *, highlight_only: bool = True) -> F
|
|||||||
return fig
|
return fig
|
||||||
|
|
||||||
|
|
||||||
def generate_district_image_base64(district: District) -> str:
|
|
||||||
"""Generate a base64-encoded PNG image of the district map.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
district: The district to visualize.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
Base64-encoded PNG image string.
|
|
||||||
"""
|
|
||||||
fig = create_district_map(district)
|
|
||||||
|
|
||||||
# Save to bytes buffer
|
|
||||||
buf = BytesIO()
|
|
||||||
fig.savefig(buf, format="png", bbox_inches="tight", dpi=150)
|
|
||||||
plt.close(fig)
|
|
||||||
buf.seek(0)
|
|
||||||
|
|
||||||
# Encode to base64
|
|
||||||
return base64.b64encode(buf.read()).decode("utf-8")
|
|
||||||
|
|
||||||
|
|
||||||
def save_district_image(district: District, output_dir: Path) -> Path:
|
def save_district_image(district: District, output_dir: Path) -> Path:
|
||||||
"""Save a district map image to a file.
|
"""Save a district map image to a file.
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user