Repository: ManimCommunity/manim

Issue:
Fail to use LinearTransformationScene by division by zero
## Description of bug / unexpected behavior
When I use the (even empty) LinearTransformationScene, division by zero occurs.
Use ManimCommunity today's head. python3.7.5, poetry 1.1.4

The reason is 
manum/mobject/coordinate_systems.py:315, the 4th argument,

`   self.faded_line_ratio
`

is 0. Because of the manim/scene/vector_space_scene.py:5498 overwrites with 0 in the CONFIG of LinearTransformationScene.

Fix: set manim/scene/vector_space_scene.py:549 to

` "faded_line_ratio": 1,`

instead of 

` "faded_line_ratio": 0, # this causes division by zero`

generates an expected result. But I am not sure this is the correct way to fix.
Could anyone give me an advice?
Also I am new here and if this is not the right place to ask bugfix, please advise me.
Thanks a lot!
Hitoshi

## Expected behavior
<!-- Add a clear and concise description of what you expected to happen. -->
Render a LinearTransformationScene (grid).

## How to reproduce the issue
<!-- Provide a piece of code illustrating the undesired behavior. -->

<details><summary>Code for reproducing the problem</summary>

```python
from manim import *
class TestScene(LinearTransformationScene):
    def construct(self):
        self.wait(5)
```

</details>


## Additional media files
<!-- Paste in the files manim produced on rendering the code above. Note that GitHub doesn't allow posting videos, so you may need to convert it to a GIF or use the `-i` rendering option. -->

No image produced by an error.

<details><summary>Images/GIFs</summary>

<!-- PASTE MEDIA HERE -->

</details>


## Logs
<details><summary>Terminal output</summary>
<!-- Add "-v DEBUG" when calling manim to generate more detailed logs -->

```
(manimce-s9WNd35N-py3.7) hitoshi@kubuntu1604[29]bash % python3 -m manim 00_linear.py  -p  -ql



Traceback (most recent call last):
  File "/home/hitoshi/data/gitdata/manim/community/manim/manim/__main__.py", line 84, in main
    scene.render()
  File "/home/hitoshi/data/gitdata/manim/community/manim/manim/scene/scene.py", line 88, in render
    self.setup()
  File "/home/hitoshi/data/gitdata/manim/community/manim/manim/scene/vector_space_scene.py", line 572, in setup
    self.plane = NumberPlane(**self.foreground_plane_kwargs)
  File "/home/hitoshi/data/gitdata/manim/community/manim/manim/mobject/coordinate_systems.py", line 277, in __init__
    self.init_background_lines()
  File "/home/hitoshi/data/gitdata/manim/community/manim/manim/mobject/coordinate_systems.py", line 290, in init_background_lines
    self.background_lines, self.faded_lines = self.get_lines()
  File "/home/hitoshi/data/gitdata/manim/community/manim/manim/mobject/coordinate_systems.py", line 319, in get_lines
    self.faded_line_ratio,
  File "/home/hitoshi/data/gitdata/manim/community/manim/manim/mobject/coordinate_systems.py", line 357, in get_lines_parallel_to_axis
    step = (1 / dense_freq) * freq
ZeroDivisionError: division by zero

```

<!-- Insert screenshots here (only when absolutely necessary, we prefer copy/pasted output!) -->

</details>


## System specifications

<details><summary>System Details</summary>

