| 1 |
from typing import Any, Optional |
| 2 |
import pytest |
| 3 |
import eagerpy as ep |
| 4 |
|
| 5 |
|
| 6 |
def pytest_addoption(parser: Any) -> None: |
| 7 |
parser.addoption("--backend") |
| 8 |
|
| 9 |
|
| 10 |
@pytest.fixture(scope="session") |
| 11 |
def dummy(request: Any) -> ep.Tensor: |
| 12 |
backend: Optional[str] = request.config.option.backend |
| 13 |
if backend is None: |
| 14 |
pytest.skip() |
| 15 |
assert False |
| 16 |
return ep.utils.get_dummy(backend) |
| 17 |
|
| 18 |
|
| 19 |
@pytest.fixture(scope="session") |
| 20 |
def t1(dummy: ep.Tensor) -> ep.Tensor: |
| 21 |
return ep.arange(dummy, 5).float32() |
| 22 |
|
| 23 |
|
| 24 |
@pytest.fixture(scope="session") |
| 25 |
def t1int(dummy: ep.Tensor) -> ep.Tensor: |
| 26 |
return ep.arange(dummy, 5) |
| 27 |
|
| 28 |
|
| 29 |
@pytest.fixture(scope="session") |
| 30 |
def t2(dummy: ep.Tensor) -> ep.Tensor: |
| 31 |
return ep.arange(dummy, 7, 17, 2).float32() |
| 32 |
|
| 33 |
|
| 34 |
@pytest.fixture(scope="session") |
| 35 |
def t2int(dummy: ep.Tensor) -> ep.Tensor: |
| 36 |
return ep.arange(dummy, 7, 17, 2) |
| 37 |
|
| 38 |
|
| 39 |
@pytest.fixture(scope="session", params=["t1", "t2"]) |
| 40 |
def t(request: Any, t1: ep.Tensor, t2: ep.Tensor) -> ep.Tensor: |
| 41 |
return {"t1": t1, "t2": t2}[request.param] |