ronantakizawa/codereview-bench huggingface dataset:
Repository: ManimCommunity/manim
File: manim/_config/main_utils.py (Python)

Code before:
        type=str,
        help=(
            "Verbosity level. Also changes the ffmpeg log level unless "
            "the latter is specified in the config"
        ),
        choices=constants.VERBOSITY_CHOICES,
    )

    parser.add_argument(
        "--version",
        action="store_true",
        help="Print the current version of Manim you are using",
    )

    # Specify if the progress bar should be displayed
    parser.add_argument(
        "--progress_bar",
        type=_str2bool,
        help="Display the progress bar",
        metavar="True/False",
    )

    parser.add_argument(
        "--jupyter_width", type=str, help="Width of the displayed media on Jupyter"
    )

    return parser.parse_args(args[1:])


Review comment (bug):
I believe this file is responsible for adding the option to the CLI which we don't want since `--jupyter_width` shouldn't be called from the CLI (I could be wrong about that though).
```suggestion
```

Code after:
    )

    # Specify the verbosity
    parser.add_argument(
        "-v",
        "--verbosity",
        type=str,
        help=(
            "Verbosity level. Also changes the ffmpeg log level unless "
            "the latter is specified in the config"
        ),
        choices=constants.VERBOSITY_CHOICES,
    )

    parser.add_argument(
        "--version",
        action="store_true",
        help="Print the current version of Manim you are using",
    )

    # Specify if the progress bar should be displayed
    parser.add_argument(
        "--progress_bar",
        type=_str2bool,
        help="Display the progress bar",
        metavar="True/False",
    )

    return parser.parse_args(args[1:])
Repository: ManimCommunity/manim
File: tests/test_commands.py (Python)

Code before:
    import importlib.metadata as importlib_metadata
except ModuleNotFoundError:
    import importlib_metadata

import manim


def call_command(command, cwd=None, env=None):
    a = subprocess.run(
        command,
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE,
        check=True,
        text=True,
        cwd=cwd,
        env=env,
    )
    return a


def test_manim_version_from_command_line():
    a = call_command(
        [
            sys.executable,
            "-m",
            "manim",
            "--version",
        ]
    )
    version = importlib_metadata.version("manim")
    assert version in a.stdout
    assert a.stdout.strip() == f"Manim Community v{version}"
    assert manim.__version__ == version


def test_manim_cfg_subcommand_no_subcommand():
    a = call_command(
        [
            sys.executable,
            "-m",
            "manim",
            "cfg",
        ]
    )
    assert "No subcommand provided; Exiting..." in a.stdout