- OS (Linux Kubuntu 18.04):
- RAM: 8G
- Python version (`Python 3.7.5):
- Installed modules (provide output from `pip list`):
```
Package                       Version
----------------------------- ----------
alabaster                     0.7.12
appdirs                       1.4.4
astroid                       2.4.2
attrs                         20.3.0
Babel                         2.9.0
black                         20.8b1
cairocffi                     1.2.0
certifi                       2020.11.8
cffi                          1.14.4
chardet                       3.0.4
click                         7.1.2
colorama                      0.4.4
colour                        0.1.5
commonmark                    0.9.1
cycler                        0.10.0
docutils                      0.16
guzzle-sphinx-theme           0.7.11
idna                          2.10
imagesize                     1.2.0
importlib-metadata            3.1.0
iniconfig                     1.1.1
isort                         5.6.4
Jinja2                        2.11.2
kiwisolver                    1.3.1
lazy-object-proxy             1.4.3
manimce                       0.1.0
MarkupSafe                    1.1.1
matplotlib                    3.3.3
mccabe                        0.6.1
mypy-extensions               0.4.3
numpy                         1.19.4
packaging                     20.4
pangocairocffi                0.4.0
pangocffi                     0.8.0
pathspec                      0.8.1
Pillow                        8.0.1
pip                           20.2.2
pluggy                        0.13.1
progressbar                   2.5
py                            1.9.0
pycairo                       1.20.0
pycparser                     2.20
pydub                         0.24.1
Pygments                      2.7.2
pylint                        2.6.0
pyparsing                     2.4.7
pytest                        6.1.2
python-dateutil               2.8.1
pytz                          2020.4
recommonmark                  0.6.0
regex                         2020.11.13
requests                      2.25.0
rich                          6.2.0
scipy                         1.5.4
setuptools                    49.6.0
six                           1.15.0
snowballstemmer               2.0.0
Sphinx                        3.3.1
sphinxcontrib-applehelp       1.0.2
sphinxcontrib-devhelp         1.0.2
sphinxcontrib-htmlhelp        1.0.3
sphinxcontrib-jsmath          1.0.1
sphinxcontrib-qthelp          1.0.3
sphinxcontrib-serializinghtml 1.1.4
toml                          0.10.2
tqdm                          4.54.0
typed-ast                     1.4.1
typing-extensions             3.7.4.3
urllib3                       1.26.2
wheel                         0.35.1
wrapt                         1.12.1
zipp                          3.4.0
```

</details>

<details><summary>LaTeX details</summary>

+ LaTeX distribution (e.g. TeX Live 2020):
+ Installed LaTeX packages:
<!-- output of `tlmgr list --only-installed` for TeX Live or a screenshot of the Packages page for MikTeX -->
No output
</details>

<details><summary>FFMPEG</summary>

Output of `ffmpeg -version`:

```
No output
```
</details>

## Additional comments
<!-- Add further context that you think might be relevant for this issue here. -->



Discussion:
Hi @yamauchih and thanks for reporting this! 

Can you please post the output of your script (the one containing just the call to `self.wait(5)`) when you make the proposed change from 0 to 1?

Also, @cobordism, since we are getting rid of CONFIG and the problem here seems to be a faulty CONFIG key, could you please check whether we have the same problem on the remove-CONFIG branch?
Thanks for taking care of this. Here is the output.
1. When the CONFIG in class LinearTransformationScene,
"faded_line_ratio": 0,

```
(manimce-s9WNd35N-py3.7) hitoshi@[13]bash % python3 -m manim 00_linear.py -p -ql



Traceback (most recent call last):
  File "/home/hitoshi/data/gitdata/manim/community/manim/manim/__main__.py", line 84, in main
    scene.render()
  File "/home/hitoshi/data/gitdata/manim/community/manim/manim/scene/scene.py", line 88, in render
    self.setup()
  File "/home/hitoshi/data/gitdata/manim/community/manim/manim/scene/vector_space_scene.py", line 572, in setup
    self.plane = NumberPlane(**self.foreground_plane_kwargs)
  File "/home/hitoshi/data/gitdata/manim/community/manim/manim/mobject/coordinate_systems.py", line 277, in __init__
    self.init_background_lines()
  File "/home/hitoshi/data/gitdata/manim/community/manim/manim/mobject/coordinate_systems.py", line 290, in init_background_lines
    self.background_lines, self.faded_lines = self.get_lines()
  File "/home/hitoshi/data/gitdata/manim/community/manim/manim/mobject/coordinate_systems.py", line 319, in get_lines
    self.faded_line_ratio,
  File "/home/hitoshi/data/gitdata/manim/community/manim/manim/mobject/coordinate_systems.py", line 357, in get_lines_parallel_to_axis
    step = (1 / dense_freq) * freq
ZeroDivisionError: division by zero

```
2. When the CONFIG in class LinearTransformationScene,
"faded_line_ratio": 1,

```
(manimce-s9WNd35N-py3.7) hitoshi@[14]bash % python3 -m manim 00_linear.py -p -ql
[11/29/20 23:19:51] INFO     Animation 0 : Using cached data (hash :                                  caching.py:41
                             3070002022_2874490763_2253047108)                                                     
[11/29/20 23:19:53] INFO                                                                   scene_file_writer.py:562
                             File ready at /home/hitoshi/data/gitdata/ka_video/math/202011                         
                             18_bayes_manim/media/videos/00_linear/480p15/TestScene.mp4                            
                                                                                                                   
                    INFO     Rendered TestScene                                                         scene.py:96
                             Played 1 animations             

```

Thanks! I meant if you could please show us the video or image that you get in the second instance (with faded_line_ratio=1) :slightly_smiling_face: Does it show what you expect it to show? Have you been able to otherwise use LinearTransformationScene with no changes other than setting faded_line_ratio to 1?
Yes, when faded_line_ratio=1, the result is expected (when faded_line_ratio=0, no result due to the error.) Here is the output image (this time: python3 -m manim 00_linear.py  -pi -ql, use -i option to get a gif image.)


![TestScene](https://user-images.githubusercontent.com/2727324/100603903-0e706780-3306-11eb-84e6-e7001d667d93.gif)

Thank you! In that case, I think the best way to fix this is to add this modification to the ongoing PR that removes CONFIG. @cobordism 
I will add `faded_line_ratio=1` to the other PR
Hi @leotrs ,
Shall I need to do any action? I am not familiar with the process.
Thanks!

Resolving patch:
diff --git a/manim/mobject/coordinate_systems.py b/manim/mobject/coordinate_systems.py
--- a/manim/mobject/coordinate_systems.py
+++ b/manim/mobject/coordinate_systems.py
@@ -342,7 +342,7 @@ def get_lines_parallel_to_axis(
             The axis with which the lines will be perpendicular.
 
         ratio_faded_lines : :class:`float`
-            The number of faded lines between each non-faded line.
+            The ratio between the space between faded lines and the space between non-faded lines.
 
         freq : :class:`float`
             Frequency of non-faded lines (number of non-faded lines per graph unit).
@@ -353,8 +353,9 @@ def get_lines_parallel_to_axis(
             The first (i.e the non-faded lines parallel to `axis_parallel_to`) and second (i.e the faded lines parallel to `axis_parallel_to`) sets of lines, respectively.
         """
         line = Line(axis_parallel_to.get_start(), axis_parallel_to.get_end())
-        dense_freq = ratio_faded_lines
-        step = (1 / dense_freq) * freq
+        if ratio_faded_lines == 0:  # don't show faded lines
+            ratio_faded_lines = 1  # i.e. set ratio to 1
+        step = (1 / ratio_faded_lines) * freq
         lines1 = VGroup()
         lines2 = VGroup()
         unit_vector_axis_perp_to = axis_perpendicular_to.get_unit_vector()
diff --git a/manim/scene/vector_space_scene.py b/manim/scene/vector_space_scene.py
--- a/manim/scene/vector_space_scene.py
+++ b/manim/scene/vector_space_scene.py
@@ -546,7 +546,7 @@ def __init__(self, **kwargs):
             "x_min": -config["frame_width"] / 2,
             "y_max": config["frame_width"] / 2,
             "y_min": -config["frame_width"] / 2,
-            "faded_line_ratio": 0,
+            "faded_line_ratio": 1,
         }
 
     def setup(self):


Test patch: