Skip to content

Commit

Permalink
flesh out testing - #50 (#61)
Browse files Browse the repository at this point in the history
* flesh out testing - #50

* some approximation for float precision [1]

* Update fastpair/tests/test_fastpair.py

Co-authored-by: cjqf <[email protected]>

---------

Co-authored-by: cjqf <[email protected]>
  • Loading branch information
jGaboardi and carsonfarmer authored Jul 4, 2024
1 parent 2e3a3af commit 39362e0
Show file tree
Hide file tree
Showing 4 changed files with 671 additions and 1 deletion.
31 changes: 31 additions & 0 deletions fastpair/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import numpy
import pytest


def rand_tuple(dim: int = 2, seed: None | int = None) -> tuple[float]:
rng = numpy.random.default_rng(seed)
return tuple([round(rng.uniform(), 4) for j in range(dim)])


def point_set(n: int = 50, d: int = 10, seed: int = 0) -> list[tuple[float, float]]:
"""Return ``numpy.array`` of shape ``(n, d)``."""
return [rand_tuple(dim=d, seed=seed + i) for i in range(n)]


def pytest_configure(config): # noqa: ARG001
"""PyTest session attributes, methods, etc."""

pytest.rand_tuple = rand_tuple
pytest.point_set = point_set


@pytest.fixture
def image_array():
return [
(b"\x00\x00\x07\x20\x00\x00\x03\x21\x08\x02\x00\x00\x00", "0"),
(b"\x00\x50\x07\x60\x00\x00\x03\x21\x06\x02\x00\x00\x00", "1"),
(b"\x00\x00\x07\x20\x00\x00\x03\x21\x08\x02\x00\x08\x00", "2"),
(b"\x00\x50\x07\x60\x00\x00\x03\x21\x06\x02\x00\x60\x00", "3"),
(b"\x00\x00\x07\x20\x00\x00\x03\x21\x08\x02\x00\x30\x01", "4"),
(b"\x00\x50\x07\x60\x00\x00\x03\x21\x06\x02\x00\x00\x10", "5"),
]
Loading

0 comments on commit 39362e0

Please sign in to comment.