Skip to content
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

fix HTML printing tests after PrettyTables.jl 2.2 release #3221

Merged
merged 2 commits into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions docs/src/man/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,10 @@ Let us start with the example of using the `empty` and `empty!` functions:
```jldoctest dataframe
julia> empty(german)
0×10 DataFrame
Row │ id Age Sex Job Housing Saving accounts Checking accoun ⋯
│ Int64 Int64 String7 Int64 String7 String15 String15 ⋯
─────┴──────────────────────────────────────────────────────────────────────────
4 columns omitted

julia> german
1000×10 DataFrame
Expand All @@ -500,20 +504,29 @@ julia> german

julia> empty!(german)
0×10 DataFrame
Row │ id Age Sex Job Housing Saving accounts Checking accoun ⋯
│ Int64 Int64 String7 Int64 String7 String15 String15 ⋯
─────┴──────────────────────────────────────────────────────────────────────────
4 columns omitted

julia> german
0×10 DataFrame
Row │ id Age Sex Job Housing Saving accounts Checking accoun ⋯
│ Int64 Int64 String7 Int64 String7 String15 String15 ⋯
─────┴──────────────────────────────────────────────────────────────────────────
4 columns omitted
```

In the above example `empty` function created a new `DataFrame` with the same
column names and column element types as `german` but with zero rows. On the
other hand `empty!` function removed all rows from `german` in-place and made
each of its columns empty.

The difference between the behavior of the `empty` and `empty!` functions is an application of the
The difference between the behavior of the `empty` and `empty!` functions is an
application of the
[stylistic convention](https://docs.julialang.org/en/v1/manual/variables/#Stylistic-Conventions)
employed in the Julia language.
This convention is followed in all functions provided by the DataFrames.jl package.
employed in the Julia language. This convention is followed in all functions
provided by the DataFrames.jl package.

### Getting Basic Information about a Data Frame

Expand Down
3 changes: 3 additions & 0 deletions docs/src/man/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,9 @@ integers and the second one can only contain strings):
```jldoctest dataframe
julia> df = DataFrame(A=Int[], B=String[])
0×2 DataFrame
Row │ A B
│ Int64 String
─────┴───────────────
```

Rows can then be added as tuples or vectors, where the order of elements matches that of columns.
Expand Down
3 changes: 3 additions & 0 deletions src/dataframe/dataframe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1014,6 +1014,9 @@ julia> df = DataFrame(a=1:3, b=4:6)

julia> empty!(df)
0×2 DataFrame
Row │ a b
│ Int64 Int64
─────┴──────────────

