Skip to content

Commit ea2ad3e

Browse files
committed
Fix readimage import
And update the test to include cmyk channels
1 parent a1a3190 commit ea2ad3e

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

plantcv/plantcv/visualize/pixel_scatter_vis.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from plantcv.plantcv import rgb2gray_hsv
88
from plantcv.plantcv import rgb2gray_lab
99
from plantcv.plantcv import rgb2gray_cmyk
10-
from plantcv.plantcv import readimage
10+
from plantcv.plantcv.readimage import readimage
1111
from plantcv.plantcv import fatal_error
1212
from plantcv.plantcv import params
1313

@@ -101,7 +101,7 @@ def pixel_scatter_plot(paths_to_imgs, x_channel, y_channel):
101101
fig, ax = plt.subplots()
102102
# load and plot the set of images sequentially
103103
for p in paths_to_imgs:
104-
img, _, _ = readimage(filename=p, mode="native")
104+
img, _, _ = readimage(filename=p)
105105
h, _, c = img.shape
106106

107107
# resizing to predetermined width to reduce the number of pixels

tests/plantcv/visualize/test_pixel_scatter_plot.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
import cv2
33
import os
44
import numpy as np
5-
from plantcv.plantcv.visualize.pixel_scatter_vis import pixel_scatter_plot
5+
from plantcv.plantcv.visualize import pixel_scatter_plot
66

77

8-
@pytest.mark.parametrize("ch", ['R', 'G', 'B', 'l', 'a', 'b', 'h', 's', 'v', 'gray'])
8+
@pytest.mark.parametrize("ch", ['R', 'G', 'B', 'l', 'a', 'b', 'h', 's', 'v', 'c', 'm', 'y', 'k', 'gray'])
99
def test_pixel_scatter_plot(ch, tmpdir):
1010
"""Test for PlantCV."""
1111
# Create a tmp directory
1212
cache_dir = tmpdir.mkdir("cache")
1313
rng = np.random.default_rng()
14-
img_size = (10,10,3)
14+
img_size = (10, 10, 3)
1515
# create a random image and write it to the temp directory
1616
img = rng.integers(low=0, high=255, size=img_size, dtype=np.uint8, endpoint=True)
1717
path_to_img = os.path.join(cache_dir, 'tmp_img.png')
@@ -26,12 +26,11 @@ def test_pixel_scatter_plot_wrong_ch(tmpdir):
2626
# Create a tmp directory
2727
cache_dir = tmpdir.mkdir("cache")
2828
rng = np.random.default_rng()
29-
img_size = (10,10,3)
29+
img_size = (10, 10, 3)
3030
# create a random image and write it to the temp directory
3131
img = rng.integers(low=0, high=255, size=img_size, dtype=np.uint8, endpoint=True)
3232
path_to_img = os.path.join(cache_dir, 'tmp_img.png')
3333
cv2.imwrite(path_to_img, img)
3434
# test the function with channel parameter that is not an option
3535
with pytest.raises(RuntimeError):
3636
_, _ = pixel_scatter_plot(paths_to_imgs=[path_to_img], x_channel='wrong_ch', y_channel='index')
37-

0 commit comments

Comments
 (0)