Closed gforge closed 8 years ago
Cool idea !
Though I am not sure about returning a Dataframe for a single row and with a string as argument. Generally when I use __index
equivalent in other languages is to directly have the raw data.
About size
returning a tensor seems the best option, there is still the shape
function anyway.
__eq
meta function could be useful for tests purpose.
I think it would be nice to add some torch class metatable functionality in addition to the
__tostring__
. The available methods according to the docs are:__index__
Single number
Calling
__index__
with a number should naturally return a single row. The return object should be a dataframe and either we change the currentget_row
to use the_create_subset
or we call that directly.A table or tensor with integers
This should probably work just as the
_create_subset
A string value
I'm not sure if it is a good idea but a string value could result in
get_column
since columns are always strings.__newindex__
Single number
A simple call to
_update_single_row
after asserting that the index exists.If index is
self.n_rows + 1
theninsert
should be invoked.String
If column exists it should
drop
the column if argument isnil
otherwise throw an error.If string is non-existant it should call the
add_column
__len__
Returns the
self.n_rows
size
Should return
shape()["rows"]
when called withsize(1)
andshape()["cols"]
when called withsize(2)
. Empty string returns unnamed table with{no_rows, no_cols}
, possibly it should return a tensor for sticking with the Torch spiritcopy
A call to
clone
and_copy_meta
should do it.