forked from argoverse/argoverse-api
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_mayavi_utils_when_missing.py
36 lines (25 loc) · 1 KB
/
test_mayavi_utils_when_missing.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# <Copyright 2019, Argo AI, LLC. Released under the MIT license.>
"""Smokescreen unit tests to make sure our Mayavi utility functions work."""
try:
import mayavi.mlab
MISSING_MAYAVI = False
except ImportError:
MISSING_MAYAVI = True
import pathlib
import numpy as np
import pytest
from argoverse.utils import mayavi_wrapper
_TEST_DIR = pathlib.Path(__file__).parent.parent / "tests"
skip_if_mayavi = pytest.mark.skipif(not MISSING_MAYAVI, reason="mayavi installed")
@skip_if_mayavi
def test_raises_when_we_try_to_use_a_missing_mayavi() -> None:
n_mer, n_long = 6, 11
pi = np.pi
dphi = pi / 1000.0
phi = np.arange(0.0, 2 * pi + 0.5 * dphi, dphi)
mu = phi * n_mer
x = np.cos(mu) * (1 + np.cos(n_long * mu / n_mer) * 0.5)
y = np.sin(mu) * (1 + np.cos(n_long * mu / n_mer) * 0.5)
z = np.sin(n_long * mu / n_mer) * 0.5
with pytest.raises(mayavi_wrapper.NoMayaviAvailableError):
mayavi_wrapper.mlab.plot3d(x, y, z, np.sin(mu), tube_radius=0.025, colormap="Spectral")