Repository: ManimCommunity/manim

Issue:
Manim Raises Zero Divison Error while writing Empty Text
## Description of bug / unexpected behavior
<!-- Add a clear and concise description of the problem you encountered. -->
Main Raises Zero Divison Error while writing Empty Text

## Expected behavior
<!-- Add a clear and concise description of what you expected to happen. -->
`Write(T)` where T is a text object should work seamlessly even if the given Text is empty. 

## How to reproduce the issue
<!-- Provide a piece of code illustrating the undesired behavior. -->
from manim import Text, Scene, Wait, config, Write

```
        # Throws exception
        text = ''
        T = Text(text)
        self.play(Write(T))
        self.play(Wait(3))
```

<details><summary>Code for reproducing the problem</summary>

```py
from manim import Text, Scene, Wait, config, Write

class Example(Scene):
    def construct(self):
        # Works well
        text = 'hello'
        T = Text(text)
        self.play(Write(T))
        self.play(Wait(3))

        # Throws exception
        text = ''
        T = Text(text)
        self.play(Write(T))
        self.play(Wait(3))

if __name__ == '__main__':
    config.preview = True
    Example().render()

```

</details>

## Logs
<details><summary>Terminal output</summary>
<!-- Add "-v DEBUG" when calling manim to generate more detailed logs -->

```
Manim Community v0.16.0.post0

[10/03/22 14:17:48] INFO     Animation 0 : Using cached     cairo_renderer.py:75
                             data (hash :                                       
                             2724823860_528071960_223132457                     
                             )                                                  
Traceback (most recent call last):
                    INFO     Animation 1 : Using cached     cairo_renderer.py:75
                             data (hash :                                       
                             1164547788_2358420384_25907343                     
                             55)                                                
  File "/Users/nehem/mega/py/p/discord.py", line 19, in <module>
    Example().render()
  File "/Users/nehem/.virtualenvs/p/lib/python3.9/site-packages/manim/scene/scene.py", line 222, in render
    self.construct()
  File "/Users/nehem/mega/py/p/discord.py", line 14, in construct
    self.play(Write(T))
  File "/Users/nehem/.virtualenvs/p/lib/python3.9/site-packages/manim/animation/creation.py", line 314, in __init__
    run_time, lag_ratio = self._set_default_config_from_length(
  File "/Users/nehem/.virtualenvs/p/lib/python3.9/site-packages/manim/animation/creation.py", line 344, in _set_default_config_from_length
    lag_ratio = min(4.0 / length, 0.2)
ZeroDivisionError: float division by zero
```


Discussion:

Resolving patch:
diff --git a/manim/animation/creation.py b/manim/animation/creation.py
--- a/manim/animation/creation.py
+++ b/manim/animation/creation.py
@@ -302,6 +302,15 @@ def construct(self):
         class ShowWriteReversed(Scene):
             def construct(self):
                 self.play(Write(Text("Hello", font_size=144), reverse=True))
+
+    Tests
+    -----
+
+    Check that creating empty :class:`.Write` animations works::
+
+        >>> from manim import Write, Text
+        >>> Write(Text(''))
+        Write(Text(''))
     """
 
     def __init__(
@@ -343,7 +352,7 @@ def _set_default_config_from_length(
             else:
                 run_time = 2
         if lag_ratio is None:
-            lag_ratio = min(4.0 / length, 0.2)
+            lag_ratio = min(4.0 / max(1.0, length), 0.2)
         return run_time, lag_ratio
 
     def reverse_submobjects(self) -> None:


Test patch: