Repository: ManimCommunity/manim
File: manim/mobject/svg/svg_path.py (Python)

Code before:
    num_string = num_string.replace("-", ",-")
    num_string = num_string.replace("e,-", "e-")
    float_results = []
    for s in re.split("[ ,]", num_string):
        if s != "":
            try:
                float_results.append(float(s))
            except ValueError:
                # in this case, it's something like "2.4.3.14 which should be parsed as "2.4 0.3 0.14"
                undotted_parts = s.split(".")
                float_results.append(undotted_parts[0] + "." + undotted_parts[1])
                float_results += ["." + u for u in undotted_parts[2:]]
    return float_results


def grouped(iterable, n):
    """Group iterable into arrays of n items."""
    return (np.array(v) for v in zip(*[iter(iterable)] * n))


class SVGPathMobject(VMobject, metaclass=ConvertToOpenGL):
    def __init__(
        self,
        path_string,
        should_subdivide_sharp_curves=False,
        should_remove_null_curves=False,
        long_lines=True,
        **kwargs
    ):
        self.path_string = path_string
        if config.renderer == "opengl":
            kwargs["long_lines"] = True
        super().__init__(**kwargs)
        self.current_path_start = np.zeros((1, self.dim))

    def get_path_commands(self):
        """Returns a list of possible path commands used within an SVG ``d``
        attribute.

        See: https://svgwg.org/svg2-draft/paths.html#DProperty for further
        details on what each path command does.

        Returns
        -------
        List[:class:`str`]
            The various upper and lower cased path commands.
        """
        result = [
            "M",  # moveto
            "L",  # lineto
            "H",  # horizontal lineto

Review comment (suggestion):
I think these should be removed and just only passed by `SVGMobject` if the renderer is opengl, particularly since now these are just being consumed without being forwarded on

Code after:
    num_string = num_string.replace("-", ",-")
    num_string = num_string.replace("e,-", "e-")
    float_results = []
    for s in re.split("[ ,]", num_string):
        if s != "":
            try:
                float_results.append(float(s))
            except ValueError:
                # in this case, it's something like "2.4.3.14 which should be parsed as "2.4 0.3 0.14"
                undotted_parts = s.split(".")
                float_results.append(undotted_parts[0] + "." + undotted_parts[1])
                float_results += ["." + u for u in undotted_parts[2:]]
    return float_results


def grouped(iterable, n):
    """Group iterable into arrays of n items."""
    return (np.array(v) for v in zip(*[iter(iterable)] * n))


class SVGPathMobject(VMobject, metaclass=ConvertToOpenGL):
    def __init__(self, path_string, **kwargs):
        self.path_string = path_string
        if config.renderer == "opengl":
            kwargs["long_lines"] = True
        super().__init__(**kwargs)
        self.current_path_start = np.zeros((1, self.dim))

    def get_path_commands(self):
        """Returns a list of possible path commands used within an SVG ``d``
        attribute.

        See: https://svgwg.org/svg2-draft/paths.html#DProperty for further
        details on what each path command does.

        Returns
        -------
        List[:class:`str`]
            The various upper and lower cased path commands.
        """
        result = [
            "M",  # moveto
            "L",  # lineto
            "H",  # horizontal lineto
            "V",  # vertical lineto
            "C",  # curveto
            "S",  # smooth curveto
            "Q",  # quadratic Bezier curve
            "T",  # smooth quadratic Bezier curveto
            "A",  # elliptical Arc
            "Z",  # closepath