When changing to tds as a data backend for the torch-dataframe I noticed that the sort for tds.Vec fails in LUA52 & LUA53‡ environments with the error:
unable to convert argument 2 from cdata<int ()(struct tdselem, struct tdselem)> to cdata<int ()(const struct tdselem, const struct tdselem)>
stack traceback:
/opt/torch/install/share/lua/5.2/trepl/init.lua:501: in function </opt/torch/install/share/lua/5.2/trepl/init.lua:494>
[C]: in function 'tds_vec_sort'
/opt/torch/install/share/lua/5.2/tds/vec.lua:98: in function 'sort'
[string "_RESULT={b:sort(function(a,b) return a < b en..."]:1: in main chunk
[C]: in function 'xpcall'
/opt/torch/install/share/lua/5.2/trepl/init.lua:652: in function 'repl'
/opt/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:199: in main chunk
[C]: in ?
Here's code that runs fine in standard LUAJIT:
th> tds = require 'tds'
[0.0014s]
th> a = tds.Vec("ba", "ab", "c", "AA")
[0.0001s]
th> a:sort(function(a, b) return string.lower(a) < string.lower(b) end)
[0.0001s]
th> a
tds.Vec[4]{
1 : AA
2 : ab
3 : ba
4 : c
}
[0.0001s]
th> a:sort(function(a, b) return a:lower() < b:lower() end)
[0.0001s]
th> a
tds.Vec[4]{
1 : AA
2 : ab
3 : ba
4 : c
}
[0.0001s]
th> a:sort(function(a, b) return a:lower() > b:lower() end)
[0.0003s]
th> a
tds.Vec[4]{
1 : c
2 : ba
3 : ab
4 : AA
}
[0.0001s]
th> b = tds.Vec({2,1,3,0})
[0.0001s]
th> b:sort(function(a,b) return a < b end)
[0.0001s]
th> b
tds.Vec[4]{
1 : 0
2 : 1
3 : 2
4 : 3
}
The same code in a LUA52 Docker container results in:
...
th> a:sort(function(a, b) return a:lower() > b:lower() end)
unable to convert argument 2 from cdata<int (*)(struct tds_elem_*, struct tds_elem_*)> to cdata<int (*)(const struct tds_elem_*, const struct tds_elem_*)>
stack traceback:
/opt/torch/install/share/lua/5.2/trepl/init.lua:501: in function </opt/torch/install/share/lua/5.2/trepl/init.lua:494>
[C]: in function 'tds_vec_sort'
/opt/torch/install/share/lua/5.2/tds/vec.lua:98: in function 'sort'
[string "_RESULT={a:sort(function(a, b) return a:lower..."]:1: in main chunk
[C]: in function 'xpcall'
/opt/torch/install/share/lua/5.2/trepl/init.lua:652: in function 'repl'
/opt/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:199: in main chunk
[C]: in ?
[0.0005s]
...
th> b:sort(function(a,b) return a < b end)
unable to convert argument 2 from cdata<int (*)(struct tds_elem_*, struct tds_elem_*)> to cdata<int (*)(const struct tds_elem_*, const struct tds_elem_*)>
stack traceback:
/opt/torch/install/share/lua/5.2/trepl/init.lua:501: in function </opt/torch/install/share/lua/5.2/trepl/init.lua:494>
[C]: in function 'tds_vec_sort'
/opt/torch/install/share/lua/5.2/tds/vec.lua:98: in function 'sort'
[string "_RESULT={b:sort(function(a,b) return a < b en..."]:1: in main chunk
[C]: in function 'xpcall'
/opt/torch/install/share/lua/5.2/trepl/init.lua:652: in function 'repl'
/opt/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:199: in main chunk
[C]: in ?
‡ probably also allpies to LUA51 but this hasn't been tested as we've dropped 51 support
When changing to
tds
as a data backend for the torch-dataframe I noticed that thesort
fortds.Vec
fails in LUA52 & LUA53‡ environments with the error:Here's code that runs fine in standard LUAJIT:
The same code in a LUA52 Docker container results in:
‡ probably also allpies to LUA51 but this hasn't been tested as we've dropped 51 support