Skip to content

Commit

Permalink
Fix is_named_list bug #3181 (#3183)
Browse files Browse the repository at this point in the history
* Fix `is_named_list` bug #3181

* DESCRIPTION NEWS.md [skip ci]
  • Loading branch information
johnkerl authored Oct 17, 2024
1 parent 7683e1e commit e6bdaa4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion apis/r/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Description: Interface for working with 'TileDB'-based Stack of Matrices,
like those commonly used for single cell data analysis. It is documented at
<https://github.com/single-cell-data>; a formal specification available is at
<https://github.com/single-cell-data/SOMA/blob/main/abstract_specification.md>.
Version: 1.15.99.6
Version: 1.15.99.7
Authors@R: c(
person(given = "Aaron", family = "Wolen",
role = c("cre", "aut"), email = "aaron@tiledb.com",
Expand Down
2 changes: 2 additions & 0 deletions apis/r/NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* Add transitional/non-exported `parse_query_condition_new` [#3162](https://github.com/single-cell-data/TileDB-SOMA/pull/3162)
* Apply new `parse_query_condition` [#3174](https://github.com/single-cell-data/TileDB-SOMA/pull/3174)
* Apply new `non_empty_domain` [#3176](https://github.com/single-cell-data/TileDB-SOMA/pull/3176)
* Support for dense current domain with core 2.27 [#3180](https://github.com/single-cell-data/TileDB-SOMA/pull/3180)
* Fix `is_named_list` bug for half-named lists [#3183](https://github.com/single-cell-data/TileDB-SOMA/pull/3183)

# tiledbsoma 1.14.1

Expand Down
4 changes: 3 additions & 1 deletion apis/r/R/utils-assertions.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ is_named <- function(x, allow_empty = TRUE) {
}

is_named_list <- function(x) {
is.list(x) && is_named(x)
# Use allow_empty=FALSE otherwise "half-named" lists like list(a=1, 2)
# will get through. We want all slots to have names.
is.list(x) && is_named(x, allow_empty = FALSE)
}

is_character_or_null <- function(x) {
Expand Down
6 changes: 6 additions & 0 deletions apis/r/tests/testthat/test-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,9 @@ test_that("validate read coords with dimension names and schema", {
expect_equal(test_coords$int_column, 1:10)
expect_equal(test_coords$soma_joinid, as.integer64(1:10))
})

test_that("half-named lists are not treated as named", {
expect_true(is_named_list(list(a=1, b=2)))
expect_false(is_named_list(list(a=1, 2)))
expect_false(is_named_list(list(1, 2)))
})

0 comments on commit e6bdaa4

Please sign in to comment.