xKDR / TSFrames.jl

Timeseries in Julia
MIT License
91 stars 22 forks source link

Tables.rowcount() throws an error #109

Closed chiraganand closed 1 year ago

chiraganand commented 1 year ago

rowcount() isn't implemented but somehow it throws a non-no-method error:

julia> Tables.rowcount(TS(1:10))
ERROR: MethodError: no method matching length(::DataFrame)

whereas, this works:

julia> Tables.rowcount(TS(1:10).coredata)
10
harsharora21 commented 1 year ago

This issue is not related to TSFrames. We can reproduce this using any struct.

struct foo
a::Any
end
x=foo(:bar) # we use a symbol because length is not defined for a symbol
y=foo([1 2])

julia> Tables.rowcount(x)
ERROR: MethodError: no method matching length(::Symbol)
#truncated output

julia> Tables.rowcount(y)
2

Possible fixes:

  1. Write our own rowcount which takes TSFrame.
  2. Fix Tables.rowcount to take a restricted type instead of Any.
chiraganand commented 1 year ago

This issue is not related to TSFrames. We can reproduce this using any struct.

struct foo
a::Any
end
x=foo(:bar) # we use a symbol because length is not defined for a symbol
y=foo([1 2])

julia> Tables.rowcount(x)
ERROR: MethodError: no method matching length(::Symbol)
#truncated output

julia> Tables.rowcount(y)
2

Possible fixes:

1. Write our own rowcount which takes TSFrame.

I feel this is going to be a proper solution.

2. Fix Tables.rowcount to take a restricted type instead of Any.

Can't change Tables.rowcount as it is a generic method for any table type so implementing our own rowcount() is the only fix.