manim/tests/test_coordinate_system.py
hydrobeam 9e88b64cd4
Upgrades to CoordinateSystem and graphing. (#1161)
* coordinate_systems.py

* number_line.py

* functions.py

* forgot to remove logging

* remove mutables in UnitInterval and restore things that shouldn't have been factored out

* visual changes + add backup in case only two args are given to x_range

* test_axes.py test reworked

* test_axes.py add tips

* coordinate_system + systems test and minor update to .py

* test_functions and mini-rework of funtions.py

* black and graph_scene test

* add defaults for threeDaxes

* all tests pass, threed updates

* make graphscene functional

* formatting

* test_axes_shift fix

* fix the broken test_axes_shift and docs

* forgot negative in docs

* missing commas

* fix broken example in graphscene.py

* forgot comma... again

* line_projection, import cleanup, and variable cleanup

* get_tick_range all numbers

* revert examples.rst

* restore GraphScene, deprecate it, introduce OldNumberLine

* rever test_axes_shift.py

* test_graphscene_reverted

* poetry error

* test_coord_system fix (?)

* unecssary import in graphscene

* black

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix tests (?)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* add rounding for default coord_range + projection docs

* adjust test for rounding

* add zero fix

* used wrong fix

* set_length instead of rescale_to_fit

* fix improper coordinates for default NumberPlane

* update test

* adjust defaults for NumberLine and introduce dynamic scaling

* test adjusted

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* explanations + create axis docs

* parameters for NumberLine`

* NumberPlane documentation mods

* ThreeDAxes docs

* all done

* add colon for docs

* switch oldNUmberLine to NumberLineOld

* docs update for NumberLineOld

* Update manim/mobject/number_line.py

Co-authored-by: Benjamin Hackl <devel@benjamin-hackl.at>

* Update manim/mobject/number_line.py

Co-authored-by: Benjamin Hackl <devel@benjamin-hackl.at>

* Update manim/mobject/number_line.py

Co-authored-by: Benjamin Hackl <devel@benjamin-hackl.at>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* suggestions from code review

* missing period

* adjust wording for create_axis

* fix merge conflict (?)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Benjamin Hackl <devel@benjamin-hackl.at>
2021-04-30 20:40:51 +02:00

42 lines
1.3 KiB
Python

import numpy as np
import pytest
from manim import LEFT, ORIGIN, Axes, ComplexPlane
from manim import CoordinateSystem as CS
from manim import NumberPlane, ThreeDAxes, config, tempconfig
def test_initial_config():
"""Check that all attributes are defined properly from the config."""
cs = CS()
assert cs.x_range[0] == round(-config["frame_x_radius"])
assert cs.x_range[1] == round(config["frame_x_radius"])
assert cs.x_range[2] == 1.0
assert cs.y_range[0] == round(-config["frame_y_radius"])
assert cs.y_range[1] == round(config["frame_y_radius"])
assert cs.y_range[2] == 1.0
ax = Axes()
assert np.allclose(ax.get_center(), ORIGIN)
assert np.allclose(ax.y_axis_config["label_direction"], LEFT)
with tempconfig({"frame_x_radius": 100, "frame_y_radius": 200}):
cs = CS()
assert cs.x_range[0] == -100
assert cs.x_range[1] == 100
assert cs.y_range[0] == -200
assert cs.y_range[1] == 200
def test_dimension():
"""Check that objects have the correct dimension."""
assert Axes().dimension == 2
assert NumberPlane().dimension == 2
assert ComplexPlane().dimension == 2
assert ThreeDAxes().dimension == 3
def test_abstract_base_class():
"""Check that CoordinateSystem has some abstract methods."""
with pytest.raises(Exception):
CS().get_axes()