Skip to content

Commit aa55850

Browse files
committed
[FIX] tests
1 parent cec216c commit aa55850

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/reactea/vizualization/plot_results.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,14 @@ def crop_image_with_transparency(img):
190190

191191
# Applying transparency
192192
# (https://stackoverflow.com/questions/4379978/python-pil-how-to-make-area-transparent-in-png)
193-
for transparent_zone in [(0, 0, l - epsilon, h), (0, 0, w, u - epsilon), (r + epsilon, 0, w, h),
194-
(0, b + epsilon, w, h)]:
193+
for transparent_zone in [
194+
(0, 0, max(0, l - epsilon), h),
195+
(0, 0, w, max(0, u - epsilon)),
196+
(min(w, r + epsilon), 0, w, h),
197+
(0, min(h, b + epsilon), w, h)
198+
]:
195199
draw = ImageDraw.Draw(mask)
200+
print(transparent_zone)
196201
draw.rectangle(transparent_zone, fill=0)
197202
img.putalpha(mask)
198203

tests/unit_tests/visualization/test_plot_results.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import os.path
21
from unittest import TestCase
32

43
from reactea.vizualization.plot_results import PlotResults
@@ -9,7 +8,8 @@
98
class TestPlotResults(TestCase):
109

1110
def test_plot_results(self):
12-
mock_output_configs = {'transformations_path': os.path.join(TEST_DIR, 'data/output_example/GA_rr_600esc_400gen_0.6sweet_0.4_caloric/FINAL_TRANSFORMATIONS_04-29_16-51-54.csv')}
11+
path = TEST_DIR / 'data' / 'output_example' / 'GA_rr_600esc_400gen_0.6sweet_0.4_caloric' / 'FINAL_TRANSFORMATIONS_04-29_16-51-54.csv'
12+
mock_output_configs = {'transformations_path': path}
1313
PlotResults(mock_output_configs, solution_index=0).plot_results(save_fig=False)
1414
PlotResults(mock_output_configs, solution_index=4).plot_results(save_fig=False)
1515
PlotResults(mock_output_configs, solution_index=6).plot_results(save_fig=False)

0 commit comments

Comments
 (0)