Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
9 changes: 5 additions & 4 deletions test/test_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,14 +328,15 @@ def test_pad_raises_with_invalid_pad_sequence_len(self):
transforms.Pad((1, 2, 3, 4, 5))

def test_lambda(self):
trans = transforms.Lambda(lambda x: x.add(10))
trans = transforms.Lambda(lambda x, a: (x.add(10), a))
x = torch.randn(10)
y = trans(x)
a = []
y, a = trans(x, a)
assert (y.equal(torch.add(x, 10)))

trans = transforms.Lambda(lambda x: x.add_(10))
trans = transforms.Lambda(lambda x, a: (x.add_(10), a))
x = torch.randn(10)
y = trans(x)
y, a = trans(x, a)
assert (y.equal(x))

# Checking if Lambda can be printed as string
Expand Down
Loading