manim/tests/test_units.py
Naveen M K dcb90a8656
Format Imports using Isort (#1178)
* Format imports using Isort.
Add a check for pull requests.

Signed-off-by: Naveen M K <naveen@syrusdark.website>

* CI: update check's name
2021-04-03 13:45:12 +05:30

28 lines
949 B
Python

import numpy as np
import pytest
from manim import PI, X_AXIS, Y_AXIS, Z_AXIS, config
from manim.utils.unit import Degrees, Munits, Percent, Pixels
def test_units():
# make sure we are using the right frame geometry
assert config.pixel_width == 1920
assert np.isclose(config.frame_height, 8.0)
# Munits should be equivalent to the internal logical units
assert np.isclose(8.0 * Munits, config.frame_height)
# Pixels should convert from pixels to Munits
assert np.isclose(1920 * Pixels, config.frame_width)
# Percent should give the fractional length of the frame
assert np.isclose(50 * Percent(X_AXIS), config.frame_width / 2)
assert np.isclose(50 * Percent(Y_AXIS), config.frame_height / 2)
# The length of the Z axis is not defined
with pytest.raises(NotImplementedError):
Percent(Z_AXIS)
# Degrees should convert from degrees to radians
assert np.isclose(180 * Degrees, PI)