mirror of
https://github.com/ManimCommunity/manim.git
synced 2026-06-29 10:02:11 +00:00
* Format imports using Isort. Add a check for pull requests. Signed-off-by: Naveen M K <naveen@syrusdark.website> * CI: update check's name
28 lines
949 B
Python
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)
|