-
Notifications
You must be signed in to change notification settings - Fork 39
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
pretty_table should require_one_based_indexing #110
Comments
Hi @yurivish, Thanks for the tip! I will add this to avoid those problems. However, I just had an amazing idea to support offset arrays. Inside PrettyTables, I can wrap the array inside a custom type (I already do this for Tables.jl). The only functions I need to create for this new type is |
Interesting idea! Could that new type itself be an |
I do not want it to be dependent of struct GenericTable
data
offset
size
end Then we can do something like:
This code will not work, but it illustrates my idea :) |
Is there a reason too not use |
Can you please provide more details? |
I'm trying to do something similar to: julia> pretty_table(OffsetVector(1:11, -5:5))
┌────────┐
│ Col. 1 │
├────────┤
│ 7 │
│ 8 │
│ 9 │
│ 10 │
│ 11 │
│ #undef │
│ #undef │
│ #undef │
│ #undef │
│ #undef │
│ #undef │
└────────┘ but I have my own I haven't looked into the root issue (it could be from Tables.jl as I implemented the |
Hi @yurivish and @GlenHertz ! First of all, sorry for the HUGE delay. PrettyTables needed a huge rewrite in the algorithm that handles the input table internally before supporting OffsetArrays. Everything is done and we now support OffsetArrays in julia> using PrettyTables
julia> using OffsetArrays
julia> A = OffsetArray(rand(3,3), -2:0, -3:-1);
julia> pretty_table(A, show_row_number = true)
┌─────┬──────────┬──────────┬──────────┐
│ Row │ Col. -3 │ Col. -2 │ Col. -1 │
├─────┼──────────┼──────────┼──────────┤
│ -2 │ 0.332428 │ 0.698186 │ 0.251798 │
│ -1 │ 0.285071 │ 0.434293 │ 0.987304 │
│ 0 │ 0.515081 │ 0.756921 │ 0.397783 │
└─────┴──────────┴──────────┴──────────┘ |
Currently
pretty_table
prints incorrect information about arrays with offset axes.Julia has a function
Base.require_one_based_indexing
that can be used to disallow such arrays as input and throw an error instead of exhibiting undefined behavior or returning incorrect results.The text was updated successfully, but these errors were encountered: