Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions tests/update_mask_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import typing
import pytest
import torch
from grassmann_tensor import GrassmannTensor

Initialization = tuple[tuple[bool, ...], tuple[tuple[int, int], ...], torch.Tensor]


@pytest.fixture(params=[
(
(True, False),
((2, 2), (3, 1)),
torch.randn([4, 4], dtype=torch.float32),
),
(
(False, True, False),
((1, 1), (2, 2), (1, 1)),
torch.randn([2, 4, 2], dtype=torch.float32),
),
])
def x(request: typing.Any) -> Initialization:
return request.param


def test_update_mask(x: Initialization) -> None:
tensor = GrassmannTensor(*x)
updated_tensor = tensor.update_mask()
assert torch.all(updated_tensor.tensor == torch.where(updated_tensor.mask, 0, x[2]))