-
Notifications
You must be signed in to change notification settings - Fork 367
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
Juno Display #1121
Juno Display #1121
Changes from all commits
78a47b4
713b84f
2426b7e
4b69825
45533bf
9b9ae7c
29abf67
3c30038
83249d7
2e673d0
69c1578
e98d4c3
978af28
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ SortingAlgorithms | |
Reexport | ||
Compat 0.8.4 | ||
FileIO 0.1.2 | ||
Juno 0.2.4 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -579,3 +579,28 @@ function showcols(io::IO, df::AbstractDataFrame) # -> Void | |
end | ||
|
||
showcols(df::AbstractDataFrame) = showcols(STDOUT, df) # -> Void | ||
|
||
using Juno | ||
using Juno: Inline, LazyTree, Table, Row, strong | ||
|
||
const SIZE = 25 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't you want to allow users to tweak this somewhere in Juno? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Possibly, but we'd have to implement a Juno.jl API for that. I think a better approach would be to extend this view to be capable of showing the entire dataframe at once. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK. Though showing the full data frame could be quite problematic if it contains one million rows and one hundred columns. Better take a subset first. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not if we lazy-load it as needed |
||
|
||
function to_matrix(df::AbstractDataFrame) | ||
res = Array{Any}(size(df)) | ||
for (j, col) in enumerate(columns(df)), i = 1:length(col) | ||
isassigned(col, i) && (res[i, j] = col[i]) | ||
end | ||
return res | ||
end | ||
|
||
function _render(df::AbstractDataFrame) | ||
width = min(size(df, 2), SIZE) | ||
height = min(size(df, 1), SIZE) | ||
header = map(x->strong(string(x)), names(df)[1:width]') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. julia> [:foo, :bar]'
WARNING: the no-op `transpose` fallback is deprecated, and no more specific `transpose` method for Symbol exists. Consider `permutedims(x, [2, 1])` or writing a specific `transpose(x::Symbol)` method if appropriate.
1×2 Array{Symbol,2}:
:foo :bar This seems like broken behaviour on Julia's part – I can only transpose arrays of transposable objects? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Transpose is recursive. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. transpose is a linear algebraic operation, and recursive on elements There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see where the error is coming from, but the ultimate behaviour – arrays of Xs are transposable but arrays of Ys are not – seems pretty arbitrary to me. What makes a number transposable, other than as a hack to get array transpose to work? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
body = Juno.undefs(to_matrix(df))[1:height, 1:width] | ||
view = Table(vcat(header, body)) | ||
LazyTree(Row(typeof(df), text" ", Juno.dims(size(df)...)), | ||
() -> [view]) | ||
end | ||
|
||
@render Inline df::AbstractDataFrame _render(df) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not needed, redundant with following line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using
will import all of the symbols exported from Juno, butusing Juno: stuff
gets specific, potentially unexported symbols, so it's not entirely redundant, right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah right. only other thing that should be needed that isn't listed yet is
@render
, so adding that could replace the first line.Mike, please communicate in sentences, single word responses (and commit messages) are not an effective way of justifying anything.