def test_manim_plugis_subcommand_no_subcommand():
    a = call_command(
        [
            sys.executable,

Review comment (suggestion):
```suggestion
    assert __version__ in a.stdout
```

Code after:


def call_command(command, cwd=None, env=None):
    a = subprocess.run(
        command,
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE,
        check=True,
        text=True,
        cwd=cwd,
        env=env,
    )
    return a


def test_manim_version_from_command_line():
    a = call_command(
        [
            sys.executable,
            "-m",
            "manim",
            "--version",
        ]
    )
    version = manim.__version__
    assert version in a.stdout
    assert a.stdout.strip() == f"Manim Community v{version}"


def test_manim_cfg_subcommand_no_subcommand():
    a = call_command(
        [
            sys.executable,
            "-m",
            "manim",
            "cfg",
        ]
    )
    assert "No subcommand provided; Exiting..." in a.stdout


def test_manim_plugis_subcommand_no_subcommand():
    a = call_command(
        [
            sys.executable,
            "-m",
            "manim",
            "plugins",
        ]
    )
    assert "No flag provided; Exiting..." in a.stdout
Repository: ManimCommunity/manim
File: tests/test_commands.py (Python)

Code before:
def call_command(command, cwd=None, env=None):
    a = subprocess.run(
        command,
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE,
        check=True,
        text=True,
        cwd=cwd,
        env=env,
    )
    return a


def test_manim_version_from_command_line():
    a = call_command(
        [
            sys.executable,
            "-m",
            "manim",
            "--version",
        ]
    )
    version = importlib_metadata.version("manim")
    assert version in a.stdout
    assert a.stdout.strip() == f"Manim Community v{version}"
    assert manim.__version__ == version


def test_manim_cfg_subcommand_no_subcommand():
    a = call_command(
        [
            sys.executable,
            "-m",
            "manim",
            "cfg",
        ]
    )
    assert "No subcommand provided; Exiting..." in a.stdout


def test_manim_plugis_subcommand_no_subcommand():
    a = call_command(
        [
            sys.executable,
            "-m",
            "manim",
            "plugins",
        ]
    )
    assert "No flag provided; Exiting..." in a.stdout


Review comment (suggestion):
This assertion will always be true because `manim.__version__` is set the same way as you set `version` above. Instead, there is a already a test [here](https://github.com/ManimCommunity/manim/blob/master/tests/test_version.py) that _should_ be comparing `__version__` to the version in `pyproject.toml`.

Code after:
        check=True,
        text=True,
        cwd=cwd,
        env=env,
    )
    return a


def test_manim_version_from_command_line():
    a = call_command(
        [
            sys.executable,
            "-m",
            "manim",
            "--version",
        ]
    )
    version = manim.__version__
    assert version in a.stdout
    assert a.stdout.strip() == f"Manim Community v{version}"


def test_manim_cfg_subcommand_no_subcommand():
    a = call_command(
        [
            sys.executable,
            "-m",
            "manim",
            "cfg",
        ]
    )
    assert "No subcommand provided; Exiting..." in a.stdout


def test_manim_plugis_subcommand_no_subcommand():
    a = call_command(
        [
            sys.executable,
            "-m",
            "manim",
            "plugins",
        ]
    )
    assert "No flag provided; Exiting..." in a.stdout


def test_manim_plugis_subcommand_listing(function_like_plugin):
    # Check whether `test_plugin` is in plugins list
    a = call_command([sys.executable, "-m", "manim", "plugins", "--list"])
    assert "test_plugin" in a.stdout
Repository: ManimCommunity/manim
File: manim/mobject/geometry.py (Python)

Code before:
                line2 = Line( DOWN, UP )
                rightangles = [
                    RightAngle(line1, line2),
                    RightAngle(line1, line2, length=0.4, quadrant=(1,-1)),
                    RightAngle(line1, line2, length=0.5, quadrant=(-1,1), stroke_width=8),
                    RightAngle(line1, line2, length=0.7, quadrant=(-1,-1), color=RED),
                ]
                line_list = VGroup( *[VGroup() for k in range(4)] )
                for k in range(4):
                    linea = line1.copy()
                    lineb = line2.copy()
                    line_list[k].add( linea )
                    line_list[k].add( lineb )
                    line_list[k].add( rightangles[k] )
                line_list.arrange_in_grid(buff=1.5)
                self.add(
                    line_list
                )

    """

    def __init__(self, line1, line2, length=None, **kwargs):
        if length == None:
            Angle.__init__(self, line1, line2, elbow=True, **kwargs)
        else:
            Angle.__init__(self, line1, line2, radius=length, elbow=True, **kwargs)


Review comment (suggestion):
I think this can be simplified to just:
```suggestion
        Angle.__init__(self, line1, line2, radius=length, elbow=True, **kwargs)
```
since if `length==None` then the Angle constructor would just receive `radius=None` (which is the default behavior for Angle) and calculate it dynamically. Essentially, `RightAngle` is just a shorthand for passing in `elbow=True`.

Code after:

    Examples
    --------

    .. manim:: RightAngleExample
        :save_last_frame:

        class RightAngleExample(Scene):
            def construct(self):
                line1 = Line( LEFT, RIGHT )
                line2 = Line( DOWN, UP )
                rightangles = [
                    RightAngle(line1, line2),
                    RightAngle(line1, line2, length=0.4, quadrant=(1,-1)),
                    RightAngle(line1, line2, length=0.5, quadrant=(-1,1), stroke_width=8),
                    RightAngle(line1, line2, length=0.7, quadrant=(-1,-1), color=RED),
                ]
                line_list = VGroup( *[VGroup() for k in range(4)] )
                for k in range(4):
                    linea = line1.copy()
                    lineb = line2.copy()
                    line_list[k].add( linea )
                    line_list[k].add( lineb )
                    line_list[k].add( rightangles[k] )
                line_list.arrange_in_grid(buff=1.5)
                self.add(
                    line_list
                )

    """

    def __init__(self, line1, line2, length=None, **kwargs):
        Angle.__init__(self, line1, line2, radius=length, elbow=True, **kwargs)
Repository: ManimCommunity/manim
File: manim/utils/config_ops.py (Python)

Code before:

def merge_dicts_recursively(*dicts):
    """
    Creates a dict whose keyset is the union of all the
    input dictionaries.  The value for each key is based
    on the first dict in the list with that key.

    dicts later in the list have higher priority

    When values are dictionaries, it is applied recursively
    """
    result = dict()
    all_items = it.chain(*[d.items() for d in dicts])
    for key, value in all_items:
        if key in result and isinstance(result[key], dict) and isinstance(value, dict):
            result[key] = merge_dicts_recursively(result[key], value)
        else:
            result[key] = value
    return result


def update_dict_recursively(*dicts):
    current_dict = dicts[0]
    updated_dict = merge_dicts_recursively(*dicts)
    for key, value in updated_dict.items():
        current_dict[key] = value


# Occasionally convenient in order to write dict.x instead of more laborious
# (and less in keeping with all other attr accesses) dict["x"]


class DictAsObject(object):
    def __init__(self, dict):
        self.__dict__ = dict


Review comment (suggestion):
The current code can error on `dicts[0]` if no dicts are passed; better to be explicit in the signature about how many arguments are needed imo. Also the for loop can just be replaced with a call to `dict.update` afaict
```suggestion
def update_dict_recursively(current_dict, *others):
    updated_dict = merge_dicts_recursively(current_dict, *others)
    current_dict.update(updated_dict)
```

Code after:

def merge_dicts_recursively(*dicts):
    """
    Creates a dict whose keyset is the union of all the
    input dictionaries.  The value for each key is based
    on the first dict in the list with that key.

    dicts later in the list have higher priority

    When values are dictionaries, it is applied recursively
    """
    result = dict()
    all_items = it.chain(*[d.items() for d in dicts])
    for key, value in all_items:
        if key in result and isinstance(result[key], dict) and isinstance(value, dict):
            result[key] = merge_dicts_recursively(result[key], value)
        else:
            result[key] = value
    return result


def update_dict_recursively(current_dict, *others):
    updated_dict = merge_dicts_recursively(current_dict, *others)
    current_dict.update(updated_dict)


# Occasionally convenient in order to write dict.x instead of more laborious
# (and less in keeping with all other attr accesses) dict["x"]


class DictAsObject(object):
    def __init__(self, dict):
        self.__dict__ = dict
Repository: ManimCommunity/manim
File: manim/mobject/three_dimensions.py (Python)

Code before:
    ):
        ParametricSurface.__init__(
            self,
            self.func,
            resolution=resolution,
            u_min=u_min,
            u_max=u_max,
            v_min=v_min,
            v_max=v_max,
            **kwargs,
        )
        self.radius = radius
        self.scale(self.radius)

    def func(
        self, u, v
    ):  # FIXME: An attribute defined in manim.mobject.three_dimensions line 56 hides this method
        return np.array([np.cos(v) * np.sin(u), np.sin(v) * np.sin(u), np.cos(u)])


class Dot3D(Sphere):
    """A spherical dot.

    Parameters
    --------
    radius : :class:`float`
        The radius of the dot.
    """

    def __init__(self, radius=DEFAULT_DOT_RADIUS, color=WHITE, **kwargs):
        Sphere.__init__(self, radius=radius, **kwargs)
        self.set_color(color)


class Cube(VGroup):
    def __init__(
        self,
        side_length=2,
        fill_opacity=0.75,
        fill_color=BLUE,
        stroke_width=0,
        **kwargs
    ):
        self.side_length = side_length
        super().__init__(
            fill_color=fill_color,
            fill_opacity=fill_opacity,
            stroke_width=stroke_width,
            **kwargs,
        )


Review comment (suggestion):
```suggestion
    radius : :class:`float`, optional
```

Code after:
    ):
        ParametricSurface.__init__(
            self,
            self.func,
            resolution=resolution,
            u_min=u_min,
            u_max=u_max,
            v_min=v_min,
            v_max=v_max,
            **kwargs,
        )
        self.radius = radius
        self.scale(self.radius)

    def func(
        self, u, v
    ):  # FIXME: An attribute defined in manim.mobject.three_dimensions line 56 hides this method
        return np.array([np.cos(v) * np.sin(u), np.sin(v) * np.sin(u), np.cos(u)])


class Dot3D(Sphere):
    """A spherical dot.

    Parameters
    --------
    radius : :class:`float`, optional
        The radius of the dot.
    color : :class:`~.Colors`, optional
        The color of the :class:`Dot3D`

    Examples
    --------

    .. manim:: Dot3DExample
        :save_last_frame:

        class Dot3DExample(ThreeDScene):
            def construct(self):
                self.set_camera_orientation(phi=75*DEGREES, theta=-45*DEGREES)

                axes = ThreeDAxes()
                dot_1 = Dot3D(color=RED).move_to(axes.coords_to_point(0, 0, 1))
                dot_2 = Dot3D(radius=0.1, color=BLUE).move_to(axes.coords_to_point(2, 0, 0))

                self.add(axes, dot_1, dot_2)
    """

    def __init__(self, radius=DEFAULT_DOT_RADIUS, color=WHITE, **kwargs):
        Sphere.__init__(self, radius=radius, **kwargs)
        self.set_color(color)
Repository: ManimCommunity/manim
File: manim/mobject/three_dimensions.py (Python)

Code before:
class Dot3D(Sphere):
    """A spherical dot.

    Parameters
    --------
    radius : :class:`float`
        The radius of the dot.
    """

    def __init__(self, radius=DEFAULT_DOT_RADIUS, color=WHITE, **kwargs):
        Sphere.__init__(self, radius=radius, **kwargs)
        self.set_color(color)


