Convert the one and two argument show methods to MIME"text/plain" methods#3524
Convert the one and two argument show methods to MIME"text/plain" methods#3524andreasnoack wants to merge 1 commit intomainfrom
Conversation
985333d to
6167ffe
Compare
|
Thank you for the PR. We do not plan to make breaking releases for this package. However, we can discuss if we can consider this a "bugfix" and do staged introduction of the changes. For my understanding - what is exactly the bug that we fix with this change. (i.e. what is not working as expected with the current design)? CC @nalimilan |
|
This is my understanding of https://docs.julialang.org/en/v1/manual/types/#man-custom-pretty-printing is that multi-line output should be delegated to the three-argument show method for The immediate reason why I prepared this PR was vector output like the output below, which takes up too much space, is hard to separate the elements, and is a mess in text logs. julia> fill(DataFrame(x = ones(5)), 5)
5-element Vector{DataFrame}:
5×1 DataFrame
Row │ x
│ Float64
─────┼─────────
1 │ 1.0
2 │ 1.0
3 │ 1.0
4 │ 1.0
5 │ 1.0
5×1 DataFrame
Row │ x
│ Float64
─────┼─────────
1 │ 1.0
2 │ 1.0
3 │ 1.0
4 │ 1.0
5 │ 1.0
5×1 DataFrame
Row │ x
│ Float64
─────┼─────────
1 │ 1.0
2 │ 1.0
3 │ 1.0
4 │ 1.0
5 │ 1.0
5×1 DataFrame
Row │ x
│ Float64
─────┼─────────
1 │ 1.0
2 │ 1.0
3 │ 1.0
4 │ 1.0
5 │ 1.0
5×1 DataFrame
Row │ x
│ Float64
─────┼─────────
1 │ 1.0
2 │ 1.0
3 │ 1.0
4 │ 1.0
5 │ 1.0With this PR, that would be julia> fill(DataFrame(x = ones(5)), 5)
5-element Vector{DataFrame}:
DataFrame(AbstractVector[[1.0, 1.0, 1.0, 1.0, 1.0]], DataFrames.Index(Dict(:x => 1), [:x]), nothing, nothing, true)
DataFrame(AbstractVector[[1.0, 1.0, 1.0, 1.0, 1.0]], DataFrames.Index(Dict(:x => 1), [:x]), nothing, nothing, true)
DataFrame(AbstractVector[[1.0, 1.0, 1.0, 1.0, 1.0]], DataFrames.Index(Dict(:x => 1), [:x]), nothing, nothing, true)
DataFrame(AbstractVector[[1.0, 1.0, 1.0, 1.0, 1.0]], DataFrames.Index(Dict(:x => 1), [:x]), nothing, nothing, true)
DataFrame(AbstractVector[[1.0, 1.0, 1.0, 1.0, 1.0]], DataFrames.Index(Dict(:x => 1), [:x]), nothing, nothing, true)which can be improved, but is more structured and doesn't ruin text logs. |
89f195c to
1e10e96
Compare
|
Regarding the decision - I am OK to mark this PR as a bug fix.
Thank you! |
1e10e96 to
79507fa
Compare
|
Hi! Although I agree that the current way DataFrames print does not follow the convention in the Julia manual, I really think we must treat this as breaking. Anyone, me included, that customizes the output will start to see errors when updating the package. Furthermore, output customization will start to be more verbose. The only gain, IMHO, is when you have a vector of DataFrames. However, it seems something very unusual. Finally, if you decide to merge this PR, I highly recommend keeping the actual behavior if the user passes any keyword argument to |
79507fa to
5d44b05
Compare
|
I think I agree that, in its current form, this PR is probably too breaking to be considered just a bug fix. I do think it is unfortunate that the (very powerful and well written) show methods in this package don't follow the documentation for extending the I could try to make this less breaking, but the feasibility of that depends on how people are actually using these custom show methods. If it only because people have been relying on For Alternatively, we can just keep this one open until there is an appetite for a major release. At that point, it might be a good idea to also convert all the keyword arguments to fields of the |
|
I agree that it seems too breaking (for
Though it would be quite inconsistent so I'm not sure it would be worth it. The issue isn't easy to resolve even for the next breaking release: requiring users to write |
|
Do users really call |
|
Hard to tell, but at least I would think that arguments like |
We often receive some questions in Discourse asking how the output can be customized. That's was one of the reasons why @bkamins always asked me to add a section "Customizing DataFrames Output" to the manual. Hence, I think the number of people using it is not negligible. Now, with PrettyTables.jl v3 and the ability to add summary rows, I think it will be higher. |
|
In general my opinion is that users do ask for customized output in interactive sessions. Also in simple scripts calling |
Strictly speaking, I consider this a bugfix. "Decorated" multiline output should be handled by a show method for
MIME"text/plain"and not the two-argument show method. However, the show method here is very useful and probably used by many downstream packages, so it might cause a temporary ecosystem imbalance if this is released as a non-breaking release. We saw that when fixing the show method for StatsBase'sCoefTable. Are there other changes waiting for a breaking release?