Skip to content

Commit

Permalink
Pillar 1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
flying-sheep committed May 14, 2019
1 parent 6ac1021 commit 32c55b0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ Imports:
grDevices,
htmltools,
jsonlite,
pillar,
pillar (>= 1.4.0),
base64enc
Suggests:
methods,
highr,
Cairo,
stringr,
testthat,
diffobj,
diffobj (>= 0.2.3),
leaflet
Enhances:
data.table,
Expand Down
6 changes: 3 additions & 3 deletions R/repr_matrix_df.r
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,10 @@ repr_matrix_generic <- function(
is_matrix <- !is.list(x)
cls <-
if (!is.null(caption_override)) caption_override
else if (!is.object(x)) class(x)[[1]]
else type_sum(x)
else if (class(x)[[1]] == 'tbl_df') 'tibble'
else class(x)[[1]]
dims <- dim(x)
types <- if (is_matrix) type_sum(x) else {
types <- if (is_matrix) type_sum(as.vector(x)) else {
type_vec <- sprintf('<%s>', sapply(x, type_sum))
# A row limit of 3 is the minimal choice, but we only have 1 anyway
as.vector(ellip_limit_arr(matrix(type_vec, nrow = 1L), 3L, cols))
Expand Down
10 changes: 4 additions & 6 deletions tests/testthat/helpers.r
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ expect_id_text <- function(object, expected) {
object <- strsplit(object, '\n')[[1]]
expected <- strsplit(expected, '\n')[[1]]
}
if (!identical(object, expected)) {
dif <- diffobj::diffChr(object, expected, format = 'ansi256', ignore.white.space = FALSE, interactive = FALSE)
fail_msg <- as.character(dif)
if (!one_element) fail_msg <- paste(format(seq_along(fail_msg)), fail_msg)
expect(!any(dif), fail_msg)
}
dif <- diffobj::diffChr(object, expected, format = 'ansi256', ignore.white.space = FALSE, interactive = FALSE)
fail_msg <- as.character(dif)
if (!one_element) fail_msg <- paste(format(seq_along(fail_msg)), fail_msg)
expect(!any(dif), fail_msg)
}

expect_equivalent_string <- function(result, expectation){
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test_repr_array_df.r
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ test_that('matrices in data.frames work', {
expect_id_text(repr_markdown(df), '
A data.frame: 3 \u00D7 5
| Species &lt;fct&gt; | Sepal.Length &lt;dbl&gt; | Sepal.Width &lt;dbl&gt; | Petal.Length &lt;dbl&gt; | Petal.Width &lt;dbl&gt; |
| Species &lt;fct&gt; | Sepal.Length &lt;dbl[,2]&gt; | Sepal.Width &lt;dbl[,2]&gt; | Petal.Length &lt;dbl[,2]&gt; | Petal.Width &lt;dbl[,2]&gt; |
|---|---|---|---|---|
| setosa | 4.3, 5.8 | 2.3, 4.4 | 1.0, 1.9 | 0.1, 0.6 |
| versicolor | 4.9, 7.0 | 2.0, 3.4 | 3.0, 5.1 | 1.0, 1.8 |
Expand Down

0 comments on commit 32c55b0

Please sign in to comment.