-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve Tables.istable by adding Tables.astable #348
Comments
I fully agree with the proposal of @bkamins ! I would just change how we call those scenarios. In my opinion, I would call an object that returns Hence, packages that want to follow the loose rule, can use the Tables.jl functions to fetch the data, even though the object does not comply with the Tables.jl public API. Packages that want to follow the stricter rule, just need to mention that they are expecting something compliant with the Tables.jl public API. Does it make sense or is it even more complicated? |
One good example pointed out by @bkamins is the vector of julia> pretty_table([Dict(1=>2), Dict(3=>4)])
┌────────────┐
│ Col. 1 │
├────────────┤
│ Dict(1=>2) │
│ Dict(3=>4) │
└────────────┘ DataFrames, on the other hand, parse the data as follows: julia> DataFrame([Dict(1=>2), Dict(3=>4)])
2×8 DataFrame
Row │ slots keys vals ndel count age idxfloor maxprobe
│ Array… Array… Array… Int64 Int64 UInt64 Int64 Int64
─────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
1 │ UInt8[0x00, 0x00, 0x00, 0x00, 0x… [0, 4585988768, 5056425184, 4585… [0, 5776188496, 5056425184, 4585… 0 1 1 15 0
2 │ UInt8[0x00, 0x00, 0x00, 0x00, 0x… [0, 4585988768, 5056425184, 4585… [0, 4585988768, 5056425184, 4585… 0 1 1 14 0 |
I think, if we add
|
Perfect! I think it will make easier to handle those types internally in PrettyTables.jl since now I need to check for custom table-like types if |
Btw, from PrettyTables.jl side, I think that with @bkamins proposal we will not break depending on how Tables.jl would treat vectors, matrices, and dictionaries after |
There are matrices that are tables, but AFAICT all such types implement |
@quinnj The issue that
Tables.istable
can returnfalse
and the object is still a table resurfaces often. See e.g. JuliaEarth/geospatial-data-science-with-julia#3 from today.What I propose:
Tables.istable
returnstrue
is a table; (stricter rule)For packages that want to follow the stricter rule it would be nice to add a method to e.g. Tables.table:
where
GenericTable
would be a thin wrapper for whichTables.istable
would returntrue
, and all other methods would just unwrapt
fromGenericTable
and call it.In this way packages following stricter rule could easily distinguish between general objects that are not tables and something that user explicitly asked to be a table.
The text was updated successfully, but these errors were encountered: