Skip to content

Commit

Permalink
[FIX] tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jcorreia11 committed Feb 12, 2025
1 parent cec216c commit aa55850
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/reactea/vizualization/plot_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,14 @@ def crop_image_with_transparency(img):

# Applying transparency
# (https://stackoverflow.com/questions/4379978/python-pil-how-to-make-area-transparent-in-png)
for transparent_zone in [(0, 0, l - epsilon, h), (0, 0, w, u - epsilon), (r + epsilon, 0, w, h),
(0, b + epsilon, w, h)]:
for transparent_zone in [
(0, 0, max(0, l - epsilon), h),
(0, 0, w, max(0, u - epsilon)),
(min(w, r + epsilon), 0, w, h),
(0, min(h, b + epsilon), w, h)
]:
draw = ImageDraw.Draw(mask)
print(transparent_zone)
draw.rectangle(transparent_zone, fill=0)
img.putalpha(mask)

Expand Down
4 changes: 2 additions & 2 deletions tests/unit_tests/visualization/test_plot_results.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os.path
from unittest import TestCase

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

def test_plot_results(self):
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')}
path = TEST_DIR / 'data' / 'output_example' / 'GA_rr_600esc_400gen_0.6sweet_0.4_caloric' / 'FINAL_TRANSFORMATIONS_04-29_16-51-54.csv'
mock_output_configs = {'transformations_path': path}
PlotResults(mock_output_configs, solution_index=0).plot_results(save_fig=False)
PlotResults(mock_output_configs, solution_index=4).plot_results(save_fig=False)
PlotResults(mock_output_configs, solution_index=6).plot_results(save_fig=False)

0 comments on commit aa55850

Please sign in to comment.