diff --git a/apis/python/src/tiledbsoma/_dataframe.py b/apis/python/src/tiledbsoma/_dataframe.py index 449e4cc225..ec6b02c0ee 100644 --- a/apis/python/src/tiledbsoma/_dataframe.py +++ b/apis/python/src/tiledbsoma/_dataframe.py @@ -300,13 +300,9 @@ def create( if index_column_name == "soma_joinid": lower = slot_core_current_domain[0] upper = slot_core_current_domain[1] - if lower != 0: + if lower < 0 or upper < 0 or upper < lower: raise ValueError( - f"domain for soma_joinid must have lower bound of 0; got {lower}" - ) - if upper < 0: - raise ValueError( - f"domain for soma_joinid must have upper bound >= 0; got {upper}" + f"domain for soma_joinid must be non-negative with lower <= upper; got ({lower}, {upper})" ) # Here is our Arrow data API for communicating schema info between diff --git a/apis/python/tests/test_dataframe.py b/apis/python/tests/test_dataframe.py index b1f5103323..df2dff0a50 100644 --- a/apis/python/tests/test_dataframe.py +++ b/apis/python/tests/test_dataframe.py @@ -1882,20 +1882,20 @@ def test_bounds_on_somajoinid_domain(tmp_path): soma.DataFrame.create( uri, schema=schema, - domain=[[2, 99]], + domain=[[0, -1]], ) with pytest.raises(ValueError): soma.DataFrame.create( uri, schema=schema, - domain=[[0, -1]], + domain=[[-1, 2]], ) soma.DataFrame.create( uri, schema=schema, - domain=[[0, 99]], + domain=[[2, 99]], ) assert soma.DataFrame.exists(uri) diff --git a/apis/r/R/SOMADataFrame.R b/apis/r/R/SOMADataFrame.R index a7b24d702a..761e0d98ff 100644 --- a/apis/r/R/SOMADataFrame.R +++ b/apis/r/R/SOMADataFrame.R @@ -66,11 +66,12 @@ SOMADataFrame <- R6::R6Class( ) if ("soma_joinid" %in% index_column_names && !is.null(domain)) { - lower <- domain[["soma_joinid"]][1] - upper <- domain[["soma_joinid"]][2] + lower_bound <- domain[["soma_joinid"]][1] + upper_bound <- domain[["soma_joinid"]][2] stopifnot( - "The lower bound for soma_joinid domain must be 0" = lower == 0, - "The upper bound for soma_joinid domain must be >= 0" = upper >= 0 + "The lower bound for soma_joinid domain must be >= 0" = lower_bound >= 0, + "The upper bound for soma_joinid domain must be >= 0" = upper_bound >= 0, + "The upper bound for soma_joinid domain must be >= the lower bound" = upper_bound >= lower_bound ) } diff --git a/apis/r/tests/testthat/test-06-SOMADataFrame.R b/apis/r/tests/testthat/test-06-SOMADataFrame.R index e9aa748b9e..ab0669de66 100644 --- a/apis/r/tests/testthat/test-06-SOMADataFrame.R +++ b/apis/r/tests/testthat/test-06-SOMADataFrame.R @@ -194,7 +194,7 @@ test_that("soma_joinid domain lower bound must be zero", { uri, asch, index_column_names = index_column_names, - domain = list(soma_joinid=c(2, 99)) + domain = list(soma_joinid=c(3, 2)) ) ) @@ -207,12 +207,21 @@ test_that("soma_joinid domain lower bound must be zero", { ) ) + expect_error( + SOMADataFrameCreate( + uri, + asch, + index_column_names = index_column_names, + domain = list(soma_joinid=c(-1, 0)) + ) + ) + expect_no_condition( SOMADataFrameCreate( uri, asch, index_column_names = index_column_names, - domain = list(soma_joinid=c(0, 99)) + domain = list(soma_joinid=c(2, 99)) ) )