-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add all prebuilt libraries and lua files
- Loading branch information
Showing
340 changed files
with
48,166 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
local doc = {} | ||
|
||
function doc.record() | ||
doc.__record = {} | ||
end | ||
|
||
function doc.stop() | ||
local md = table.concat(doc.__record) | ||
doc.__record = nil | ||
return md | ||
end | ||
|
||
function doc.doc(str) | ||
if doc.__record then | ||
table.insert(doc.__record, str) | ||
end | ||
end | ||
|
||
setmetatable(doc, {__call= | ||
function(self, ...) | ||
return self.doc(...) | ||
end}) | ||
|
||
return doc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
local doc = require 'argcheck.doc' | ||
|
||
local ffi = require 'ffi' | ||
|
||
doc.__noop = ffi.new('int*') | ||
ffi.gc(doc.__noop, | ||
function() | ||
print(doc.stop()) | ||
end) | ||
|
||
doc.record() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
local env = {} | ||
|
||
-- user configurable function | ||
function env.istype(obj, typename) | ||
local mt = getmetatable(obj) | ||
if type(mt) == 'table' then | ||
local objtype = rawget(mt, '__typename') | ||
if objtype then | ||
return objtype == typename | ||
end | ||
end | ||
return type(obj) == typename | ||
end | ||
|
||
function env.type(obj) | ||
local mt = getmetatable(obj) | ||
if type(mt) == 'table' then | ||
local objtype = rawget(mt, '__typename') | ||
if objtype then | ||
return objtype | ||
end | ||
end | ||
return type(obj) | ||
end | ||
|
||
-- torch specific | ||
if pcall(require, 'torch') then | ||
function env.istype(obj, typename) | ||
local thname = torch.typename(obj) | ||
if thname then | ||
-- __typename (see below) might be absent | ||
local match = thname:match(typename) | ||
if match and (match ~= typename or match == thname) then | ||
return true | ||
end | ||
local mt = torch.getmetatable(thname) | ||
while mt do | ||
if mt.__typename then | ||
match = mt.__typename:match(typename) | ||
if match and (match ~= typename or match == mt.__typename) then | ||
return true | ||
end | ||
end | ||
mt = getmetatable(mt) | ||
end | ||
return false | ||
end | ||
return type(obj) == typename | ||
end | ||
function env.type(obj) | ||
return torch.type(obj) | ||
end | ||
end | ||
|
||
return env |
Oops, something went wrong.