Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/torch/argcheck.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSoumith Chintala <soumith@gmail.com>2016-05-11 06:38:36 +0300
committerSoumith Chintala <soumith@gmail.com>2016-05-11 06:38:36 +0300
commit91344af90e67aac0af170c1344b339c5b82dc807 (patch)
tree85cec92da254fa8d775a029d684b06b2e88bdb44
parent9e879ae03fe8f593ef3d73bd73375f72c17c17e7 (diff)
parent4ef9eab2f4b8cf0881ee654d1864adbd0febb64d (diff)
Merge pull request #10 from jbarbero/fix-colors-patch
fix argcheck function to encapsulate its local variables
-rw-r--r--graph.lua2
-rw-r--r--test/test.lua10
2 files changed, 11 insertions, 1 deletions
diff --git a/graph.lua b/graph.lua
index 7d839fb..b813e7c 100644
--- a/graph.lua
+++ b/graph.lua
@@ -365,8 +365,8 @@ end
function ACN:generate(upvalues)
assert(upvalues, 'upvalues table missing')
local code = {}
- table.insert(code, 'local usage = require "argcheck.usage"')
table.insert(code, 'return function(...)')
+ table.insert(code, ' local usage = require "argcheck.usage"')
table.insert(code, ' local narg = select("#", ...)')
self:generate_ordered_or_named(code, upvalues, 'O')
diff --git a/test/test.lua b/test/test.lua
index b3778bc..1a5e9e2 100644
--- a/test/test.lua
+++ b/test/test.lua
@@ -333,6 +333,16 @@ if pcall(require, 'torch') then
assert(env.istype(t, '.*Long') == true)
assert(env.istype(t, 'torch.IntTensor') == false)
assert(env.istype(t, 'torch.Long') == false)
+
+ -- test argcheck function serialization
+ local f = argcheck{
+ {name='arg', type='string'},
+ call = function(arg)
+ print(arg)
+ end
+ }
+ local m = torch.MemoryFile()
+ m:writeObject(f)
end
print('PASSED')