Skip to content

Commit

Permalink
Remove deprecated u-min/max and v-min/max in Surface (#2061)
Browse files Browse the repository at this point in the history
Co-authored-by: Laith Bahodi <[email protected]>
  • Loading branch information
k4pran and hydrobeam authored Sep 28, 2021
1 parent 568db8f commit 0976f23
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 24 deletions.
26 changes: 6 additions & 20 deletions manim/mobject/three_dimensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,6 @@ def construct(self):
self.add(axes, surface)
"""

@deprecated_params(
params="u_min,u_max,v_min,v_max",
since="v0.9.0",
until="v0.10.0",
message="Use u_range and v_range instead.",
)
def __init__(
self,
func: Callable[[float, float], np.ndarray],
Expand All @@ -98,10 +92,8 @@ def __init__(
pre_function_handle_to_anchor_scale_factor: float = 0.00001,
**kwargs
) -> None:
self.u_min = kwargs.pop("u_min", None) or u_range[0]
self.u_max = kwargs.pop("u_max", None) or u_range[1]
self.v_min = kwargs.pop("v_min", None) or v_range[0]
self.v_max = kwargs.pop("v_max", None) or v_range[1]
self.u_range = u_range
self.v_range = v_range
super().__init__(**kwargs)
self.resolution = resolution
self.surface_piece_config = surface_piece_config
Expand All @@ -126,13 +118,9 @@ def get_u_values_and_v_values(self):
u_res = v_res = res[0]
else:
u_res, v_res = res
u_min = self.u_min
u_max = self.u_max
v_min = self.v_min
v_max = self.v_max

u_values = np.linspace(u_min, u_max, u_res + 1)
v_values = np.linspace(v_min, v_max, v_res + 1)
u_values = np.linspace(*self.u_range, u_res + 1)
v_values = np.linspace(*self.v_range, v_res + 1)

return u_values, v_values

Expand Down Expand Up @@ -634,24 +622,22 @@ def add_bases(self):
"""Adds the end caps of the cylinder."""
color = self.color if config["renderer"] == "opengl" else self.fill_color
opacity = self.opacity if config["renderer"] == "opengl" else self.fill_opacity
u_min = self.u_range[0] if config["renderer"] == "opengl" else self.u_min
u_max = self.u_range[1] if config["renderer"] == "opengl" else self.u_max
self.base_top = Circle(
radius=self.radius,
color=color,
fill_opacity=opacity,
shade_in_3d=True,
stroke_width=0,
)
self.base_top.shift(u_max * IN)
self.base_top.shift(self.u_range[1] * IN)
self.base_bottom = Circle(
radius=self.radius,
color=color,
fill_opacity=opacity,
shade_in_3d=True,
stroke_width=0,
)
self.base_bottom.shift(u_min * IN)
self.base_bottom.shift(self.u_range[0] * IN)
self.add(self.base_top, self.base_bottom)

def _rotate_to_direction(self):
Expand Down
6 changes: 2 additions & 4 deletions tests/test_graphical_units/test_threed.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,8 @@ def param_trig(u, v):
trig_plane = Surface(
lambda x, y: axes.c2p(x, y, param_trig(x, y)),
resolution=(resolution_fa, resolution_fa),
v_min=-3,
v_max=+3,
u_min=-3,
u_max=+3,
v_range=[-3, 3],
u_range=[-3, 3],
)
trig_plane.set_fill_by_value(axes=axes, colors=[BLUE, GREEN, YELLOW, ORANGE, RED])
scene.add(axes, trig_plane)

0 comments on commit 0976f23

Please sign in to comment.