Skip to content

Commit

Permalink
[r/python] Revert #3300 (#3358)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkerl authored Nov 21, 2024
1 parent 4aac1da commit ca00d5b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
8 changes: 2 additions & 6 deletions apis/python/src/tiledbsoma/_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions apis/python/tests/test_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
9 changes: 5 additions & 4 deletions apis/r/R/SOMADataFrame.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
}

Expand Down
13 changes: 11 additions & 2 deletions apis/r/tests/testthat/test-06-SOMADataFrame.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))
)
)

Expand All @@ -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))
)
)

Expand Down

0 comments on commit ca00d5b

Please sign in to comment.