class Cube(VGroup):
    def __init__(
        self,
        side_length=2,
        fill_opacity=0.75,
        fill_color=BLUE,
        stroke_width=0,
        **kwargs
    ):
        self.side_length = side_length
        super().__init__(
            fill_color=fill_color,
            fill_opacity=fill_opacity,
            stroke_width=stroke_width,
            **kwargs,
        )

    def generate_points(self):
        for vect in IN, OUT, LEFT, RIGHT, UP, DOWN:
            face = Square(
                side_length=self.side_length,
                shade_in_3d=True,
            )
            face.flip()
            face.shift(self.side_length * OUT / 2.0)
            face.apply_matrix(z_to_vector(vect))

            self.add(face)


class Prism(Cube):
    def __init__(self, dimensions=[3, 2, 1], **kwargs):
        self.dimensions = dimensions
        Cube.__init__(self, **kwargs)

    def generate_points(self):
        Cube.generate_points(self)

Review comment (suggestion):
```suggestion
    color : :class:`~.Colors`, optional
        The color of the :class:`Dot3D`
```
    

Code after:
class Dot3D(Sphere):
    """A spherical dot.

    Parameters
    --------
    radius : :class:`float`, optional
        The radius of the dot.
    color : :class:`~.Colors`, optional
        The color of the :class:`Dot3D`

    Examples
    --------

    .. manim:: Dot3DExample
        :save_last_frame:

        class Dot3DExample(ThreeDScene):
            def construct(self):
                self.set_camera_orientation(phi=75*DEGREES, theta=-45*DEGREES)

                axes = ThreeDAxes()
                dot_1 = Dot3D(color=RED).move_to(axes.coords_to_point(0, 0, 1))
                dot_2 = Dot3D(radius=0.1, color=BLUE).move_to(axes.coords_to_point(2, 0, 0))

                self.add(axes, dot_1, dot_2)
    """

    def __init__(self, radius=DEFAULT_DOT_RADIUS, color=WHITE, **kwargs):
        Sphere.__init__(self, radius=radius, **kwargs)
        self.set_color(color)


class Cube(VGroup):
    def __init__(
        self,
        side_length=2,
        fill_opacity=0.75,
        fill_color=BLUE,
        stroke_width=0,
        **kwargs
    ):
        self.side_length = side_length
        super().__init__(
            fill_color=fill_color,
            fill_opacity=fill_opacity,
            stroke_width=stroke_width,
            **kwargs,
        )

    def generate_points(self):
        for vect in IN, OUT, LEFT, RIGHT, UP, DOWN:
Repository: ManimCommunity/manim
File: manim/mobject/mobject.py (Python)

