mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-07-04 16:23:04 +02: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
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
import pytest
|
||||
|
||||
try:
|
||||
@ -71,14 +72,10 @@ class TestCreateDistrictMap:
|
||||
fig = create_district_map(district)
|
||||
assert fig is not None
|
||||
# Clean up
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
plt.close(fig)
|
||||
|
||||
def test_creates_figure_for_all_districts(self) -> None:
|
||||
"""Test that we can create maps for all districts."""
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
for district in WARSAW_DISTRICTS:
|
||||
fig = create_district_map(district)
|
||||
assert fig is not None
|
||||
|
||||
@ -22,8 +22,6 @@ Output:
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import base64
|
||||
from io import BytesIO
|
||||
from pathlib import Path
|
||||
import sys
|
||||
from typing import TYPE_CHECKING, NamedTuple
|
||||
@ -136,27 +134,6 @@ def create_district_map(district: District, *, highlight_only: bool = True) -> F
|
||||
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:
|
||||
"""Save a district map image to a file.
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user