JuliaDynamics/DelayEmbeddings.jl

Return type of one-dimensional Datasets slices

heliosdrm opened this issue · 2 comments

In other places (e.g in JuliaDynamics/RecurrenceAnalysis.jl#106) we have been discussing why multi-dimensional time series should be using the Dataset type instead of AbstractMatrix.

I think that one of the selling points of Dataset is that it can be used to iterate over the multi-dimensional points just as it is done with vectors, e.g. if you have a series of 3-dimensional points, you can have them in a dataset data and iterate over those points just with for x in data. On the other hand, with AbstractMatrices you have to take into account if the points are organized in rows or columns, and then do for x in eachrow(data) etc.

However that argument would be stronger if one-dimensional slices like data[1:10] also returned a Dataset. As it is now, that returns a vector of SArray, and the straightforward way of slicing Datasets is with matrix-like indexing, i.e. data[1:10, :]. This is not good for generic code that would like to manage Datasets more or less like Vectors. (v[1:10, :] for vectors returns a matrix!)

Would it be sensible to rewrite the method Base.getindex(d::AbstractDataset, r::AbstractRange) to achieve that, or would it be too breaking?


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Yeap this is breaking but regardless I completely I agree with the suggestion. This is just a bad coding practice from back in the day where I was quite inexperienced (Dataset was one of the very first things coded in DynamicalSystems.jl).

Since I'm anyways heading towards DynamicalSystems.jl 2.0, I have no problem to do this change.

I also agree with this change for 2.0. More consistent behaviour is better!