Code before:
        Parameters
        ----------
        recursive : :class:`bool`
            Whether to recursively enable updating on all submobjects.

        Returns
        -------
        :class:`Mobject`
            ``self``

        See also
        --------
        :meth:`suspend_updating`
        :meth:`add_updater`

        """
        self.updating_suspended = False
        if recursive:
            for submob in self.submobjects:
                submob.resume_updating(recursive)
        self.update(dt=0, recursive=recursive)
        return self

    # Transforming operations

    def apply_to_family(self, func) -> "Mobject":
        """Apply a function to ``self`` and every submobject with points recursively.

        Parameters
        ----------
        func : :class:`Callable`
            The function to apply to each mobject. ``func`` gets passed the respective (sub)mobject as parameter.

        Returns
        -------
        :class:`Mobject`
            ``self``

        See also
        --------
        :meth:`family_members_with_points`

        """
        for mob in self.family_members_with_points():
            func(mob)

    def shift(self, *vectors) -> "Mobject":
        """Shift by the given vectors.

        Parameters
        ----------

Review comment (suggestion):
`func` is a function that accepts Mobject as a parameter and doesn't return anything right?
```suggestion
    def apply_to_family(self, func: Callable[["Mobject"], None]) -> "Mobject":
```


Code after:
            for submob in self.submobjects:
                submob.suspend_updating(recursive)
        return self

    def resume_updating(self, recursive: bool = True) -> "Mobject":
        """Enable updating from updaters and animations.

        Parameters
        ----------
        recursive
            Whether to recursively enable updating on all submobjects.

        Returns
        -------
        :class:`Mobject`
            ``self``

        See also
        --------
        :meth:`suspend_updating`
        :meth:`add_updater`

        """
        self.updating_suspended = False
        if recursive:
            for submob in self.submobjects:
                submob.resume_updating(recursive)
        self.update(dt=0, recursive=recursive)
        return self

    # Transforming operations

    def apply_to_family(self, func: Callable[["Mobject"], None]) -> "Mobject":
        """Apply a function to ``self`` and every submobject with points recursively.

        Parameters
        ----------
        func
            The function to apply to each mobject. ``func`` gets passed the respective (sub)mobject as parameter.

        Returns
        -------
        :class:`Mobject`
            ``self``

        See also
        --------
        :meth:`family_members_with_points`

        """
        for mob in self.family_members_with_points():
Repository: ManimCommunity/manim
File: manim/mobject/mobject.py (Python)

Code before:
        return self

    # Transforming operations

    def apply_to_family(self, func) -> "Mobject":
        """Apply a function to ``self`` and every submobject with points recursively.

        Parameters
        ----------
        func : :class:`Callable`
            The function to apply to each mobject. ``func`` gets passed the respective (sub)mobject as parameter.

        Returns
        -------
        :class:`Mobject`
            ``self``

        See also
        --------
        :meth:`family_members_with_points`

        """
        for mob in self.family_members_with_points():
            func(mob)

    def shift(self, *vectors) -> "Mobject":
        """Shift by the given vectors.

        Parameters
        ----------
        vectors : :class:numpy.ndarray`
            Vectors to shift by. If multiple vectors are given, they are added together.

        Returns
        -------
        :class:`Mobject`
            ``self``

        See also
        --------
        :meth:`move_to`
        """

        if config["use_opengl_renderer"]:
            self.apply_points_function(
                lambda points: points + vectors[0],
                about_edge=None,
                works_on_bounding_box=True,
            )
            return self
        else:

Review comment (suggestion):
```suggestion
    def shift(self, *vectors: np.ndarray) -> "Mobject":
```

Code after:

        """
        self.updating_suspended = False
        if recursive:
            for submob in self.submobjects:
                submob.resume_updating(recursive)
        self.update(dt=0, recursive=recursive)
        return self

    # Transforming operations

    def apply_to_family(self, func: Callable[["Mobject"], None]) -> "Mobject":
        """Apply a function to ``self`` and every submobject with points recursively.

        Parameters
        ----------
        func
            The function to apply to each mobject. ``func`` gets passed the respective (sub)mobject as parameter.

        Returns
        -------
        :class:`Mobject`
            ``self``

        See also
        --------
        :meth:`family_members_with_points`

        """
        for mob in self.family_members_with_points():
            func(mob)

    def shift(self, *vectors: np.ndarray) -> "Mobject":
        """Shift by the given vectors.

        Parameters
        ----------
        vectors
            Vectors to shift by. If multiple vectors are given, they are added together.

        Returns
        -------
        :class:`Mobject`
            ``self``

        See also
        --------
        :meth:`move_to`
        """

        if config["use_opengl_renderer"]: