From 20bec6b9c9e7a1022384268bfb6d80db5159c11c Mon Sep 17 00:00:00 2001 From: Noah Fahlgren Date: Wed, 8 May 2024 17:01:41 -0500 Subject: [PATCH 01/30] Try making figure sizes smaller --- tests/test_annotate_points.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/test_annotate_points.py b/tests/test_annotate_points.py index c74769b..d7828b3 100644 --- a/tests/test_annotate_points.py +++ b/tests/test_annotate_points.py @@ -11,7 +11,7 @@ def test_points(test_data): img = cv2.imread(test_data.small_rgb_img) # initialize interactive tool - drawer_rgb = Points(img, figsize=(12, 6)) + drawer_rgb = Points(img, figsize=(5, 5)) # simulate mouse clicks # event 1, left click to add point @@ -56,7 +56,7 @@ def test_points_print_coords(test_data, tmpdir): img = cv2.imread(test_data.small_rgb_img) # initialize interactive tool - drawer_rgb = Points(img, figsize=(12, 6)) + drawer_rgb = Points(img, figsize=(5, 5)) # simulate mouse clicks # event 1, left click to add point @@ -82,7 +82,7 @@ def test_points_import_list(test_data): # Read in a test image img = cv2.imread(test_data.small_rgb_img) # initialize interactive tool - drawer_rgb = Points(img, figsize=(12, 6), label="default") + drawer_rgb = Points(img, figsize=(5, 5), label="default") totalpoints1 = [(158, 531), (361, 112), (500, 418), (269.25303806488864, 385.69839981447126), (231.21964288863632, 445.995245825603), (293.37177646934134, 448.778177179963), (240.49608073650273, 277.1640769944342), (279.4571196975417, 240.05832560296852), @@ -98,7 +98,7 @@ def test_points_import_list_warn(test_data): # Read in a test image img = cv2.imread(test_data.small_rgb_img) # initialize interactive tool - drawer_rgb = Points(img, figsize=(12, 6), label="default") + drawer_rgb = Points(img, figsize=(5, 5), label="default") totalpoints1 = [(158, 531), (361, 112), (500, 418), (445.50535717435065, 138.94515306122452)] drawer_rgb.import_list(coords=totalpoints1) @@ -108,7 +108,7 @@ def test_points_import_list_warn(test_data): def test_points_import_file(test_data): """Test for plantcv-annotate.""" img = cv2.imread(test_data.small_rgb_img) - counter = Points(img, figsize=(8, 6)) + counter = Points(img, figsize=(5, 5)) file = test_data.pollen_coords counter.import_file(file) @@ -121,7 +121,7 @@ def test_points_view(test_data): img = cv2.imread(test_data.small_rgb_img) # initialize interactive tool - drawer_rgb = Points(img, figsize=(12, 6)) + drawer_rgb = Points(img, figsize=(5, 5)) # simulate mouse clicks # event 1, left click to add point @@ -137,7 +137,7 @@ def test_points_view(test_data): drawer_rgb.onclick(e2) drawer_rgb.view(view_all=False) - assert str(drawer_rgb.fig) == "Figure(1200x600)" + assert str(drawer_rgb.fig) == "Figure(500x500)" def test_points_view_warn(test_data): @@ -146,7 +146,7 @@ def test_points_view_warn(test_data): img = cv2.imread(test_data.small_rgb_img) # initialize interactive tool, implied default label and "r" color - drawer_rgb = Points(img, figsize=(12, 6)) + drawer_rgb = Points(img, figsize=(5, 5)) # simulate mouse clicks, event 1=left click to add point e1 = matplotlib.backend_bases.MouseEvent(name="button_press_event", canvas=drawer_rgb.fig.canvas, @@ -156,4 +156,4 @@ def test_points_view_warn(test_data): drawer_rgb.onclick(e1) drawer_rgb.view(label="new", color='r') - assert str(drawer_rgb.fig) == "Figure(1200x600)" + assert str(drawer_rgb.fig) == "Figure(500x500)" From 1bff4557b5df2311d0ac4a35da2d8a74c89b9085 Mon Sep 17 00:00:00 2001 From: Noah Fahlgren Date: Fri, 10 May 2024 11:20:17 -0500 Subject: [PATCH 02/30] Increase setup delay --- .github/workflows/continuous-integration.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index f64c7e5..ef86ea4 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -50,6 +50,7 @@ jobs: - name: Tests uses: aganders3/headless-gui@v2 with: + linux-setup-delay: 2000 run: pytest --cov-report=xml --cov=./ - name: Upload coverage to Deepsource uses: deepsourcelabs/test-coverage-action@master From 6e027527f87de977c2e107b847568ae444d93988 Mon Sep 17 00:00:00 2001 From: Noah Fahlgren Date: Fri, 10 May 2024 11:24:05 -0500 Subject: [PATCH 03/30] Increase delay to 10s --- .github/workflows/continuous-integration.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index ef86ea4..e54e9f0 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -50,7 +50,7 @@ jobs: - name: Tests uses: aganders3/headless-gui@v2 with: - linux-setup-delay: 2000 + linux-setup-delay: 10000 run: pytest --cov-report=xml --cov=./ - name: Upload coverage to Deepsource uses: deepsourcelabs/test-coverage-action@master From 8788098012e28510d65301c5094fd76dceee91a0 Mon Sep 17 00:00:00 2001 From: Noah Fahlgren Date: Fri, 10 May 2024 11:30:35 -0500 Subject: [PATCH 04/30] Change screen resolution --- .github/workflows/continuous-integration.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index e54e9f0..206ba25 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -51,6 +51,7 @@ jobs: uses: aganders3/headless-gui@v2 with: linux-setup-delay: 10000 + xvfb-screen-size: 1280x720x24 run: pytest --cov-report=xml --cov=./ - name: Upload coverage to Deepsource uses: deepsourcelabs/test-coverage-action@master From f05f741e231e9d74f91f56e98b61241638469e2b Mon Sep 17 00:00:00 2001 From: Malia Gehan Date: Tue, 14 May 2024 19:07:40 -0500 Subject: [PATCH 05/30] Update continuous-integration.yml remove xvfb --- .github/workflows/continuous-integration.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 206ba25..b18a740 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -31,7 +31,7 @@ jobs: - name: Install dependencies run: | sudo apt-get update - sudo apt-get install --no-install-recommends libyaml-dev libegl1-mesa libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-shape0 libxcb-cursor0 xserver-xephyr xvfb + sudo apt-get install --no-install-recommends libyaml-dev libegl1-mesa libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-shape0 libxcb-cursor0 xserver-xephyr python -m pip install --upgrade pip pip install flake8 pytest pytest-cov pytest-qt pytest-xvfb ipython anyio - name: Lint with flake8 From df608d0449d59dffb4355145dc1761ecce310e38 Mon Sep 17 00:00:00 2001 From: Malia Gehan Date: Tue, 14 May 2024 20:01:07 -0500 Subject: [PATCH 06/30] Update continuous-integration.yml https://pytest-qt.readthedocs.io/en/latest/troubleshooting.html#xvfb-assertionerror-timeouterror-when-using-waituntil-waitexposed-and-ui-events --- .github/workflows/continuous-integration.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index b18a740..7048801 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -34,6 +34,7 @@ jobs: sudo apt-get install --no-install-recommends libyaml-dev libegl1-mesa libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-shape0 libxcb-cursor0 xserver-xephyr python -m pip install --upgrade pip pip install flake8 pytest pytest-cov pytest-qt pytest-xvfb ipython anyio + /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 1920x1200x24 -ac +extension GLX - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names @@ -47,6 +48,7 @@ jobs: pip install . pip uninstall -y opencv-python pip install opencv-python-headless + /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 1920x1200x24 -ac +extension GLX - name: Tests uses: aganders3/headless-gui@v2 with: From d162ec9c06781c18ff6fa8b16b197a0ee8aa1c9e Mon Sep 17 00:00:00 2001 From: Malia Gehan Date: Tue, 14 May 2024 20:04:48 -0500 Subject: [PATCH 07/30] Update continuous-integration.yml --- .github/workflows/continuous-integration.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 7048801..b18a740 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -34,7 +34,6 @@ jobs: sudo apt-get install --no-install-recommends libyaml-dev libegl1-mesa libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-shape0 libxcb-cursor0 xserver-xephyr python -m pip install --upgrade pip pip install flake8 pytest pytest-cov pytest-qt pytest-xvfb ipython anyio - /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 1920x1200x24 -ac +extension GLX - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names @@ -48,7 +47,6 @@ jobs: pip install . pip uninstall -y opencv-python pip install opencv-python-headless - /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 1920x1200x24 -ac +extension GLX - name: Tests uses: aganders3/headless-gui@v2 with: From 6340f0d9c96781d846e42c377211ba41a9524850 Mon Sep 17 00:00:00 2001 From: Malia Gehan Date: Tue, 14 May 2024 20:29:20 -0500 Subject: [PATCH 08/30] Update continuous-integration.yml --- .github/workflows/continuous-integration.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index b18a740..2874b9a 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -30,7 +30,6 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | - sudo apt-get update sudo apt-get install --no-install-recommends libyaml-dev libegl1-mesa libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-shape0 libxcb-cursor0 xserver-xephyr python -m pip install --upgrade pip pip install flake8 pytest pytest-cov pytest-qt pytest-xvfb ipython anyio From 74c778ccf5b598f76cb33c2b0dbba55ed8658801 Mon Sep 17 00:00:00 2001 From: Malia Gehan Date: Tue, 14 May 2024 21:10:10 -0500 Subject: [PATCH 09/30] Update continuous-integration.yml --- .github/workflows/continuous-integration.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 2874b9a..c2b77ca 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -47,7 +47,7 @@ jobs: pip uninstall -y opencv-python pip install opencv-python-headless - name: Tests - uses: aganders3/headless-gui@v2 + uses: aganders3/headless-gui@v2.2 with: linux-setup-delay: 10000 xvfb-screen-size: 1280x720x24 From d62b2130019c34011735ced9c27a71fa3b34ed92 Mon Sep 17 00:00:00 2001 From: Malia Gehan Date: Wed, 15 May 2024 09:43:30 -0500 Subject: [PATCH 10/30] Update continuous-integration.yml saw something about specifically using python 3.10.12 --- .github/workflows/continuous-integration.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index c2b77ca..97c7096 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -16,7 +16,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ['3.9', '3.10', '3.11'] + python-version: ['3.9', '3.10.12', '3.11'] os: [ubuntu-latest] env: OS: ${{ matrix.os }} From d5afb93e3f451c5383c28aa5c261aa1cd7c9d1ae Mon Sep 17 00:00:00 2001 From: Malia Gehan Date: Wed, 15 May 2024 09:54:52 -0500 Subject: [PATCH 11/30] Update continuous-integration.yml seeing if the problem is consistently with 3.10 --- .github/workflows/continuous-integration.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 97c7096..9f1c81f 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -16,7 +16,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ['3.9', '3.10.12', '3.11'] + python-version: ['3.9', '3.11'] os: [ubuntu-latest] env: OS: ${{ matrix.os }} From 93640aa2e6331c1c99b9fd62e3cd1d8a61e03add Mon Sep 17 00:00:00 2001 From: Malia Gehan Date: Wed, 15 May 2024 09:58:25 -0500 Subject: [PATCH 12/30] Update continuous-integration.yml 3.10 isn't the problem. getting same error on 3.11. --- .github/workflows/continuous-integration.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 9f1c81f..288d098 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -16,7 +16,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ['3.9', '3.11'] + python-version: ['3.9','3.10' '3.11'] os: [ubuntu-latest] env: OS: ${{ matrix.os }} From 4dc2d7835022cfa4b39ab1dd8b64212ff94b1697 Mon Sep 17 00:00:00 2001 From: Malia Gehan Date: Wed, 15 May 2024 10:56:14 -0500 Subject: [PATCH 13/30] Update continuous-integration.yml --- .github/workflows/continuous-integration.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 288d098..42ef749 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -51,7 +51,7 @@ jobs: with: linux-setup-delay: 10000 xvfb-screen-size: 1280x720x24 - run: pytest --cov-report=xml --cov=./ + run: pytest -vv --cov-report=xml --cov=./ - name: Upload coverage to Deepsource uses: deepsourcelabs/test-coverage-action@master with: From 0cf7668ed004f56348f7a437316da0da6a156664 Mon Sep 17 00:00:00 2001 From: Malia Gehan Date: Wed, 15 May 2024 11:02:43 -0500 Subject: [PATCH 14/30] Update continuous-integration.yml omg I broke github actions.... --- .github/workflows/continuous-integration.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 42ef749..1f23f09 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -51,7 +51,7 @@ jobs: with: linux-setup-delay: 10000 xvfb-screen-size: 1280x720x24 - run: pytest -vv --cov-report=xml --cov=./ + run: pytest -v --cov-report=xml --cov=./ - name: Upload coverage to Deepsource uses: deepsourcelabs/test-coverage-action@master with: From f9909129e5c639168b9172bea0232ae68e365c35 Mon Sep 17 00:00:00 2001 From: Malia Gehan Date: Wed, 15 May 2024 11:06:32 -0500 Subject: [PATCH 15/30] Update continuous-integration.yml missing comma --- .github/workflows/continuous-integration.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 1f23f09..ed57f0e 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -16,7 +16,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ['3.9','3.10' '3.11'] + python-version: ['3.9','3.10', '3.11'] os: [ubuntu-latest] env: OS: ${{ matrix.os }} @@ -51,7 +51,7 @@ jobs: with: linux-setup-delay: 10000 xvfb-screen-size: 1280x720x24 - run: pytest -v --cov-report=xml --cov=./ + run: pytest -vv --cov-report=xml --cov=./ - name: Upload coverage to Deepsource uses: deepsourcelabs/test-coverage-action@master with: From 3afe91b9079725da9271ccde98e9b9d1d37247d6 Mon Sep 17 00:00:00 2001 From: Malia Gehan Date: Wed, 15 May 2024 11:15:10 -0500 Subject: [PATCH 16/30] test testing to see if there is a specific test breaking github actions. --- tests/test_annotate_get_centroids.py | 12 -- tests/test_annotate_points.py | 159 --------------------------- tests/test_napari_classes.py | 18 --- tests/test_napari_join_labels.py | 79 ------------- tests/test_napari_label_classes.py | 15 --- tests/test_napari_open.py | 40 ------- 6 files changed, 323 deletions(-) delete mode 100644 tests/test_annotate_get_centroids.py delete mode 100644 tests/test_annotate_points.py delete mode 100644 tests/test_napari_classes.py delete mode 100644 tests/test_napari_join_labels.py delete mode 100644 tests/test_napari_label_classes.py delete mode 100644 tests/test_napari_open.py diff --git a/tests/test_annotate_get_centroids.py b/tests/test_annotate_get_centroids.py deleted file mode 100644 index 54c4db3..0000000 --- a/tests/test_annotate_get_centroids.py +++ /dev/null @@ -1,12 +0,0 @@ -import cv2 -from plantcv.annotate.get_centroids import get_centroids - - -def test_get_centroids(test_data): - """Test for PlantCV.""" - # Read in test data - mask = cv2.imread(test_data.small_bin_img, -1) - - coor = get_centroids(bin_img=mask) - - assert coor == [(166, 214)] diff --git a/tests/test_annotate_points.py b/tests/test_annotate_points.py deleted file mode 100644 index d7828b3..0000000 --- a/tests/test_annotate_points.py +++ /dev/null @@ -1,159 +0,0 @@ -"""Tests for annotate.Points.""" -import os -import cv2 -import matplotlib -from plantcv.annotate.classes import Points - - -def test_points(test_data): - """Test for plantcv-annotate.""" - # Read in a test grayscale image - img = cv2.imread(test_data.small_rgb_img) - - # initialize interactive tool - drawer_rgb = Points(img, figsize=(5, 5)) - - # simulate mouse clicks - # event 1, left click to add point - e1 = matplotlib.backend_bases.MouseEvent(name="button_press_event", canvas=drawer_rgb.fig.canvas, - x=0, y=0, button=1) - point1 = (200, 200) - e1.xdata, e1.ydata = point1 - drawer_rgb.onclick(e1) - - # event 2, left click to add point - e2 = matplotlib.backend_bases.MouseEvent(name="button_press_event", canvas=drawer_rgb.fig.canvas, - x=0, y=0, button=1) - e2.xdata, e2.ydata = (300, 200) - drawer_rgb.onclick(e2) - - # event 3, left click to add point - e3 = matplotlib.backend_bases.MouseEvent(name="button_press_event", canvas=drawer_rgb.fig.canvas, - x=0, y=0, button=1) - e3.xdata, e3.ydata = (50, 50) - drawer_rgb.onclick(e3) - - # event 4, right click to remove point with exact coordinates - e4 = matplotlib.backend_bases.MouseEvent(name="button_press_event", canvas=drawer_rgb.fig.canvas, - x=0, y=0, button=3) - e4.xdata, e4.ydata = (50, 50) - drawer_rgb.onclick(e4) - - # event 5, right click to remove point with coordinates close but not equal - e5 = matplotlib.backend_bases.MouseEvent(name="button_press_event", canvas=drawer_rgb.fig.canvas, - x=0, y=0, button=3) - e5.xdata, e5.ydata = (301, 200) - drawer_rgb.onclick(e5) - - assert drawer_rgb.coords["default"][0] == point1 - - -def test_points_print_coords(test_data, tmpdir): - """Test for plantcv-annotate.""" - cache_dir = tmpdir.mkdir("cache") - filename = os.path.join(cache_dir, 'plantcv_print_coords.txt') - # Read in a test image - img = cv2.imread(test_data.small_rgb_img) - - # initialize interactive tool - drawer_rgb = Points(img, figsize=(5, 5)) - - # simulate mouse clicks - # event 1, left click to add point - e1 = matplotlib.backend_bases.MouseEvent(name="button_press_event", canvas=drawer_rgb.fig.canvas, - x=0, y=0, button=1) - point1 = (200, 200) - e1.xdata, e1.ydata = point1 - drawer_rgb.onclick(e1) - - # event 2, left click to add point - e2 = matplotlib.backend_bases.MouseEvent(name="button_press_event", canvas=drawer_rgb.fig.canvas, - x=0, y=0, button=1) - e2.xdata, e2.ydata = (300, 200) - drawer_rgb.onclick(e2) - - # Save collected coords out - drawer_rgb.print_coords(filename) - assert os.path.exists(filename) - - -def test_points_import_list(test_data): - """Test for plantcv-annotate.""" - # Read in a test image - img = cv2.imread(test_data.small_rgb_img) - # initialize interactive tool - drawer_rgb = Points(img, figsize=(5, 5), label="default") - totalpoints1 = [(158, 531), (361, 112), (500, 418), (269.25303806488864, 385.69839981447126), - (231.21964288863632, 445.995245825603), (293.37177646934134, 448.778177179963), - (240.49608073650273, 277.1640769944342), (279.4571196975417, 240.05832560296852), - (77.23077461405376, 165.84682282003712), (420, 364), (509.5127783246289, 353.2308673469388), - (527.1380102355752, 275.3087894248609), (445.50535717435065, 138.94515306122452)] - drawer_rgb.import_list(coords=totalpoints1, label="imported") - - assert len(drawer_rgb.coords["imported"]) == 13 - - -def test_points_import_list_warn(test_data): - """Test for plantcv-annotate.""" - # Read in a test image - img = cv2.imread(test_data.small_rgb_img) - # initialize interactive tool - drawer_rgb = Points(img, figsize=(5, 5), label="default") - totalpoints1 = [(158, 531), (361, 112), (500, 418), (445.50535717435065, 138.94515306122452)] - drawer_rgb.import_list(coords=totalpoints1) - - assert len(drawer_rgb.coords["default"]) == 0 - - -def test_points_import_file(test_data): - """Test for plantcv-annotate.""" - img = cv2.imread(test_data.small_rgb_img) - counter = Points(img, figsize=(5, 5)) - file = test_data.pollen_coords - counter.import_file(file) - - assert counter.count['total'] == 70 - - -def test_points_view(test_data): - """Test for plantcv-annotate.""" - # Read in a test grayscale image - img = cv2.imread(test_data.small_rgb_img) - - # initialize interactive tool - drawer_rgb = Points(img, figsize=(5, 5)) - - # simulate mouse clicks - # event 1, left click to add point - e1 = matplotlib.backend_bases.MouseEvent(name="button_press_event", canvas=drawer_rgb.fig.canvas, - x=0, y=0, button=1) - point1 = (200, 200) - e1.xdata, e1.ydata = point1 - drawer_rgb.onclick(e1) - drawer_rgb.view(label="new", view_all=True) - e2 = matplotlib.backend_bases.MouseEvent(name="button_press_event", canvas=drawer_rgb.fig.canvas, - x=0, y=0, button=1) - e2.xdata, e2.ydata = (300, 200) - drawer_rgb.onclick(e2) - drawer_rgb.view(view_all=False) - - assert str(drawer_rgb.fig) == "Figure(500x500)" - - -def test_points_view_warn(test_data): - """Test for plantcv-annotate.""" - # Read in a test grayscale image - img = cv2.imread(test_data.small_rgb_img) - - # initialize interactive tool, implied default label and "r" color - drawer_rgb = Points(img, figsize=(5, 5)) - - # simulate mouse clicks, event 1=left click to add point - e1 = matplotlib.backend_bases.MouseEvent(name="button_press_event", canvas=drawer_rgb.fig.canvas, - x=0, y=0, button=1) - point1 = (200, 200) - e1.xdata, e1.ydata = point1 - drawer_rgb.onclick(e1) - drawer_rgb.view(label="new", color='r') - - assert str(drawer_rgb.fig) == "Figure(500x500)" diff --git a/tests/test_napari_classes.py b/tests/test_napari_classes.py deleted file mode 100644 index f4050a9..0000000 --- a/tests/test_napari_classes.py +++ /dev/null @@ -1,18 +0,0 @@ -import numpy as np -from plantcv.annotate import napari_classes - - -def test_napari_classes(make_napari_viewer): - """Test for PlantCV.Annotate""" - # Read in test data - viewer = make_napari_viewer(show=False) - img = np.zeros((100, 100)) - coor = [(25, 25), (50, 50)] - viewer.add_image(img) - viewer.add_points(np.array(coor), symbol="o", name="total", - face_color="red", size=30) - viewer.add_points(np.array(coor), symbol="o", name="test", - face_color="red", size=30) - keys = napari_classes(viewer) - - assert keys == ['total', 'test'] diff --git a/tests/test_napari_join_labels.py b/tests/test_napari_join_labels.py deleted file mode 100644 index 269465d..0000000 --- a/tests/test_napari_join_labels.py +++ /dev/null @@ -1,79 +0,0 @@ -import numpy as np -from plantcv.annotate.napari_open import napari_open -from plantcv.annotate.napari_label_classes import napari_label_classes -from plantcv.plantcv import readimage -from plantcv.annotate.napari_join_labels import napari_join_labels -from plantcv.plantcv import params - - -def test_napari_join_labels(test_data): - """Test for PlantCV.Annotate""" - # Read in test data - img, _, _ = readimage(test_data.kmeans_seed_gray_img) - viewer = napari_label_classes(img, ["seed"], show=False) - labeled, _ = napari_join_labels(img, viewer) - - assert np.shape(labeled) == (576, 537) - - -def test_napari_join_allclass(test_data): - """Test for PlantCV.Annotate""" - # Read in test data - img, _, _ = readimage(test_data.kmeans_seed_gray_img) - viewer = napari_open(img, show=False) - background = [(54, 143), (77, 246)] - viewer.add_points(np.array(background), symbol="o", name='background', - face_color="red", size=1) - wing = [(275, 54)] - viewer.add_points(np.array(wing), symbol="o", name='wing', - face_color="red", size=1) - seed = [(280, 218)] - viewer.add_points(np.array(seed), symbol="o", name='seed', - face_color="red", size=1) - - labeled, _ = napari_join_labels(img, viewer) - - assert np.shape(labeled) == (576, 537) - - -def test_napari_join_warn(test_data): - """Test for PlantCV.Annotate""" - # Read in test data - img, _, _ = readimage(test_data.kmeans_seed_gray_img) - viewer = napari_open(img, show=False) - background = [(54, 143), (77, 246)] - viewer.add_points(np.array(background), symbol="o", name='background', - face_color="red", size=1) - wing = [(275, 54)] - viewer.add_points(np.array(wing), symbol="o", name='wing', - face_color="red", size=1) - seed = [(275, 54)] - viewer.add_points(np.array(seed), symbol="o", name='seed', - face_color="red", size=1) - - labeled, _ = napari_join_labels(img, viewer) - - assert np.shape(labeled) == (576, 537) - - -def test_napari_join_print(test_data, tmpdir): - """Test for PlantCV.Annotate""" - params.debug = 'print' - cache_dir = tmpdir.mkdir("cache") - params.debug_outdir = cache_dir - # Read in test data - img, _, _ = readimage(test_data.kmeans_seed_gray_img) - viewer = napari_open(img, show=False) - background = [(54, 143), (77, 246)] - viewer.add_points(np.array(background), symbol="o", name='background', - face_color="red", size=1) - wing = [(280, 218)] - viewer.add_points(np.array(wing), symbol="o", name='wing', - face_color="red", size=1) - seed = [(275, 54)] - viewer.add_points(np.array(seed), symbol="o", name='seed', - face_color="red", size=1) - - labeled, _ = napari_join_labels(img, viewer) - - assert np.shape(labeled) == (576, 537) diff --git a/tests/test_napari_label_classes.py b/tests/test_napari_label_classes.py deleted file mode 100644 index ca49b8f..0000000 --- a/tests/test_napari_label_classes.py +++ /dev/null @@ -1,15 +0,0 @@ -import numpy as np -from plantcv.annotate import napari_label_classes -from plantcv.plantcv import readimage - - -def test_napari_label_classes_gray(test_data): - """Test for PlantCV.Annotate""" - # Read in test data - img, _, _ = readimage(test_data.kmeans_seed_gray_img) - viewer = napari_label_classes(img, ['seed'], show=False) - coor = [(25, 25)] - viewer.add_points(np.array(coor), symbol="o", name='background', - face_color="red", size=1) - - assert len(viewer.layers['background'].data) == 1 diff --git a/tests/test_napari_open.py b/tests/test_napari_open.py deleted file mode 100644 index cfb9d25..0000000 --- a/tests/test_napari_open.py +++ /dev/null @@ -1,40 +0,0 @@ -import numpy as np -from plantcv.annotate import napari_open -from plantcv.plantcv import readimage - - -def test_napari_open_rgb(test_data): - """Test for PlantCV.Annotate""" - # Read in test data - img, _, _ = readimage(test_data.small_rgb_img) - viewer = napari_open(img, show=False) - coor = [(25, 25), (50, 50)] - viewer.add_points(np.array(coor), symbol="o", name="total", - face_color="red", size=1) - - assert len(viewer.layers['total'].data) == 2 - - -def test_napari_open_gray(test_data): - """Test for PlantCV.Annotate""" - # Read in test data - img, _, _ = readimage(test_data.kmeans_seed_gray_img) - viewer = napari_open(img, show=False) - coor = [(25, 25), (50, 50)] - viewer.add_points(np.array(coor), symbol="o", name="total", - face_color="red", size=1) - - assert len(viewer.layers['total'].data) == 2 - - -def test_napari_open_envi(test_data): - """Test for PlantCV.Annotate""" - # Read in test data - img = readimage(test_data.envi_sample_data, mode='envi') - img = img.array_data - viewer = napari_open(img, show=False) - coor = [(25, 25), (50, 50)] - viewer.add_points(np.array(coor), symbol="o", name="total", - face_color="red", size=1) - - assert len(viewer.layers['total'].data) == 2 From cf8b3a431e3cb9611ebc5663c532f7418921f2ef Mon Sep 17 00:00:00 2001 From: Malia Gehan Date: Wed, 15 May 2024 11:20:36 -0500 Subject: [PATCH 17/30] Create test_annotate_points.py add points tests --- tests/test_annotate_points.py | 159 ++++++++++++++++++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100644 tests/test_annotate_points.py diff --git a/tests/test_annotate_points.py b/tests/test_annotate_points.py new file mode 100644 index 0000000..d7828b3 --- /dev/null +++ b/tests/test_annotate_points.py @@ -0,0 +1,159 @@ +"""Tests for annotate.Points.""" +import os +import cv2 +import matplotlib +from plantcv.annotate.classes import Points + + +def test_points(test_data): + """Test for plantcv-annotate.""" + # Read in a test grayscale image + img = cv2.imread(test_data.small_rgb_img) + + # initialize interactive tool + drawer_rgb = Points(img, figsize=(5, 5)) + + # simulate mouse clicks + # event 1, left click to add point + e1 = matplotlib.backend_bases.MouseEvent(name="button_press_event", canvas=drawer_rgb.fig.canvas, + x=0, y=0, button=1) + point1 = (200, 200) + e1.xdata, e1.ydata = point1 + drawer_rgb.onclick(e1) + + # event 2, left click to add point + e2 = matplotlib.backend_bases.MouseEvent(name="button_press_event", canvas=drawer_rgb.fig.canvas, + x=0, y=0, button=1) + e2.xdata, e2.ydata = (300, 200) + drawer_rgb.onclick(e2) + + # event 3, left click to add point + e3 = matplotlib.backend_bases.MouseEvent(name="button_press_event", canvas=drawer_rgb.fig.canvas, + x=0, y=0, button=1) + e3.xdata, e3.ydata = (50, 50) + drawer_rgb.onclick(e3) + + # event 4, right click to remove point with exact coordinates + e4 = matplotlib.backend_bases.MouseEvent(name="button_press_event", canvas=drawer_rgb.fig.canvas, + x=0, y=0, button=3) + e4.xdata, e4.ydata = (50, 50) + drawer_rgb.onclick(e4) + + # event 5, right click to remove point with coordinates close but not equal + e5 = matplotlib.backend_bases.MouseEvent(name="button_press_event", canvas=drawer_rgb.fig.canvas, + x=0, y=0, button=3) + e5.xdata, e5.ydata = (301, 200) + drawer_rgb.onclick(e5) + + assert drawer_rgb.coords["default"][0] == point1 + + +def test_points_print_coords(test_data, tmpdir): + """Test for plantcv-annotate.""" + cache_dir = tmpdir.mkdir("cache") + filename = os.path.join(cache_dir, 'plantcv_print_coords.txt') + # Read in a test image + img = cv2.imread(test_data.small_rgb_img) + + # initialize interactive tool + drawer_rgb = Points(img, figsize=(5, 5)) + + # simulate mouse clicks + # event 1, left click to add point + e1 = matplotlib.backend_bases.MouseEvent(name="button_press_event", canvas=drawer_rgb.fig.canvas, + x=0, y=0, button=1) + point1 = (200, 200) + e1.xdata, e1.ydata = point1 + drawer_rgb.onclick(e1) + + # event 2, left click to add point + e2 = matplotlib.backend_bases.MouseEvent(name="button_press_event", canvas=drawer_rgb.fig.canvas, + x=0, y=0, button=1) + e2.xdata, e2.ydata = (300, 200) + drawer_rgb.onclick(e2) + + # Save collected coords out + drawer_rgb.print_coords(filename) + assert os.path.exists(filename) + + +def test_points_import_list(test_data): + """Test for plantcv-annotate.""" + # Read in a test image + img = cv2.imread(test_data.small_rgb_img) + # initialize interactive tool + drawer_rgb = Points(img, figsize=(5, 5), label="default") + totalpoints1 = [(158, 531), (361, 112), (500, 418), (269.25303806488864, 385.69839981447126), + (231.21964288863632, 445.995245825603), (293.37177646934134, 448.778177179963), + (240.49608073650273, 277.1640769944342), (279.4571196975417, 240.05832560296852), + (77.23077461405376, 165.84682282003712), (420, 364), (509.5127783246289, 353.2308673469388), + (527.1380102355752, 275.3087894248609), (445.50535717435065, 138.94515306122452)] + drawer_rgb.import_list(coords=totalpoints1, label="imported") + + assert len(drawer_rgb.coords["imported"]) == 13 + + +def test_points_import_list_warn(test_data): + """Test for plantcv-annotate.""" + # Read in a test image + img = cv2.imread(test_data.small_rgb_img) + # initialize interactive tool + drawer_rgb = Points(img, figsize=(5, 5), label="default") + totalpoints1 = [(158, 531), (361, 112), (500, 418), (445.50535717435065, 138.94515306122452)] + drawer_rgb.import_list(coords=totalpoints1) + + assert len(drawer_rgb.coords["default"]) == 0 + + +def test_points_import_file(test_data): + """Test for plantcv-annotate.""" + img = cv2.imread(test_data.small_rgb_img) + counter = Points(img, figsize=(5, 5)) + file = test_data.pollen_coords + counter.import_file(file) + + assert counter.count['total'] == 70 + + +def test_points_view(test_data): + """Test for plantcv-annotate.""" + # Read in a test grayscale image + img = cv2.imread(test_data.small_rgb_img) + + # initialize interactive tool + drawer_rgb = Points(img, figsize=(5, 5)) + + # simulate mouse clicks + # event 1, left click to add point + e1 = matplotlib.backend_bases.MouseEvent(name="button_press_event", canvas=drawer_rgb.fig.canvas, + x=0, y=0, button=1) + point1 = (200, 200) + e1.xdata, e1.ydata = point1 + drawer_rgb.onclick(e1) + drawer_rgb.view(label="new", view_all=True) + e2 = matplotlib.backend_bases.MouseEvent(name="button_press_event", canvas=drawer_rgb.fig.canvas, + x=0, y=0, button=1) + e2.xdata, e2.ydata = (300, 200) + drawer_rgb.onclick(e2) + drawer_rgb.view(view_all=False) + + assert str(drawer_rgb.fig) == "Figure(500x500)" + + +def test_points_view_warn(test_data): + """Test for plantcv-annotate.""" + # Read in a test grayscale image + img = cv2.imread(test_data.small_rgb_img) + + # initialize interactive tool, implied default label and "r" color + drawer_rgb = Points(img, figsize=(5, 5)) + + # simulate mouse clicks, event 1=left click to add point + e1 = matplotlib.backend_bases.MouseEvent(name="button_press_event", canvas=drawer_rgb.fig.canvas, + x=0, y=0, button=1) + point1 = (200, 200) + e1.xdata, e1.ydata = point1 + drawer_rgb.onclick(e1) + drawer_rgb.view(label="new", color='r') + + assert str(drawer_rgb.fig) == "Figure(500x500)" From b1e1812a07e9e7210dd4b37b641e3f26c5731411 Mon Sep 17 00:00:00 2001 From: Malia Gehan Date: Wed, 15 May 2024 11:23:48 -0500 Subject: [PATCH 18/30] Create test_annotate_get_centroids.py add centroid tests --- tests/test_annotate_get_centroids.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 tests/test_annotate_get_centroids.py diff --git a/tests/test_annotate_get_centroids.py b/tests/test_annotate_get_centroids.py new file mode 100644 index 0000000..54c4db3 --- /dev/null +++ b/tests/test_annotate_get_centroids.py @@ -0,0 +1,12 @@ +import cv2 +from plantcv.annotate.get_centroids import get_centroids + + +def test_get_centroids(test_data): + """Test for PlantCV.""" + # Read in test data + mask = cv2.imread(test_data.small_bin_img, -1) + + coor = get_centroids(bin_img=mask) + + assert coor == [(166, 214)] From ecfbc68ac768937253f14b7a08f95cd06ce35f85 Mon Sep 17 00:00:00 2001 From: Malia Gehan Date: Wed, 15 May 2024 11:27:26 -0500 Subject: [PATCH 19/30] Create test_napari_open.py napari open --- tests/test_napari_open.py | 40 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 tests/test_napari_open.py diff --git a/tests/test_napari_open.py b/tests/test_napari_open.py new file mode 100644 index 0000000..cfb9d25 --- /dev/null +++ b/tests/test_napari_open.py @@ -0,0 +1,40 @@ +import numpy as np +from plantcv.annotate import napari_open +from plantcv.plantcv import readimage + + +def test_napari_open_rgb(test_data): + """Test for PlantCV.Annotate""" + # Read in test data + img, _, _ = readimage(test_data.small_rgb_img) + viewer = napari_open(img, show=False) + coor = [(25, 25), (50, 50)] + viewer.add_points(np.array(coor), symbol="o", name="total", + face_color="red", size=1) + + assert len(viewer.layers['total'].data) == 2 + + +def test_napari_open_gray(test_data): + """Test for PlantCV.Annotate""" + # Read in test data + img, _, _ = readimage(test_data.kmeans_seed_gray_img) + viewer = napari_open(img, show=False) + coor = [(25, 25), (50, 50)] + viewer.add_points(np.array(coor), symbol="o", name="total", + face_color="red", size=1) + + assert len(viewer.layers['total'].data) == 2 + + +def test_napari_open_envi(test_data): + """Test for PlantCV.Annotate""" + # Read in test data + img = readimage(test_data.envi_sample_data, mode='envi') + img = img.array_data + viewer = napari_open(img, show=False) + coor = [(25, 25), (50, 50)] + viewer.add_points(np.array(coor), symbol="o", name="total", + face_color="red", size=1) + + assert len(viewer.layers['total'].data) == 2 From cb848b5910d7aa6c25352251116d6440119478b4 Mon Sep 17 00:00:00 2001 From: Malia Gehan Date: Wed, 15 May 2024 11:35:59 -0500 Subject: [PATCH 20/30] Create test_napari_classes.py napari classes --- tests/test_napari_classes.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 tests/test_napari_classes.py diff --git a/tests/test_napari_classes.py b/tests/test_napari_classes.py new file mode 100644 index 0000000..f4050a9 --- /dev/null +++ b/tests/test_napari_classes.py @@ -0,0 +1,18 @@ +import numpy as np +from plantcv.annotate import napari_classes + + +def test_napari_classes(make_napari_viewer): + """Test for PlantCV.Annotate""" + # Read in test data + viewer = make_napari_viewer(show=False) + img = np.zeros((100, 100)) + coor = [(25, 25), (50, 50)] + viewer.add_image(img) + viewer.add_points(np.array(coor), symbol="o", name="total", + face_color="red", size=30) + viewer.add_points(np.array(coor), symbol="o", name="test", + face_color="red", size=30) + keys = napari_classes(viewer) + + assert keys == ['total', 'test'] From 9a0fa6e064e70c280281cc9d3643501c3e1ebcdd Mon Sep 17 00:00:00 2001 From: Malia Gehan Date: Wed, 15 May 2024 11:42:28 -0500 Subject: [PATCH 21/30] Create test_napari_label_classes.py napari label classes --- tests/test_napari_label_classes.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 tests/test_napari_label_classes.py diff --git a/tests/test_napari_label_classes.py b/tests/test_napari_label_classes.py new file mode 100644 index 0000000..ca49b8f --- /dev/null +++ b/tests/test_napari_label_classes.py @@ -0,0 +1,15 @@ +import numpy as np +from plantcv.annotate import napari_label_classes +from plantcv.plantcv import readimage + + +def test_napari_label_classes_gray(test_data): + """Test for PlantCV.Annotate""" + # Read in test data + img, _, _ = readimage(test_data.kmeans_seed_gray_img) + viewer = napari_label_classes(img, ['seed'], show=False) + coor = [(25, 25)] + viewer.add_points(np.array(coor), symbol="o", name='background', + face_color="red", size=1) + + assert len(viewer.layers['background'].data) == 1 From c23e57b9ea057e00a096aa94d6e360bb2cf1b79e Mon Sep 17 00:00:00 2001 From: Malia Gehan Date: Wed, 15 May 2024 11:49:18 -0500 Subject: [PATCH 22/30] viwer close testing viewer close on napari classes --- tests/test_napari_classes.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_napari_classes.py b/tests/test_napari_classes.py index f4050a9..5e21ddf 100644 --- a/tests/test_napari_classes.py +++ b/tests/test_napari_classes.py @@ -16,3 +16,5 @@ def test_napari_classes(make_napari_viewer): keys = napari_classes(viewer) assert keys == ['total', 'test'] + + viewer.close() From c6035cb5314538ce134affd60b8980708e6d154a Mon Sep 17 00:00:00 2001 From: Malia Gehan Date: Wed, 15 May 2024 11:53:02 -0500 Subject: [PATCH 23/30] Update test_napari_label_classes.py testing viewer close --- tests/test_napari_label_classes.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_napari_label_classes.py b/tests/test_napari_label_classes.py index ca49b8f..80561fa 100644 --- a/tests/test_napari_label_classes.py +++ b/tests/test_napari_label_classes.py @@ -13,3 +13,5 @@ def test_napari_label_classes_gray(test_data): face_color="red", size=1) assert len(viewer.layers['background'].data) == 1 + + viewer.close() From 4f3555ab093c9eda11f5cbde76297a5e4176ed7d Mon Sep 17 00:00:00 2001 From: Malia Gehan Date: Wed, 15 May 2024 12:00:34 -0500 Subject: [PATCH 24/30] Update test_napari_open.py add viewer.close() to napari.open --- tests/test_napari_open.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_napari_open.py b/tests/test_napari_open.py index cfb9d25..602e3ef 100644 --- a/tests/test_napari_open.py +++ b/tests/test_napari_open.py @@ -13,6 +13,7 @@ def test_napari_open_rgb(test_data): face_color="red", size=1) assert len(viewer.layers['total'].data) == 2 + viewer.close() def test_napari_open_gray(test_data): @@ -25,6 +26,7 @@ def test_napari_open_gray(test_data): face_color="red", size=1) assert len(viewer.layers['total'].data) == 2 + viewer.close() def test_napari_open_envi(test_data): @@ -38,3 +40,4 @@ def test_napari_open_envi(test_data): face_color="red", size=1) assert len(viewer.layers['total'].data) == 2 + viewer.close() From dbb565ff87f5278ded9efea5c90a7a44fafdee3c Mon Sep 17 00:00:00 2001 From: Malia Gehan Date: Wed, 15 May 2024 12:06:25 -0500 Subject: [PATCH 25/30] Create test_napari_join_labels.py added napari join labels tests with viewer close --- tests/test_napari_join_labels.py | 83 ++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 tests/test_napari_join_labels.py diff --git a/tests/test_napari_join_labels.py b/tests/test_napari_join_labels.py new file mode 100644 index 0000000..f3ae04b --- /dev/null +++ b/tests/test_napari_join_labels.py @@ -0,0 +1,83 @@ +import numpy as np +from plantcv.annotate.napari_open import napari_open +from plantcv.annotate.napari_label_classes import napari_label_classes +from plantcv.plantcv import readimage +from plantcv.annotate.napari_join_labels import napari_join_labels +from plantcv.plantcv import params + + +def test_napari_join_labels(test_data): + """Test for PlantCV.Annotate""" + # Read in test data + img, _, _ = readimage(test_data.kmeans_seed_gray_img) + viewer = napari_label_classes(img, ["seed"], show=False) + labeled, _ = napari_join_labels(img, viewer) + + assert np.shape(labeled) == (576, 537) + viewer.close() + + +def test_napari_join_allclass(test_data): + """Test for PlantCV.Annotate""" + # Read in test data + img, _, _ = readimage(test_data.kmeans_seed_gray_img) + viewer = napari_open(img, show=False) + background = [(54, 143), (77, 246)] + viewer.add_points(np.array(background), symbol="o", name='background', + face_color="red", size=1) + wing = [(275, 54)] + viewer.add_points(np.array(wing), symbol="o", name='wing', + face_color="red", size=1) + seed = [(280, 218)] + viewer.add_points(np.array(seed), symbol="o", name='seed', + face_color="red", size=1) + + labeled, _ = napari_join_labels(img, viewer) + + assert np.shape(labeled) == (576, 537) + viewer.close() + + +def test_napari_join_warn(test_data): + """Test for PlantCV.Annotate""" + # Read in test data + img, _, _ = readimage(test_data.kmeans_seed_gray_img) + viewer = napari_open(img, show=False) + background = [(54, 143), (77, 246)] + viewer.add_points(np.array(background), symbol="o", name='background', + face_color="red", size=1) + wing = [(275, 54)] + viewer.add_points(np.array(wing), symbol="o", name='wing', + face_color="red", size=1) + seed = [(275, 54)] + viewer.add_points(np.array(seed), symbol="o", name='seed', + face_color="red", size=1) + + labeled, _ = napari_join_labels(img, viewer) + + assert np.shape(labeled) == (576, 537) + viewer.close() + + +def test_napari_join_print(test_data, tmpdir): + """Test for PlantCV.Annotate""" + params.debug = 'print' + cache_dir = tmpdir.mkdir("cache") + params.debug_outdir = cache_dir + # Read in test data + img, _, _ = readimage(test_data.kmeans_seed_gray_img) + viewer = napari_open(img, show=False) + background = [(54, 143), (77, 246)] + viewer.add_points(np.array(background), symbol="o", name='background', + face_color="red", size=1) + wing = [(280, 218)] + viewer.add_points(np.array(wing), symbol="o", name='wing', + face_color="red", size=1) + seed = [(275, 54)] + viewer.add_points(np.array(seed), symbol="o", name='seed', + face_color="red", size=1) + + labeled, _ = napari_join_labels(img, viewer) + + assert np.shape(labeled) == (576, 537) + viewer.close() From b170a9a2ca7d5e5a509328c680ac65c47f962784 Mon Sep 17 00:00:00 2001 From: Malia Gehan Date: Wed, 15 May 2024 12:09:22 -0500 Subject: [PATCH 26/30] Delete test_napari_join_labels.py --- tests/test_napari_join_labels.py | 83 -------------------------------- 1 file changed, 83 deletions(-) delete mode 100644 tests/test_napari_join_labels.py diff --git a/tests/test_napari_join_labels.py b/tests/test_napari_join_labels.py deleted file mode 100644 index f3ae04b..0000000 --- a/tests/test_napari_join_labels.py +++ /dev/null @@ -1,83 +0,0 @@ -import numpy as np -from plantcv.annotate.napari_open import napari_open -from plantcv.annotate.napari_label_classes import napari_label_classes -from plantcv.plantcv import readimage -from plantcv.annotate.napari_join_labels import napari_join_labels -from plantcv.plantcv import params - - -def test_napari_join_labels(test_data): - """Test for PlantCV.Annotate""" - # Read in test data - img, _, _ = readimage(test_data.kmeans_seed_gray_img) - viewer = napari_label_classes(img, ["seed"], show=False) - labeled, _ = napari_join_labels(img, viewer) - - assert np.shape(labeled) == (576, 537) - viewer.close() - - -def test_napari_join_allclass(test_data): - """Test for PlantCV.Annotate""" - # Read in test data - img, _, _ = readimage(test_data.kmeans_seed_gray_img) - viewer = napari_open(img, show=False) - background = [(54, 143), (77, 246)] - viewer.add_points(np.array(background), symbol="o", name='background', - face_color="red", size=1) - wing = [(275, 54)] - viewer.add_points(np.array(wing), symbol="o", name='wing', - face_color="red", size=1) - seed = [(280, 218)] - viewer.add_points(np.array(seed), symbol="o", name='seed', - face_color="red", size=1) - - labeled, _ = napari_join_labels(img, viewer) - - assert np.shape(labeled) == (576, 537) - viewer.close() - - -def test_napari_join_warn(test_data): - """Test for PlantCV.Annotate""" - # Read in test data - img, _, _ = readimage(test_data.kmeans_seed_gray_img) - viewer = napari_open(img, show=False) - background = [(54, 143), (77, 246)] - viewer.add_points(np.array(background), symbol="o", name='background', - face_color="red", size=1) - wing = [(275, 54)] - viewer.add_points(np.array(wing), symbol="o", name='wing', - face_color="red", size=1) - seed = [(275, 54)] - viewer.add_points(np.array(seed), symbol="o", name='seed', - face_color="red", size=1) - - labeled, _ = napari_join_labels(img, viewer) - - assert np.shape(labeled) == (576, 537) - viewer.close() - - -def test_napari_join_print(test_data, tmpdir): - """Test for PlantCV.Annotate""" - params.debug = 'print' - cache_dir = tmpdir.mkdir("cache") - params.debug_outdir = cache_dir - # Read in test data - img, _, _ = readimage(test_data.kmeans_seed_gray_img) - viewer = napari_open(img, show=False) - background = [(54, 143), (77, 246)] - viewer.add_points(np.array(background), symbol="o", name='background', - face_color="red", size=1) - wing = [(280, 218)] - viewer.add_points(np.array(wing), symbol="o", name='wing', - face_color="red", size=1) - seed = [(275, 54)] - viewer.add_points(np.array(seed), symbol="o", name='seed', - face_color="red", size=1) - - labeled, _ = napari_join_labels(img, viewer) - - assert np.shape(labeled) == (576, 537) - viewer.close() From 6070954064823990783fd375db7f4a7a873ba178 Mon Sep 17 00:00:00 2001 From: Malia Gehan Date: Wed, 15 May 2024 12:12:27 -0500 Subject: [PATCH 27/30] Create test_napari_join_labels.py --- tests/test_napari_join_labels.py | 83 ++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 tests/test_napari_join_labels.py diff --git a/tests/test_napari_join_labels.py b/tests/test_napari_join_labels.py new file mode 100644 index 0000000..f3ae04b --- /dev/null +++ b/tests/test_napari_join_labels.py @@ -0,0 +1,83 @@ +import numpy as np +from plantcv.annotate.napari_open import napari_open +from plantcv.annotate.napari_label_classes import napari_label_classes +from plantcv.plantcv import readimage +from plantcv.annotate.napari_join_labels import napari_join_labels +from plantcv.plantcv import params + + +def test_napari_join_labels(test_data): + """Test for PlantCV.Annotate""" + # Read in test data + img, _, _ = readimage(test_data.kmeans_seed_gray_img) + viewer = napari_label_classes(img, ["seed"], show=False) + labeled, _ = napari_join_labels(img, viewer) + + assert np.shape(labeled) == (576, 537) + viewer.close() + + +def test_napari_join_allclass(test_data): + """Test for PlantCV.Annotate""" + # Read in test data + img, _, _ = readimage(test_data.kmeans_seed_gray_img) + viewer = napari_open(img, show=False) + background = [(54, 143), (77, 246)] + viewer.add_points(np.array(background), symbol="o", name='background', + face_color="red", size=1) + wing = [(275, 54)] + viewer.add_points(np.array(wing), symbol="o", name='wing', + face_color="red", size=1) + seed = [(280, 218)] + viewer.add_points(np.array(seed), symbol="o", name='seed', + face_color="red", size=1) + + labeled, _ = napari_join_labels(img, viewer) + + assert np.shape(labeled) == (576, 537) + viewer.close() + + +def test_napari_join_warn(test_data): + """Test for PlantCV.Annotate""" + # Read in test data + img, _, _ = readimage(test_data.kmeans_seed_gray_img) + viewer = napari_open(img, show=False) + background = [(54, 143), (77, 246)] + viewer.add_points(np.array(background), symbol="o", name='background', + face_color="red", size=1) + wing = [(275, 54)] + viewer.add_points(np.array(wing), symbol="o", name='wing', + face_color="red", size=1) + seed = [(275, 54)] + viewer.add_points(np.array(seed), symbol="o", name='seed', + face_color="red", size=1) + + labeled, _ = napari_join_labels(img, viewer) + + assert np.shape(labeled) == (576, 537) + viewer.close() + + +def test_napari_join_print(test_data, tmpdir): + """Test for PlantCV.Annotate""" + params.debug = 'print' + cache_dir = tmpdir.mkdir("cache") + params.debug_outdir = cache_dir + # Read in test data + img, _, _ = readimage(test_data.kmeans_seed_gray_img) + viewer = napari_open(img, show=False) + background = [(54, 143), (77, 246)] + viewer.add_points(np.array(background), symbol="o", name='background', + face_color="red", size=1) + wing = [(280, 218)] + viewer.add_points(np.array(wing), symbol="o", name='wing', + face_color="red", size=1) + seed = [(275, 54)] + viewer.add_points(np.array(seed), symbol="o", name='seed', + face_color="red", size=1) + + labeled, _ = napari_join_labels(img, viewer) + + assert np.shape(labeled) == (576, 537) + viewer.close() From 272f0825b241e392e082b7c909d2f0836a7151a7 Mon Sep 17 00:00:00 2001 From: Malia Gehan Date: Wed, 15 May 2024 12:27:03 -0500 Subject: [PATCH 28/30] line returns. remove some line returns for consistency. --- tests/test_napari_classes.py | 1 - tests/test_napari_label_classes.py | 1 - 2 files changed, 2 deletions(-) diff --git a/tests/test_napari_classes.py b/tests/test_napari_classes.py index 5e21ddf..e71826d 100644 --- a/tests/test_napari_classes.py +++ b/tests/test_napari_classes.py @@ -16,5 +16,4 @@ def test_napari_classes(make_napari_viewer): keys = napari_classes(viewer) assert keys == ['total', 'test'] - viewer.close() diff --git a/tests/test_napari_label_classes.py b/tests/test_napari_label_classes.py index 80561fa..a2ba4f9 100644 --- a/tests/test_napari_label_classes.py +++ b/tests/test_napari_label_classes.py @@ -13,5 +13,4 @@ def test_napari_label_classes_gray(test_data): face_color="red", size=1) assert len(viewer.layers['background'].data) == 1 - viewer.close() From 3daac8b63fe1bb5d22c63ef8e0ac8fd9aeca7eed Mon Sep 17 00:00:00 2001 From: Malia Gehan Date: Thu, 16 May 2024 09:38:01 -0500 Subject: [PATCH 29/30] Update continuous-integration.yml remove verbose and delay --- .github/workflows/continuous-integration.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index ed57f0e..e33b067 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -49,9 +49,8 @@ jobs: - name: Tests uses: aganders3/headless-gui@v2.2 with: - linux-setup-delay: 10000 xvfb-screen-size: 1280x720x24 - run: pytest -vv --cov-report=xml --cov=./ + run: pytest --cov-report=xml --cov=./ - name: Upload coverage to Deepsource uses: deepsourcelabs/test-coverage-action@master with: From 19129c4ef4ea011cf1df6f9bb355b90fcb0080c4 Mon Sep 17 00:00:00 2001 From: Malia Gehan Date: Thu, 16 May 2024 09:46:07 -0500 Subject: [PATCH 30/30] Update continuous-integration.yml --- .github/workflows/continuous-integration.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index e33b067..ca30610 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -16,7 +16,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ['3.9','3.10', '3.11'] + python-version: ['3.9', '3.10', '3.11'] os: [ubuntu-latest] env: OS: ${{ matrix.os }}