-
Notifications
You must be signed in to change notification settings - Fork 17
/
conftest.py
43 lines (31 loc) · 1002 Bytes
/
conftest.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
37
38
39
40
41
42
43
"""
Configure pytest.
"""
import numpy as np
import pytest
try:
import ray # noqa: F401
except ImportError:
have_ray = False
else:
have_ray = True
ray.init(num_cpus=1) # call required to be here: see ray-project/ray#44087
import jax.numpy as jnp
import scico.numpy as snp
def pytest_sessionstart(session):
"""Initialize before start of test session."""
# placeholder: currently unused
def pytest_sessionfinish(session, exitstatus):
"""Clean up after end of test session."""
if have_ray:
ray.shutdown()
@pytest.fixture(autouse=True)
def add_modules(doctest_namespace):
"""Add common modules for use in docstring examples.
Necessary because `np` is used in doc strings for jax functions
(e.g. `linear_transpose`) that get pulled into `scico/__init__.py`.
Also allow `snp` and `jnp` to be used without explicitly importing.
"""
doctest_namespace["np"] = np
doctest_namespace["snp"] = snp
doctest_namespace["jnp"] = jnp