Skip to content

Commit

Permalink
[python] Use same default maxdomain between Python and R (#3088)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkerl authored Sep 30, 2024
1 parent 06cb313 commit efd323d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
5 changes: 2 additions & 3 deletions apis/python/src/tiledbsoma/_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -830,9 +830,8 @@ def _fill_out_slot_soma_domain(
# Here the slot_domain isn't specified by the user; we're setting it.
# The SOMA spec disallows negative soma_joinid.
if index_column_name == SOMA_JOINID:
slot_domain = (0, 2**31 - 2) # R-friendly, which 2**63-1 is not
else:
saturated_range = True
slot_domain = (0, 2**63 - 2)
saturated_range = True
elif np.issubdtype(dtype, NPFloating):
finfo = np.finfo(cast(NPFloating, dtype))
slot_domain = finfo.min, finfo.max
Expand Down
6 changes: 5 additions & 1 deletion apis/python/src/tiledbsoma/_sparse_nd_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,8 +490,12 @@ def _dim_capacity_and_extent(
int64 is returned for the capacity.
"""
if dim_shape is None:
dim_capacity = 2**31 - 2 # Make this friendly for reads by tiledbsoma-r
dim_capacity = 2**63 - 1
dim_extent = min(dim_capacity, create_options.dim_tile(dim_name, 2048))
# For core: "domain max expanded to multiple of tile extent exceeds max value
# representable by domain type. Reduce domain max by 1 tile extent to allow for
# expansion."
dim_capacity -= dim_extent
else:
if dim_shape <= 0:
raise ValueError(
Expand Down
10 changes: 0 additions & 10 deletions apis/python/tests/test_shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,6 @@ def test_sparse_nd_array_basics(
with tiledbsoma.SparseNDArray.open(uri) as snda:
assert snda.shape == arg_shape

# Test resize too big
new_shape = tuple([4_000_000_000 for i in range(ndim)])
# TODO: check draft spec
# with pytest.raises(ValueError):
with pytest.raises(tiledbsoma.SOMAError):
with tiledbsoma.SparseNDArray.open(uri, "w") as snda:
snda.resize(new_shape)
with tiledbsoma.SparseNDArray.open(uri) as snda:
assert snda.shape == arg_shape

# Test writes out of bounds
with tiledbsoma.SparseNDArray.open(uri, "w") as snda:
with pytest.raises(tiledbsoma.SOMAError):
Expand Down

0 comments on commit efd323d

Please sign in to comment.