julia> df.a, df.b
(Int64[], Int64[])
Expand Down
194 changes: 63 additions & 131 deletions test/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -629,137 +629,69 @@ end
show(IOContext(io, :limit => true), MIME"text/html"(),
DataFrame(a = Int64.(1:26 |> collect)))
str = String(take!(io))
@test str == "<div>" *
"<div style = \"float: left;\">" *
"<span>26×1 DataFrame</span>" *
"</div>" *
"<div style = \"float: right;\">" *
"<span style = \"font-style: italic;\">1 row omitted</span>" *
"</div>" *
"<div style = \"clear: both;\">" *
"</div>" *
"</div>" *
"<div class = \"data-frame\" style = \"overflow-x: scroll;\">" *
"<table class = \"data-frame\" style = \"margin-bottom: 6px;\">" *
"<thead>" *
"<tr class = \"header\">" *
"<th class = \"rowNumber\" style = \"font-weight: bold; text-align: right;\">Row</th>" *
"<th style = \"text-align: left;\">a</th>" *
"</tr>" *
"<tr class = \"subheader headerLastRow\">" *
"<th class = \"rowNumber\" style = \"font-weight: bold; text-align: right;\">" *
"</th>" *
"<th title = \"Int64\" style = \"text-align: left;\">Int64</th>" *
"</tr>" *
"</thead>" *
"<tbody>" *
"<tr>" *
"<td class = \"rowNumber\" style = \"font-weight: bold; text-align: right;\">1</td>" *
"<td style = \"text-align: right;\">1</td>" *
"</tr>" *
"<tr>" *
"<td class = \"rowNumber\" style = \"font-weight: bold; text-align: right;\">2</td>" *
"<td style = \"text-align: right;\">2</td>" *
"</tr>" *
"<tr>" *
"<td class = \"rowNumber\" style = \"font-weight: bold; text-align: right;\">3</td>" *
"<td style = \"text-align: right;\">3</td>" *
"</tr>" *
"<tr>" *
"<td class = \"rowNumber\" style = \"font-weight: bold; text-align: right;\">4</td>" *
"<td style = \"text-align: right;\">4</td>" *
"</tr>" *
"<tr>" *
"<td class = \"rowNumber\" style = \"font-weight: bold; text-align: right;\">5</td>" *
"<td style = \"text-align: right;\">5</td>" *
"</tr>" *
"<tr>" *
"<td class = \"rowNumber\" style = \"font-weight: bold; text-align: right;\">6</td>" *
"<td style = \"text-align: right;\">6</td>" *
"</tr>" *
"<tr>" *
"<td class = \"rowNumber\" style = \"font-weight: bold; text-align: right;\">7</td>" *
"<td style = \"text-align: right;\">7</td>" *
"</tr>" *
"<tr>" *
"<td class = \"rowNumber\" style = \"font-weight: bold; text-align: right;\">8</td>" *
"<td style = \"text-align: right;\">8</td>" *
"</tr>" *
"<tr>" *
"<td class = \"rowNumber\" style = \"font-weight: bold; text-align: right;\">9</td>" *
"<td style = \"text-align: right;\">9</td>" *
"</tr>" *
"<tr>" *
"<td class = \"rowNumber\" style = \"font-weight: bold; text-align: right;\">10</td>" *
"<td style = \"text-align: right;\">10</td>" *
"</tr>" *
"<tr>" *
"<td class = \"rowNumber\" style = \"font-weight: bold; text-align: right;\">11</td>" *
"<td style = \"text-align: right;\">11</td>" *
"</tr>" *
"<tr>" *
"<td class = \"rowNumber\" style = \"font-weight: bold; text-align: right;\">12</td>" *
"<td style = \"text-align: right;\">12</td>" *
"</tr>" *
"<tr>" *
"<td class = \"rowNumber\" style = \"font-weight: bold; text-align: right;\">13</td>" *
"<td style = \"text-align: right;\">13</td>" *
"</tr>" *
"<tr>" *
"<td style = \"text-align: right;\">&vellip;</td>" *
"<td style = \"text-align: right;\">&vellip;</td>" *
"</tr>" *
"<tr>" *
"<td class = \"rowNumber\" style = \"font-weight: bold; text-align: right;\">15</td>" *
"<td style = \"text-align: right;\">15</td>" *
"</tr>" *
"<tr>" *
"<td class = \"rowNumber\" style = \"font-weight: bold; text-align: right;\">16</td>" *
"<td style = \"text-align: right;\">16</td>" *
"</tr>" *
"<tr>" *
"<td class = \"rowNumber\" style = \"font-weight: bold; text-align: right;\">17</td>" *
"<td style = \"text-align: right;\">17</td>" *
"</tr>" *
"<tr>" *
"<td class = \"rowNumber\" style = \"font-weight: bold; text-align: right;\">18</td>" *
"<td style = \"text-align: right;\">18</td>" *
"</tr>" *
"<tr>" *
"<td class = \"rowNumber\" style = \"font-weight: bold; text-align: right;\">19</td>" *
"<td style = \"text-align: right;\">19</td>" *
"</tr>" *
"<tr>" *
"<td class = \"rowNumber\" style = \"font-weight: bold; text-align: right;\">20</td>" *
"<td style = \"text-align: right;\">20</td>" *
"</tr>" *
"<tr>" *
"<td class = \"rowNumber\" style = \"font-weight: bold; text-align: right;\">21</td>" *
"<td style = \"text-align: right;\">21</td>" *
"</tr>" *
"<tr>" *
"<td class = \"rowNumber\" style = \"font-weight: bold; text-align: right;\">22</td>" *
"<td style = \"text-align: right;\">22</td>" *
"</tr>" *
"<tr>" *
"<td class = \"rowNumber\" style = \"font-weight: bold; text-align: right;\">23</td>" *
"<td style = \"text-align: right;\">23</td>" *
"</tr>" *
"<tr>" *
"<td class = \"rowNumber\" style = \"font-weight: bold; text-align: right;\">24</td>" *
"<td style = \"text-align: right;\">24</td>" *
"</tr>" *
"<tr>" *
"<td class = \"rowNumber\" style = \"font-weight: bold; text-align: right;\">25</td>" *
"<td style = \"text-align: right;\">25</td>" *
"</tr>" *
"<tr>" *
"<td class = \"rowNumber\" style = \"font-weight: bold; text-align: right;\">26</td>" *
"<td style = \"text-align: right;\">26</td>" *
"</tr>" *
"</tbody>" *
"</table>" *
"</div>"
@test str == """<div><div style = "float: left;"><span>26×1 DataFrame</span></div>""" *
"""<div style = "clear: both;"></div></div>""" *
"""<div class = "data-frame" style = "overflow-x: scroll;">""" *
"""<table class = "data-frame" style = "margin-bottom: 6px;">""" *
"""<thead><tr class = "header">""" *
"""<th class = "rowNumber" style = "font-weight: bold; text-align: right;">Row</th>""" *
"""<th style = "text-align: left;">a</th></tr>""" *
"""<tr class = "subheader headerLastRow">""" *
"""<th class = "rowNumber" style = "font-weight: bold; text-align: right;"></th>""" *
"""<th title = "Int64" style = "text-align: left;">Int64</th></tr></thead>""" *
"""<tbody><tr>""" *
"""<td class = "rowNumber" style = "font-weight: bold; text-align: right;">1</td>""" *
"""<td style = "text-align: right;">1</td></tr><tr>""" *
"""<td class = "rowNumber" style = "font-weight: bold; text-align: right;">2</td>""" *
"""<td style = "text-align: right;">2</td></tr><tr>""" *
"""<td class = "rowNumber" style = "font-weight: bold; text-align: right;">3</td>""" *
"""<td style = "text-align: right;">3</td></tr><tr>""" *
"""<td class = "rowNumber" style = "font-weight: bold; text-align: right;">4</td>""" *
"""<td style = "text-align: right;">4</td></tr><tr>""" *
"""<td class = "rowNumber" style = "font-weight: bold; text-align: right;">5</td>""" *
"""<td style = "text-align: right;">5</td></tr><tr>""" *
"""<td class = "rowNumber" style = "font-weight: bold; text-align: right;">6</td>""" *
"""<td style = "text-align: right;">6</td></tr><tr>""" *
"""<td class = "rowNumber" style = "font-weight: bold; text-align: right;">7</td>""" *
"""<td style = "text-align: right;">7</td></tr><tr>""" *
"""<td class = "rowNumber" style = "font-weight: bold; text-align: right;">8</td>""" *
"""<td style = "text-align: right;">8</td></tr><tr>""" *
"""<td class = "rowNumber" style = "font-weight: bold; text-align: right;">9</td>""" *
"""<td style = "text-align: right;">9</td></tr><tr>""" *
"""<td class = "rowNumber" style = "font-weight: bold; text-align: right;">10</td>""" *
"""<td style = "text-align: right;">10</td></tr><tr>""" *
"""<td class = "rowNumber" style = "font-weight: bold; text-align: right;">11</td>""" *
"""<td style = "text-align: right;">11</td></tr><tr>""" *
"""<td class = "rowNumber" style = "font-weight: bold; text-align: right;">12</td>""" *
"""<td style = "text-align: right;">12</td></tr><tr>""" *
"""<td class = "rowNumber" style = "font-weight: bold; text-align: right;">13</td>""" *
"""<td style = "text-align: right;">13</td></tr><tr>""" *
"""<td class = "rowNumber" style = "font-weight: bold; text-align: right;">14</td>""" *
"""<td style = "text-align: right;">14</td></tr><tr>""" *
"""<td class = "rowNumber" style = "font-weight: bold; text-align: right;">15</td>""" *
"""<td style = "text-align: right;">15</td></tr><tr>""" *
"""<td class = "rowNumber" style = "font-weight: bold; text-align: right;">16</td>""" *
"""<td style = "text-align: right;">16</td></tr><tr>""" *
"""<td class = "rowNumber" style = "font-weight: bold; text-align: right;">17</td>""" *
"""<td style = "text-align: right;">17</td></tr><tr>""" *
"""<td class = "rowNumber" style = "font-weight: bold; text-align: right;">18</td>""" *
"""<td style = "text-align: right;">18</td></tr><tr>""" *
"""<td class = "rowNumber" style = "font-weight: bold; text-align: right;">19</td>""" *
"""<td style = "text-align: right;">19</td></tr><tr>""" *
"""<td class = "rowNumber" style = "font-weight: bold; text-align: right;">20</td>""" *
"""<td style = "text-align: right;">20</td></tr><tr>""" *
"""<td class = "rowNumber" style = "font-weight: bold; text-align: right;">21</td>""" *
"""<td style = "text-align: right;">21</td></tr><tr>""" *
"""<td class = "rowNumber" style = "font-weight: bold; text-align: right;">22</td>""" *
"""<td style = "text-align: right;">22</td></tr><tr>""" *
"""<td class = "rowNumber" style = "font-weight: bold; text-align: right;">23</td>""" *
"""<td style = "text-align: right;">23</td></tr><tr>""" *
"""<td class = "rowNumber" style = "font-weight: bold; text-align: right;">24</td>""" *
"""<td style = "text-align: right;">24</td></tr><tr>""" *
"""<td class = "rowNumber" style = "font-weight: bold; text-align: right;">25</td>""" *
"""<td style = "text-align: right;">25</td></tr><tr>""" *
"""<td class = "rowNumber" style = "font-weight: bold; text-align: right;">26</td>""" *
"""<td style = "text-align: right;">26</td></tr></tbody></table></div>"""

# Test invalid keywords when printing to HTML.
@test_throws ArgumentError show(stdout, MIME("text/html"), df, rowid=10)
Expand Down