torch / tds

Torch C data structures
Other
80 stars 25 forks source link

the example is error #8

Closed lywaterman closed 8 years ago

lywaterman commented 8 years ago

tds = require 'tds' require 'torch'

-- create a vector containing heterogeneous data d = tds.Vec(4, 5, torch.rand(3), nil, "hello world")

-- serialize in a buffer f = torch.MemoryFile("rw") f:writeObject(d)

-- unserialize f:seek(1) print(f:readObject())

this will break when i run it with luajit 2.1 beta1, but if i remove the nil in the Vec, this will be ok

soumith commented 8 years ago

I just tested this on OSX with LuaJIT 2.1.0-beta1 and it seems to work fine. What OS did you test this on?

deltheil commented 8 years ago

I do reproduce the problem (on Linux):

tds/vec.lua:118: lua table with number keys (1...N) expected

@soumith it looks like it's a regression that has been introduced at commit 65cce40, i.e. the is-a-sequence detection introduced does not work when the list of input args has a hole (a nil element somewhere). Prior to this commit the iteration over input args did the job.

So either we fix the example in the README or find a way to support again this kind of construct. What do you think?

lywaterman commented 8 years ago

i test it on ubuntu 12.04

soumith commented 8 years ago

fixed now in master. thanks to Ronan.