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

Code before:
                )
                self.add(number_line, pointer,label)

                self.play(pointer_value.animate.set_value(0.5))
                self.wait(0.5)
                self.play(pointer_value.animate.set_value(6))
                self.wait(0.5)
                self.play(pointer_value.animate.set_value(3))
                self.wait(0.5)
                self.play(pointer_value.animate.set_value(2))
                self.wait(0.5)
    """

    def get_value(self):
        """Get the current value of the ExponentialValueTracker."""
        return np.exp(ValueTracker.get_value(self))

    def set_value(self, value):
        """Set a new scalar value to the ExponentialValueTracker. The value cannot
        be non-positive."""
        return ValueTracker.set_value(self, np.log(value))


class ComplexValueTracker(ValueTracker):
    """Operates like ValueTracker, except it encodes a complex-valued
    parameter as opposed to a real-valued parameter.

    Examples
    --------
    .. manim:: ComplexValueTrackerExample

        class ComplexValueTrackerExample(Scene):
            def construct(self):
                tracker = ComplexValueTracker(-2+1j)
                dot = Dot().add_updater(
                    lambda x: x.move_to(tracker.points)
                )

                self.add(NumberPlane(), dot)

                self.play(tracker.animate.set_value(3+2j))
                self.play(tracker.animate.set_value(tracker.get_value() * 1j))
                self.play(tracker.animate.set_value(tracker.get_value() - 2j))
                self.play(tracker.animate.set_value(tracker.get_value() / (-2 + 3j)))
    """

    def get_value(self):
        """Get the current value of the ComplexValueTracker. This value changes
        continuously when :attr:`animate` for the ComplexValueTracker is called."""
        return complex(*self.points[0, :2])


Review comment (suggestion):
```suggestion
    """Tracks a complex-valued parameter.
```

Code after:

    Examples
    --------
    .. manim:: ComplexValueTrackerExample

        class ComplexValueTrackerExample(Scene):
            def construct(self):
                tracker = ComplexValueTracker(-2+1j)
                dot = Dot().add_updater(
                    lambda x: x.move_to(tracker.points)
                )

                self.add(NumberPlane(), dot)

                self.play(tracker.animate.set_value(3+2j))
                self.play(tracker.animate.set_value(tracker.get_value() * 1j))
                self.play(tracker.animate.set_value(tracker.get_value() - 2j))
                self.play(tracker.animate.set_value(tracker.get_value() / (-2 + 3j)))
    """

    def get_value(self):
        """Get the current value of this value tracker as a complex number.

        The value is internally stored as a points array [a, b, 0]. This can be accessed directly
        to represent the value geometrically, see the usage example."""
        return complex(*self.points[0, :2])

    def set_value(self, z):
        """Sets a new complex value to the ComplexValueTracker"""
        z = complex(z)
        self.points[0, :2] = (z.real, z.imag)
        return self