Skip to content

Commit f43f543

Browse files
dawnsqrlbehacklpre-commit-ci[bot]
authored
Fix arguments of overridden set_style for BackgroundRectangle (#2658)
* Sync `set_style` arguments with base * Minimize set_style arguments; add info log * Remove excessive import * more verbose logger output, added test * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: Benjamin Hackl <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 2964326 commit f43f543

File tree

2 files changed

+26
-10
lines changed

2 files changed

+26
-10
lines changed

manim/mobject/geometry/shape_matchers.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
__all__ = ["SurroundingRectangle", "BackgroundRectangle", "Cross", "Underline"]
66

7-
from manim import config
7+
from manim import config, logger
88
from manim.constants import *
99
from manim.mobject.geometry.line import Line
1010
from manim.mobject.geometry.polygram import RoundedRectangle
@@ -104,21 +104,20 @@ def pointwise_become_partial(self, mobject, a, b):
104104
self.set_fill(opacity=b * self.original_fill_opacity)
105105
return self
106106

107-
def set_style(
108-
self,
109-
stroke_color=None,
110-
stroke_width=None,
111-
fill_color=None,
112-
fill_opacity=None,
113-
family=True,
114-
):
107+
def set_style(self, fill_opacity, **kwargs):
115108
# Unchangeable style, except for fill_opacity
109+
# All other style arguments are ignored
116110
super().set_style(
117111
stroke_color=BLACK,
118112
stroke_width=0,
119113
fill_color=BLACK,
120114
fill_opacity=fill_opacity,
121115
)
116+
if len(kwargs) > 0:
117+
logger.info(
118+
"Argument %s is ignored in BackgroundRectangle.set_style.",
119+
kwargs,
120+
)
122121
return self
123122

124123
def get_fill_color(self):

tests/test_unit_geometry.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,26 @@
11
from __future__ import annotations
22

3+
import logging
4+
35
import numpy as np
46

5-
from manim import Sector
7+
logger = logging.getLogger(__name__)
8+
9+
from manim import BackgroundRectangle, Circle, Sector
610

711

812
def test_get_arc_center():
913
assert np.all(Sector(arc_center=[1, 2, 0]).get_arc_center() == [1, 2, 0])
14+
15+
16+
def test_BackgroundRectangle(caplog):
17+
caplog.set_level(logging.INFO)
18+
c = Circle()
19+
bg = BackgroundRectangle(c)
20+
bg.set_style(fill_opacity=0.42)
21+
assert bg.get_fill_opacity() == 0.42
22+
bg.set_style(fill_opacity=1, hello="world")
23+
assert (
24+
"Argument {'hello': 'world'} is ignored in BackgroundRectangle.set_style."
25+
in caplog.text
26+
)

0 commit comments

Comments
 (0)