| from __future__ import annotations |
|
|
| import numpy as np |
| import pytest |
|
|
| from manim import PI, X_AXIS, Y_AXIS, Z_AXIS |
| from manim.utils.unit import Degrees, Munits, Percent, Pixels |
|
|
|
|
| def test_units(config): |
| |
| config.pixel_width = 1920 |
|
|
| np.testing.assert_allclose(config.frame_height, 8.0) |
|
|
| |
| np.testing.assert_allclose(8.0 * Munits, config.frame_height) |
|
|
| |
| np.testing.assert_allclose(1920 * Pixels, config.frame_width) |
|
|
| |
| np.testing.assert_allclose(50 * Percent(X_AXIS), config.frame_width / 2) |
| np.testing.assert_allclose(50 * Percent(Y_AXIS), config.frame_height / 2) |
|
|
| |
| with pytest.raises(NotImplementedError): |
| Percent(Z_AXIS) |
|
|
| |
| np.testing.assert_allclose(180 * Degrees, PI) |
|
|