diff options
author | Trevor Killeen <killeentm@gmail.com> | 2017-03-10 20:31:16 +0300 |
---|---|---|
committer | Trevor Killeen <killeentm@gmail.com> | 2017-03-10 20:31:16 +0300 |
commit | 9918aad865a73b56d17f6d674ae1808612072964 (patch) | |
tree | 0bde56631d2fd8d8cc4723fab4234842a4c54118 | |
parent | d4c2b1d34631b78717289e0d219751f448d32b9c (diff) |
fix bug in testing code
-rw-r--r-- | test/test.lua | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/test/test.lua b/test/test.lua index 99acbde..57c61f6 100644 --- a/test/test.lua +++ b/test/test.lua @@ -175,13 +175,13 @@ local function createTestTensor(maxSize) end local function isEqual(x, y, tolerance, ...) - if a == nil and b == nil then return true end - if a == nil and b ~= nil then return false end - if a ~= nil and b == nil then return false end + if x == nil and y == nil then return true end + if x == nil and y ~= nil then return false end + if x ~= nil and y == nil then return false end - -- clone the tensors so we can modify the contents if necessary for testing - local a = x:clone() - local b = y:clone() + -- if x, y are tensors clone them so we can modify the contents if necessary for testing + local a = type(x) ~= 'number' and x:clone() or x + local b = type(y) ~= 'number' and y:clone() or y if torch.type(b) ~= torch.type(a) then b = b:typeAs(a) -- TODO: remove the need for this (a-b doesnt work for bytetensor, cudatensor pairs) |