mirror of
https://github.com/ManimCommunity/manim.git
synced 2026-06-22 10:01:47 +00:00
Improve the output generated by --show_diff (#4554)
* Improve the output generated by --show_diff Do not only look at the red color channel values. * Remove comment * Code cleanup * Use named colors as suggested by Chopan50 * Use the actual shape * Made the code easier to read. Solution by Chopan50
This commit is contained in:
parent
b579779ce7
commit
61b8cfd52f
1 changed files with 5 additions and 12 deletions
|
|
@ -3,9 +3,8 @@ from __future__ import annotations
|
|||
import logging
|
||||
import warnings
|
||||
|
||||
import numpy as np
|
||||
|
||||
from manim.typing import PixelArray
|
||||
from manim.utils.color import BLACK, PURE_GREEN, PURE_RED
|
||||
|
||||
__all__ = ["show_diff_helper"]
|
||||
|
||||
|
|
@ -33,17 +32,11 @@ def show_diff_helper(
|
|||
ax.set_title("Expected")
|
||||
|
||||
ax = fig.add_subplot(gs[1, :])
|
||||
generated_is_expected = (frame_data == expected_frame_data).all(2)
|
||||
expected_is_black = (expected_frame_data == BLACK.to_int_rgba()).all(2)
|
||||
diff_im = expected_frame_data.copy()
|
||||
diff_im = np.where(
|
||||
frame_data != np.array([0, 0, 0, 255]),
|
||||
np.array([0, 255, 0, 255], dtype="uint8"),
|
||||
np.array([0, 0, 0, 255], dtype="uint8"),
|
||||
) # Set any non-black pixels to green
|
||||
np.putmask(
|
||||
diff_im,
|
||||
expected_frame_data != frame_data,
|
||||
np.array([255, 0, 0, 255], dtype="uint8"),
|
||||
) # Set any different pixels to red
|
||||
diff_im[generated_is_expected & ~expected_is_black] = PURE_GREEN.to_int_rgba()
|
||||
diff_im[~generated_is_expected & ~expected_is_black] = PURE_RED.to_int_rgba()
|
||||
ax.imshow(diff_im, interpolation="nearest")
|
||||
ax.set_title("Difference summary: (green = same, red = different)")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue