Repository: ManimCommunity/manim
File: manim/mobject/three_d/three_dimensions.py (Python)

Code before:
                        v_range=[0, 5],
                        u_range=[0, 5],
                        )
                    surface_plane.set_style(fill_opacity=1)
                    surface_plane.set_fill_by_value(axes=axes, colorscale=[(RED, -0.5), (YELLOW, 0), (GREEN, 0.5)], axis=2)
                    self.add(axes, surface_plane)
        """
        if "colors" in kwargs and colorscale is None:
            colorscale = kwargs.pop("colors")
            if kwargs:
                raise ValueError(
                    "Unsupported keyword argument(s): "
                    f"{', '.join(str(key) for key in kwargs)}"
                )
        if colorscale is None:
            logger.warning(
                "The value passed to the colorscale keyword argument was None, "
                "the surface fill color has not been changed"
            )
            return self

        # TODO: Handle this type error that has been ignored
        # error: List item 0 has incompatible type "MethodType"; expected "Sequence[float]"  [list-item]
        # error: List item 1 has incompatible type "MethodType"; expected "Sequence[float]"  [list-item]
        # error: List item 2 has incompatible type "MethodType"; expected "Sequence[float]"  [list-item]
        ranges: list[Sequence[float]] = [axes.x_range, axes.y_range, axes.z_range]  # type: ignore[list-item]
        assert isinstance(colorscale, list)
        new_colors: list[ManimColor]
        if type(colorscale[0]) is tuple:
            new_colors, pivots = [
                [ManimColor(i) for i, j in colorscale],
                [j for i, j in colorscale],
            ]
        else:
            new_colors = [ManimColor(i) for i in colorscale]

            pivot_min = ranges[axis][0]
            pivot_max = ranges[axis][1]
            pivot_frequency = (pivot_max - pivot_min) / (len(new_colors) - 1)
            pivots = np.arange(
                start=pivot_min,
                stop=pivot_max + pivot_frequency,
                step=pivot_frequency,
            )

        for mob in self.family_members_with_points():
            axis_value = axes.point_to_coords(mob.get_midpoint())[axis]
            if axis_value <= pivots[0]:
                mob.set_color(new_colors[0])
            elif axis_value >= pivots[-1]:
                mob.set_color(new_colors[-1])

Review comment (suggestion):
Should be fixed if `axes` is a `ThreeDAxes` mobject.
```suggestion
        ranges = [axes.x_range, axes.y_range, axes.z_range]
```

Code after:
                        v_range=[0, 5],
                        u_range=[0, 5],
                        )
                    surface_plane.set_style(fill_opacity=1)
                    surface_plane.set_fill_by_value(axes=axes, colorscale=[(RED, -0.5), (YELLOW, 0), (GREEN, 0.5)], axis=2)
                    self.add(axes, surface_plane)
        """
        if "colors" in kwargs and colorscale is None:
            colorscale = kwargs.pop("colors")
            if kwargs:
                raise ValueError(
                    "Unsupported keyword argument(s): "
                    f"{', '.join(str(key) for key in kwargs)}"
                )
        if colorscale is None:
            logger.warning(
                "The value passed to the colorscale keyword argument was None, "
                "the surface fill color has not been changed"
            )
            return self
        colorscale_list = list(colorscale)

        ranges = [axes.x_range, axes.y_range, axes.z_range]
        assert isinstance(colorscale_list, list)
        new_colors: list[ManimColor]
        if type(colorscale_list[0]) is tuple and len(colorscale_list[0]) == 2:
            new_colors, pivots = [
                [ManimColor(i) for i, j in colorscale_list],
                [j for i, j in colorscale_list],
            ]
        else:
            new_colors = [ManimColor(i) for i in colorscale_list]
            current_range = ranges[axis]

            assert current_range is not None
            pivot_min = current_range[0]
            pivot_max = current_range[1]
            pivot_frequency = (pivot_max - pivot_min) / (len(new_colors) - 1)
            pivots = np.arange(
                start=pivot_min,
                stop=pivot_max + pivot_frequency,
                step=pivot_frequency,
            )

        for mob in self.family_members_with_points():
            axis_value = axes.point_to_coords(mob.get_midpoint())[axis]
            if axis_value <= pivots[0]:
                mob.set_color(new_colors[0])
            elif axis_value >= pivots[-1]:
                mob.set_color(new_colors[-1])
            else: