Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/machinevisiontoolbox/ImageBlobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2303,7 +2303,7 @@ def plot_aligned_box(self, *args: Any, **kwargs: Any) -> None:
if not isinstance(boxes, list):
boxes = [boxes]
for box in boxes:
smb.plot_polygon(box[2], *args, close=True, **options)
smb.plot_polygon(box[2], close=True, **options)

def plot_MEC(self, *args: Any, **kwargs: Any) -> None:
"""
Expand Down Expand Up @@ -2349,7 +2349,7 @@ def plot_MEC(self, *args: Any, **kwargs: Any) -> None:
if not isinstance(mecs, list):
mecs = [mecs]
for mec in mecs:
smb.plot_circle(mec[2], mec[:2], *args, **options)
smb.plot_circle(mec[2], mec[:2], **options)

def plot_MER(self, *args: Any, **kwargs: Any) -> None:
"""
Expand Down Expand Up @@ -2400,7 +2400,7 @@ def plot_MER(self, *args: Any, **kwargs: Any) -> None:
box = np.array([[w, h], [w, -h], [-w, -h], [-w, h], [w, h]]).T / 2.0
T = SE2(float(mer[0]), float(mer[1]), float(np.radians(mer[4])))
box = np.asarray(T * box)
smb.plot_polygon(box[:2, :], *args, **options)
smb.plot_polygon(box[:2, :], **options)

def label_image(self, image: Any = None) -> Any:
"""
Expand Down
27 changes: 27 additions & 0 deletions tests/test_image_blobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,33 @@ def test_plot_aligned_box_ratio(self):
def test_plot_aligned_box_kwargs(self):
self._test_plot_adds("plot_aligned_box", self._lines, color="yellow")

# the format string is applied once, by mpl_styling: what each line looks like
_FMT_RESULTS = [
# fmt, color, linestyle, marker
(None, "yellow", "-", "None"),
("g", "g", "-", "None"),
("r--", "r", "--", "None"),
("--", "yellow", "--", "None"),
("r:", "r", ":", "None"),
("o", "yellow", "None", "o"), # markers only, as for plot()
("r.", "r", "None", "."),
("C1", "C1", "-", "None"),
("orange", "orange", "-", "None"),
]

def test_polygon_and_circle_methods_apply_the_format_string_once(self):
for method in ("plot_aligned_box", "plot_MEC", "plot_MER"):
for fmt, color, linestyle, marker in self._FMT_RESULTS:
with self.subTest(method=method, fmt=fmt):
fig, ax = self._fresh_ax()
getattr(self.blobs1, method)(*([] if fmt is None else [fmt]))
line = ax.lines[0]
plt.close(fig)
self.assertEqual(line.get_color(), color)
self.assertEqual(line.get_linestyle(), linestyle)
self.assertEqual(line.get_marker(), marker)
self.assertEqual(line.get_linewidth(), 2)

# ------------------------------------------------------------------ #
# plot_MEC (smb.plot_circle → 1 artist per blob)
# ------------------------------------------------------------------ #
Expand Down
Loading