Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
0x00b1 committed Jun 4, 2024
1 parent 167861d commit cda97b9
Show file tree
Hide file tree
Showing 6 changed files with 165 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/beignet/datasets/_random_rotation_matrix_dataset.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from typing import Callable, Generator

import torch
from torch.utils.data import Dataset

import beignet
from beignet.datasets.__random_rotation_dataset import RandomRotationDataset
from beignet.transforms import Transform


class RandomRotationMatrixDataset(Dataset):
class RandomRotationMatrixDataset(RandomRotationDataset):
def __init__(
self,
size: int,
Expand Down
4 changes: 2 additions & 2 deletions src/beignet/datasets/_random_rotation_vector_dataset.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from typing import Callable, Generator

import torch
from torch.utils.data import Dataset

import beignet
from beignet.datasets.__random_rotation_dataset import RandomRotationDataset
from beignet.transforms import Transform


class RandomRotationVectorDataset(Dataset):
class RandomRotationVectorDataset(RandomRotationDataset):
def __init__(
self,
size: int,
Expand Down
58 changes: 56 additions & 2 deletions tests/beignet/datasets/test__random_euler_angle_dataset.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,57 @@
import beignet
import hypothesis.strategies
from beignet.datasets import RandomEulerAngleDataset


@hypothesis.strategies.composite
def _strategy(function):
size = function(
hypothesis.strategies.integers(
min_value=1,
max_value=8,
),
)

axes = function(
hypothesis.strategies.sampled_from(
[
"xyz",
"xzy",
"yxz",
"yzx",
"zxy",
"zyx",
"XYZ",
"XZY",
"YXZ",
"YZX",
"ZXY",
"ZYX",
]
),
)

degrees = function(hypothesis.strategies.booleans())

return (
{
"size": size,
"axes": axes,
"degrees": degrees,
},
beignet.random_euler_angle(size, axes=axes, degrees=degrees),
)


class TestRandomEulerAngleDataset:
def test___init__(self):
assert True
@hypothesis.given(_strategy())
def test___init__(self, data):
parameters, output = data

dataset = RandomEulerAngleDataset(**parameters)

assert dataset.data.shape == output.shape

assert dataset.data.dtype == output.dtype

assert dataset.data.layout == output.layout
38 changes: 36 additions & 2 deletions tests/beignet/datasets/test__random_quaternion_dataset.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
import beignet
import hypothesis.strategies
from beignet.datasets import RandomQuaternionDataset


@hypothesis.strategies.composite
def _strategy(function):
size = function(
hypothesis.strategies.integers(
min_value=1,
max_value=8,
),
)

canonical = function(hypothesis.strategies.booleans())

return (
{
"size": size,
"canonical": canonical,
},
beignet.random_quaternion(size, canonical=canonical),
)


class TestRandomQuaternionDataset:
def test___init__(self):
assert True
@hypothesis.given(_strategy())
def test___init__(self, data):
parameters, output = data

dataset = RandomQuaternionDataset(**parameters)

assert dataset.data.shape == output.shape

assert dataset.data.dtype == output.dtype

assert dataset.data.layout == output.layout
35 changes: 33 additions & 2 deletions tests/beignet/datasets/test__random_rotation_matrix_dataset.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
import beignet
import hypothesis.strategies
from beignet.datasets import RandomRotationMatrixDataset


@hypothesis.strategies.composite
def _strategy(function):
size = function(
hypothesis.strategies.integers(
min_value=1,
max_value=8,
),
)

return (
{
"size": size,
},
beignet.random_rotation_matrix(size),
)


class TestRandomRotationMatrixDataset:
def test___init__(self):
assert True
@hypothesis.given(_strategy())
def test___init__(self, data):
parameters, output = data

dataset = RandomRotationMatrixDataset(**parameters)

assert dataset.data.shape == output.shape

assert dataset.data.dtype == output.dtype

assert dataset.data.layout == output.layout
38 changes: 36 additions & 2 deletions tests/beignet/datasets/test__random_rotation_vector_dataset.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
import beignet
import hypothesis.strategies
from beignet.datasets import RandomRotationVectorDataset


@hypothesis.strategies.composite
def _strategy(function):
size = function(
hypothesis.strategies.integers(
min_value=1,
max_value=8,
),
)

degrees = function(hypothesis.strategies.booleans())

return (
{
"size": size,
"degrees": degrees,
},
beignet.random_rotation_vector(size, degrees=degrees),
)


class TestRandomRotationVectorDataset:
def test___init__(self):
assert True
@hypothesis.given(_strategy())
def test___init__(self, data):
parameters, output = data

dataset = RandomRotationVectorDataset(**parameters)

assert dataset.data.shape == output.shape

assert dataset.data.dtype == output.dtype

assert dataset.data.layout == output.layout

0 comments on commit cda97b9

Please sign in to comment.