Closed Evizero closed 7 years ago
Great, thanks! Could you add a test?
Thanks @Evizero! Your fix may be correct, but looking through the code for view
I think the whole thing might need an overhaul. Cross referencing https://github.com/JuliaData/DataTables.jl/issues/38#issuecomment-288366830, there could be several functions in DataTables where returning a copy-free view could be used in-place of copying the datatable. We should check that everything about view
works as expected, this example of view(::SubDataTable, ::Int)
included.
A few issues that jumped out at me:
SubDataTable
calls view
here, while other times view
calls SubDataTable
here, here and here, while other view
s call view
again here, here, here, and here. It might be useful to have everything call in the the same direction i.e. view
-> SubDataTable
functions to normalize inputs -> SubDataTable
constructor.view
on columns will only work if the column is a scalar/single value like a symbol or Int here, but probably should work on Vector{Bool|Int|Symbol}
too.view
is using a custom Index
that is only used by the view
calls here, here, and here. We should probably get rid of that and the associated SimpleIndex
hereview
doesn't have a full set of tests. There are 14 lines in the tests that I could find that use view
in some way, but there are several combinations of arguments that are missed.I gave these ideas a shot w/ new SubDataTable
/view
code here and tests here. If any of those changes are desirable we can merge the useful bits into this PR.
@cjprybol These further improvements make sense, but we should probably merge the simple change from this PR (with a test) since it fixes a bug, and make the larger cleanup later.
Added a test that would fail on master
Fixes issue when trying to
view(::SubDataTable, ::Int)
. I think so at least. I edited this patch on github