diff --git a/apis/python/src/tiledbsoma/soma_dataframe.cc b/apis/python/src/tiledbsoma/soma_dataframe.cc index 97909558c5..43bb11c444 100644 --- a/apis/python/src/tiledbsoma/soma_dataframe.cc +++ b/apis/python/src/tiledbsoma/soma_dataframe.cc @@ -161,7 +161,8 @@ void load_soma_dataframe(py::module& m) { "resize_soma_joinid_shape", [](SOMADataFrame& sdf, int64_t newshape) { try { - sdf.resize_soma_joinid_shape(newshape); + sdf.resize_soma_joinid_shape( + newshape, "resize_soma_joinid_shape"); } catch (const std::exception& e) { throw TileDBSOMAError(e.what()); } diff --git a/apis/python/src/tiledbsoma/soma_sparse_ndarray.cc b/apis/python/src/tiledbsoma/soma_sparse_ndarray.cc index 3b38860ba6..5bfbf27b3f 100644 --- a/apis/python/src/tiledbsoma/soma_sparse_ndarray.cc +++ b/apis/python/src/tiledbsoma/soma_sparse_ndarray.cc @@ -121,7 +121,7 @@ void load_soma_sparse_ndarray(py::module& m) { "resize", [](SOMAArray& array, const std::vector& newshape) { try { - array.resize(newshape); + array.resize(newshape, "resize"); } catch (const std::exception& e) { throw TileDBSOMAError(e.what()); } @@ -132,7 +132,7 @@ void load_soma_sparse_ndarray(py::module& m) { "tiledbsoma_upgrade_shape", [](SOMAArray& array, const std::vector& newshape) { try { - array.upgrade_shape(newshape); + array.upgrade_shape(newshape, "tiledbsoma_upgrade_shape"); } catch (const std::exception& e) { throw TileDBSOMAError(e.what()); } diff --git a/apis/r/R/RcppExports.R b/apis/r/R/RcppExports.R index 71725d12d8..961f69b01e 100644 --- a/apis/r/R/RcppExports.R +++ b/apis/r/R/RcppExports.R @@ -227,7 +227,7 @@ resize <- function(uri, new_shape, ctxxp) { } resize_soma_joinid_shape <- function(uri, new_shape, ctxxp) { - invisible(.Call(`_tiledbsoma_resize_soma_joinid`, uri, new_shape, ctxxp)) + invisible(.Call(`_tiledbsoma_resize_soma_joinid_shape`, uri, new_shape, ctxxp)) } tiledbsoma_upgrade_shape <- function(uri, new_shape, ctxxp) { diff --git a/apis/r/src/RcppExports.cpp b/apis/r/src/RcppExports.cpp index 3cf04fd4a4..b530b175c6 100644 --- a/apis/r/src/RcppExports.cpp +++ b/apis/r/src/RcppExports.cpp @@ -514,7 +514,7 @@ END_RCPP } // resize_soma_joinid_shape void resize_soma_joinid_shape(const std::string& uri, Rcpp::NumericVector new_shape, Rcpp::XPtr ctxxp); -RcppExport SEXP _tiledbsoma_resize_soma_joinid(SEXP uriSEXP, SEXP new_shapeSEXP, SEXP ctxxpSEXP) { +RcppExport SEXP _tiledbsoma_resize_soma_joinid_shape(SEXP uriSEXP, SEXP new_shapeSEXP, SEXP ctxxpSEXP) { BEGIN_RCPP Rcpp::RNGScope rcpp_rngScope_gen; Rcpp::traits::input_parameter< const std::string& >::type uri(uriSEXP); @@ -761,7 +761,7 @@ static const R_CallMethodDef CallEntries[] = { {"_tiledbsoma_c_attrnames", (DL_FUNC) &_tiledbsoma_c_attrnames, 2}, {"_tiledbsoma_c_schema", (DL_FUNC) &_tiledbsoma_c_schema, 2}, {"_tiledbsoma_resize", (DL_FUNC) &_tiledbsoma_resize, 3}, - {"_tiledbsoma_resize_soma_joinid", (DL_FUNC) &_tiledbsoma_resize_soma_joinid, 3}, + {"_tiledbsoma_resize_soma_joinid_shape", (DL_FUNC) &_tiledbsoma_resize_soma_joinid_shape, 3}, {"_tiledbsoma_tiledbsoma_upgrade_shape", (DL_FUNC) &_tiledbsoma_tiledbsoma_upgrade_shape, 3}, {"_tiledbsoma_c_update_dataframe_schema", (DL_FUNC) &_tiledbsoma_c_update_dataframe_schema, 6}, {"_tiledbsoma_sr_setup", (DL_FUNC) &_tiledbsoma_sr_setup, 10}, diff --git a/apis/r/src/rinterface.cpp b/apis/r/src/rinterface.cpp index 4400cb60d4..a6a3c02b0d 100644 --- a/apis/r/src/rinterface.cpp +++ b/apis/r/src/rinterface.cpp @@ -428,7 +428,7 @@ void resize( // https://github.com/single-cell-data/TileDB-SOMA/issues/2407. auto sr = tdbs::SOMAArray::open(OpenMode::write, uri, ctxxp->ctxptr); std::vector new_shape_i64 = i64_from_rcpp_numeric(new_shape); - sr->resize(new_shape_i64); + sr->resize(new_shape_i64, "resize"); sr->close(); } @@ -440,7 +440,7 @@ void resize_soma_joinid_shape( // This function is solely for SOMADataFrame. auto sr = tdbs::SOMADataFrame::open(uri, OpenMode::write, ctxxp->ctxptr); std::vector new_shape_i64 = i64_from_rcpp_numeric(new_shape); - sr->resize_soma_joinid_shape(new_shape_i64[0]); + sr->resize_soma_joinid_shape(new_shape_i64[0], "resize_soma_joinid_shape"); sr->close(); } @@ -455,7 +455,7 @@ void tiledbsoma_upgrade_shape( // https://github.com/single-cell-data/TileDB-SOMA/issues/2407. auto sr = tdbs::SOMAArray::open(OpenMode::write, uri, ctxxp->ctxptr); std::vector new_shape_i64 = i64_from_rcpp_numeric(new_shape); - sr->upgrade_shape(new_shape_i64); + sr->upgrade_shape(new_shape_i64, "tiledbsoma_upgrade_shape"); sr->close(); } diff --git a/libtiledbsoma/src/soma/soma_array.cc b/libtiledbsoma/src/soma/soma_array.cc index 2932327e1d..394427df5a 100644 --- a/libtiledbsoma/src/soma/soma_array.cc +++ b/libtiledbsoma/src/soma/soma_array.cc @@ -524,8 +524,8 @@ void SOMAArray::_promote_indexes_to_values( return _cast_dictionary_values(schema, array); default: throw TileDBSOMAError(fmt::format( - "Saw invalid TileDB value type when attempting to " - "promote indexes to values: {}", + "Saw invalid TileDB value type when attempting to promote " + "indexes to values: {}", tiledb::impl::type_to_str(value_type))); } } @@ -1452,7 +1452,7 @@ std::pair SOMAArray::_can_set_shape_helper( return std::pair( false, fmt::format( - "cannot {}: provided shape has ndim {}, while the array has {}", + "{}: provided shape has ndim {}, while the array has {}", function_name_for_messages, arg_ndim, array_ndim)); @@ -1481,8 +1481,7 @@ std::pair SOMAArray::_can_set_shape_helper( false, fmt::format( "{}: array already has a shape: please use resize rather " - "than " - "tiledbsoma_upgrade_shape.", + "than tiledbsoma_upgrade_shape.", function_name_for_messages)); } } @@ -1497,7 +1496,7 @@ std::pair SOMAArray::_can_set_shape_helper( // // if the requested shape fits in the array's core domain, it's good to go // as a new shape. - auto domain_check = _can_set_shape_domainish_helper( + auto domain_check = _can_set_shape_domainish_subhelper( newshape, false, function_name_for_messages); if (!domain_check.first) { return domain_check; @@ -1506,7 +1505,7 @@ std::pair SOMAArray::_can_set_shape_helper( // For new-style arrays, we need to additionally that the the requested // shape (core current domain) isn't a downsize of the current one. if (has_shape) { - auto current_domain_check = _can_set_shape_domainish_helper( + auto current_domain_check = _can_set_shape_domainish_subhelper( newshape, true, function_name_for_messages); if (!current_domain_check.first) { return current_domain_check; @@ -1519,7 +1518,7 @@ std::pair SOMAArray::_can_set_shape_helper( // This is a helper for _can_set_shape_helper: it's used for comparing // the user's requested shape against the core current domain or core (max) // domain. -std::pair SOMAArray::_can_set_shape_domainish_helper( +std::pair SOMAArray::_can_set_shape_domainish_subhelper( const std::vector& newshape, bool check_current_domain, std::string function_name_for_messages) { @@ -1536,8 +1535,7 @@ std::pair SOMAArray::_can_set_shape_domainish_helper( // library-internal code, it's not the user's fault if we got here. if (dim.type() != TILEDB_INT64) { throw TileDBSOMAError(fmt::format( - "{}: internal error: expected {} dim to " - "be {}; got {}", + "{}: internal error: expected {} dim to be {}; got {}", function_name_for_messages, dim_name, tiledb::impl::type_to_str(TILEDB_INT64), @@ -1553,7 +1551,7 @@ std::pair SOMAArray::_can_set_shape_domainish_helper( return std::pair( false, fmt::format( - "cannot {} for {}: new {} < existing shape {}", + "{} for {}: new {} < existing shape {}", function_name_for_messages, dim_name, newshape[i], @@ -1569,7 +1567,7 @@ std::pair SOMAArray::_can_set_shape_domainish_helper( return std::pair( false, fmt::format( - "cannot {} for {}: new {} < maxshape {}", + "{} for {}: new {} < maxshape {}", function_name_for_messages, dim_name, newshape[i], @@ -1580,15 +1578,17 @@ std::pair SOMAArray::_can_set_shape_domainish_helper( return std::pair(true, ""); } -std::pair SOMAArray::can_resize_soma_joinid( - int64_t newshape) { +std::pair SOMAArray::can_resize_soma_joinid_shape( + int64_t newshape, std::string function_name_for_messages) { // Fail if the array doesn't already have a shape yet (they should upgrade // first). if (!has_current_domain()) { return std::pair( false, - "can_resize_soma_joinid: dataframe currently has no domain set: " - "please use tiledbsoma_upgrade_domain."); + fmt::format( + "{}: dataframe currently has no domain set: please " + "upgrade the array.", + function_name_for_messages)); } // OK if soma_joinid isn't a dim. @@ -1602,8 +1602,8 @@ std::pair SOMAArray::can_resize_soma_joinid( return std::pair( false, fmt::format( - "cannot resize_soma_joinid_shape: new soma_joinid shape {} < " - "existing shape {}", + "{}: new soma_joinid shape {} < existing shape {}", + function_name_for_messages, newshape, cur_dom_lo_hi.second)); } @@ -1614,8 +1614,8 @@ std::pair SOMAArray::can_resize_soma_joinid( return std::pair( false, fmt::format( - "cannot resize_soma_joinid_shape: new soma_joinid shape {} > " - "maxshape {}", + "{}: new soma_joinid shape {} > maxshape {}", + function_name_for_messages, newshape, dom_lo_hi.second)); } @@ -1624,27 +1624,34 @@ std::pair SOMAArray::can_resize_soma_joinid( return std::pair(true, ""); } -void SOMAArray::resize(const std::vector& newshape) { +void SOMAArray::resize( + const std::vector& newshape, + std::string function_name_for_messages) { if (_get_current_domain().is_empty()) { - throw TileDBSOMAError( - "[SOMAArray::resize] array must already have a shape"); + throw TileDBSOMAError(fmt::format( + "{} array must already have a shape", function_name_for_messages)); } - _set_current_domain_from_shape(newshape); + _set_current_domain_from_shape(newshape, function_name_for_messages); } -void SOMAArray::upgrade_shape(const std::vector& newshape) { +void SOMAArray::upgrade_shape( + const std::vector& newshape, + std::string function_name_for_messages) { if (!_get_current_domain().is_empty()) { - throw TileDBSOMAError( - "[SOMAArray::resize] array must not already have a shape"); + throw TileDBSOMAError(fmt::format( + "{}: array must not already have a shape", + function_name_for_messages)); } - _set_current_domain_from_shape(newshape); + _set_current_domain_from_shape(newshape, function_name_for_messages); } void SOMAArray::_set_current_domain_from_shape( - const std::vector& newshape) { + const std::vector& newshape, + std::string function_name_for_messages) { if (mq_->query_type() != TILEDB_WRITE) { - throw TileDBSOMAError( - "[SOMAArray::resize] array must be opened in write mode"); + throw TileDBSOMAError(fmt::format( + "{} array must be opened in write mode", + function_name_for_messages)); } // Variant-indexed dataframes must use a separate path @@ -1677,10 +1684,12 @@ void SOMAArray::_set_current_domain_from_shape( schema_evolution.array_evolve(uri_); } -void SOMAArray::resize_soma_joinid_shape(int64_t newshape) { +void SOMAArray::resize_soma_joinid_shape( + int64_t newshape, std::string function_name_for_messages) { if (mq_->query_type() != TILEDB_WRITE) { - throw TileDBSOMAError( - "[SOMAArray::resize] array must be opened in write mode"); + throw TileDBSOMAError(fmt::format( + "{}: array must be opened in write mode", + function_name_for_messages)); } ArraySchema schema = arr_->schema(); diff --git a/libtiledbsoma/src/soma/soma_array.h b/libtiledbsoma/src/soma/soma_array.h index 24f00329b9..d6a8508a82 100644 --- a/libtiledbsoma/src/soma/soma_array.h +++ b/libtiledbsoma/src/soma/soma_array.h @@ -997,8 +997,7 @@ class SOMAArray : public SOMAObject { default: throw std::runtime_error( "internal coding error in " - "SOMAArray::_core_domainish_slot_string: " - "unknown kind"); + "SOMAArray::_core_domainish_slot_string: unknown kind"); } } @@ -1061,8 +1060,10 @@ class SOMAArray : public SOMAObject { * existing core domain. */ std::pair can_resize( - const std::vector& newshape) { - return _can_set_shape_helper(newshape, true, "resize"); + const std::vector& newshape, + std::string function_name_for_messages) { + return _can_set_shape_helper( + newshape, true, function_name_for_messages); } /** @@ -1083,16 +1084,18 @@ class SOMAArray : public SOMAObject { * domain. */ std::pair can_upgrade_shape( - const std::vector& newshape) { + const std::vector& newshape, + std::string function_name_for_messages) { return _can_set_shape_helper( - newshape, false, "tiledbsoma_upgrade_shape"); + newshape, false, function_name_for_messages); } /** * This is similar to can_upgrade_shape, but it's a can-we call * for maybe_resize_soma_joinid. */ - std::pair can_resize_soma_joinid(int64_t newshape); + std::pair can_resize_soma_joinid_shape( + int64_t newshape, std::string function_name_for_messages); /** * @brief Resize the shape (what core calls "current domain") up to the @@ -1105,7 +1108,9 @@ class SOMAArray : public SOMAObject { * @return Nothing. Raises an exception if the resize would be a downsize, * which is not supported. */ - void resize(const std::vector& newshape); + void resize( + const std::vector& newshape, + std::string function_name_for_messages); /** * @brief Given an old-style array without current domain, sets its @@ -1113,7 +1118,9 @@ class SOMAArray : public SOMAObject { * of int64 type. Namely, all SparseNDArray/DenseNDArray, and * default-indexed DataFrame. */ - void upgrade_shape(const std::vector& newshape); + void upgrade_shape( + const std::vector& newshape, + std::string function_name_for_messages); /** * @brief Increases the tiledbsoma shape up to at most the maxshape, @@ -1129,7 +1136,8 @@ class SOMAArray : public SOMAObject { * @return Throws if the requested shape exceeds the array's create-time * maxshape. Throws if the array does not have current-domain support. */ - void resize_soma_joinid_shape(int64_t newshape); + void resize_soma_joinid_shape( + int64_t newshape, std::string function_name_for_messages); protected: // These two are for use nominally by SOMADataFrame. This could be moved in @@ -1198,7 +1206,7 @@ class SOMAArray : public SOMAObject { /** * This is a second-level code-dedupe helper for _can_set_shape_helper. */ - std::pair _can_set_shape_domainish_helper( + std::pair _can_set_shape_domainish_subhelper( const std::vector& newshape, bool check_current_domain, std::string function_name_for_messages); @@ -1206,7 +1214,9 @@ class SOMAArray : public SOMAObject { /** * This is a code-dedupe helper method for resize and upgrade_shape. */ - void _set_current_domain_from_shape(const std::vector& newshape); + void _set_current_domain_from_shape( + const std::vector& newshape, + std::string function_name_for_messages); /** * While SparseNDArray, DenseNDArray, and default-indexed DataFrame diff --git a/libtiledbsoma/test/unit_soma_dataframe.cc b/libtiledbsoma/test/unit_soma_dataframe.cc index 08c5408c24..4a7f114fe7 100644 --- a/libtiledbsoma/test/unit_soma_dataframe.cc +++ b/libtiledbsoma/test/unit_soma_dataframe.cc @@ -472,7 +472,7 @@ TEST_CASE_METHOD( sdf->close(); sdf = open(OpenMode::write); - sdf->resize_soma_joinid_shape(int64_t{new_max}); + sdf->resize_soma_joinid_shape(int64_t{new_max}, "testing"); sdf->close(); sdf = open(OpenMode::write); @@ -591,7 +591,7 @@ TEST_CASE_METHOD( sdf = open(OpenMode::write); // Array not resizeable if it has not already been sized - REQUIRE_THROWS(sdf->resize_soma_joinid_shape(new_shape)); + REQUIRE_THROWS(sdf->resize_soma_joinid_shape(new_shape, "testing")); sdf->close(); } else { @@ -608,11 +608,11 @@ TEST_CASE_METHOD( sdf->close(); sdf = open(OpenMode::read); - REQUIRE_THROWS(sdf->resize_soma_joinid_shape(new_shape)); + REQUIRE_THROWS(sdf->resize_soma_joinid_shape(new_shape, "testing")); sdf->close(); sdf = open(OpenMode::write); - sdf->resize_soma_joinid_shape(new_shape); + sdf->resize_soma_joinid_shape(new_shape, "testing"); sdf->close(); // Check shape after resize @@ -655,23 +655,23 @@ TEST_CASE_METHOD( REQUIRE(maxdom_sjid[1] > 2000000000); } - // Check can_resize_soma_joinid - std::pair check = sdf->can_resize_soma_joinid(1); + // Check can_resize_soma_joinid_shape + std::pair check = sdf->can_resize_soma_joinid_shape( + 1, "testing"); if (!use_current_domain) { REQUIRE(check.first == false); REQUIRE( check.second == - "can_resize_soma_joinid: dataframe currently has no domain " - "set: please use tiledbsoma_upgrade_domain."); + "testing: dataframe currently has no domain set: please " + "upgrade the array."); } else { // Must fail since this is too small. REQUIRE(check.first == false); REQUIRE( check.second == - "cannot resize_soma_joinid_shape: new soma_joinid shape 1 < " - "existing " - "shape 199"); - check = sdf->can_resize_soma_joinid(SOMA_JOINID_RESIZE_DIM_MAX + 1); + "testing: new soma_joinid shape 1 < existing shape 199"); + check = sdf->can_resize_soma_joinid_shape( + SOMA_JOINID_RESIZE_DIM_MAX + 1, "testing"); REQUIRE(check.first == true); REQUIRE(check.second == ""); } @@ -805,7 +805,7 @@ TEST_CASE_METHOD( sdf = open(OpenMode::write); // Array not resizeable if it has not already been sized - REQUIRE_THROWS(sdf->resize_soma_joinid_shape(new_shape)); + REQUIRE_THROWS(sdf->resize_soma_joinid_shape(new_shape, "testing")); sdf->close(); } else { @@ -821,11 +821,11 @@ TEST_CASE_METHOD( sdf->close(); sdf = open(OpenMode::read); - REQUIRE_THROWS(sdf->resize_soma_joinid_shape(new_shape)); + REQUIRE_THROWS(sdf->resize_soma_joinid_shape(new_shape, "testing")); sdf->close(); sdf = open(OpenMode::write); - sdf->resize_soma_joinid_shape(new_shape); + sdf->resize_soma_joinid_shape(new_shape, "testing"); sdf->close(); // Check shape after resize @@ -887,23 +887,23 @@ TEST_CASE_METHOD( REQUIRE(maxdom_u32[1] > 2000000000); } - // Check can_resize_soma_joinid - std::pair check = sdf->can_resize_soma_joinid(1); + // Check can_resize_soma_joinid_shape + std::pair check = sdf->can_resize_soma_joinid_shape( + 1, "testing"); if (!use_current_domain) { REQUIRE(check.first == false); REQUIRE( check.second == - "can_resize_soma_joinid: dataframe currently has no domain " - "set: please use tiledbsoma_upgrade_domain."); + "testing: dataframe currently has no domain set: please " + "upgrade the array."); } else { // Must fail since this is too small. REQUIRE(check.first == false); REQUIRE( check.second == - "cannot resize_soma_joinid_shape: new soma_joinid shape 1 < " - "existing " - "shape 199"); - check = sdf->can_resize_soma_joinid(SOMA_JOINID_RESIZE_DIM_MAX + 1); + "testing: new soma_joinid shape 1 < existing shape 199"); + check = sdf->can_resize_soma_joinid_shape( + SOMA_JOINID_RESIZE_DIM_MAX + 1, "testing"); REQUIRE(check.first == true); REQUIRE(check.second == ""); } @@ -1055,7 +1055,7 @@ TEST_CASE_METHOD( sdf = open(OpenMode::write); // Array not resizeable if it has not already been sized - REQUIRE_THROWS(sdf->resize_soma_joinid_shape(new_shape)); + REQUIRE_THROWS(sdf->resize_soma_joinid_shape(new_shape, "testing")); sdf->close(); } else { @@ -1071,11 +1071,11 @@ TEST_CASE_METHOD( sdf->close(); sdf = open(OpenMode::read); - REQUIRE_THROWS(sdf->resize_soma_joinid_shape(new_shape)); + REQUIRE_THROWS(sdf->resize_soma_joinid_shape(new_shape, "testing")); sdf->close(); sdf = open(OpenMode::write); - sdf->resize_soma_joinid_shape(new_shape); + sdf->resize_soma_joinid_shape(new_shape, "testing"); sdf->close(); // Check shape after resize @@ -1135,23 +1135,23 @@ TEST_CASE_METHOD( REQUIRE(ned_str == std::vector({"", ""})); - // Check can_resize_soma_joinid - std::pair check = sdf->can_resize_soma_joinid(1); + // Check can_resize_soma_joinid_shape + std::pair check = sdf->can_resize_soma_joinid_shape( + 1, "testing"); if (!use_current_domain) { REQUIRE(check.first == false); REQUIRE( check.second == - "can_resize_soma_joinid: dataframe currently has no domain " - "set: please use tiledbsoma_upgrade_domain."); + "testing: dataframe currently has no domain set: please " + "upgrade the array."); } else { // Must fail since this is too small. REQUIRE(check.first == false); REQUIRE( check.second == - "cannot resize_soma_joinid_shape: new soma_joinid shape 1 < " - "existing " - "shape 99"); - check = sdf->can_resize_soma_joinid(SOMA_JOINID_RESIZE_DIM_MAX + 1); + "testing: new soma_joinid shape 1 < existing shape 99"); + check = sdf->can_resize_soma_joinid_shape( + SOMA_JOINID_RESIZE_DIM_MAX + 1, "testing"); REQUIRE(check.first == true); REQUIRE(check.second == ""); } @@ -1286,7 +1286,7 @@ TEST_CASE_METHOD( sdf = open(OpenMode::write); // Array not resizeable if it has not already been sized - REQUIRE_THROWS(sdf->resize_soma_joinid_shape(new_shape)); + REQUIRE_THROWS(sdf->resize_soma_joinid_shape(new_shape, "testing")); sdf->close(); } else { @@ -1297,11 +1297,11 @@ TEST_CASE_METHOD( sdf->close(); sdf = open(OpenMode::read); - REQUIRE_THROWS(sdf->resize_soma_joinid_shape(new_shape)); + REQUIRE_THROWS(sdf->resize_soma_joinid_shape(new_shape, "testing")); sdf->close(); sdf = open(OpenMode::write); - sdf->resize_soma_joinid_shape(new_shape); + sdf->resize_soma_joinid_shape(new_shape, "testing"); sdf->close(); // Check shape after resize -- noting soma_joinid is not a dim here @@ -1344,14 +1344,15 @@ TEST_CASE_METHOD( REQUIRE(maxdom_str == std::vector({"", ""})); } - // Check can_resize_soma_joinid - std::pair check = sdf->can_resize_soma_joinid(0); + // Check can_resize_soma_joinid_shape + std::pair check = sdf->can_resize_soma_joinid_shape( + 0, "testing"); if (!use_current_domain) { REQUIRE(check.first == false); REQUIRE( check.second == - "can_resize_soma_joinid: dataframe currently has no domain " - "set: please use tiledbsoma_upgrade_domain."); + "testing: dataframe currently has no domain set: please " + "upgrade the array."); } else { // Must pass since soma_joinid isn't a dim in this case. REQUIRE(check.first == true); diff --git a/libtiledbsoma/test/unit_soma_dense_ndarray.cc b/libtiledbsoma/test/unit_soma_dense_ndarray.cc index c55a04ce3c..af116c0d30 100644 --- a/libtiledbsoma/test/unit_soma_dense_ndarray.cc +++ b/libtiledbsoma/test/unit_soma_dense_ndarray.cc @@ -147,7 +147,7 @@ TEST_CASE("SOMADenseNDArray: basic", "[SOMADenseNDArray]") { // been sized. // * When use_current_domain is true: TODO: current domain not // supported for dense arrays yet (see above). - REQUIRE_THROWS(dnda->resize(new_shape)); + REQUIRE_THROWS(dnda->resize(new_shape, "testing")); dnda->close(); } } diff --git a/libtiledbsoma/test/unit_soma_sparse_ndarray.cc b/libtiledbsoma/test/unit_soma_sparse_ndarray.cc index fa66faf96e..4d455cedbe 100644 --- a/libtiledbsoma/test/unit_soma_sparse_ndarray.cc +++ b/libtiledbsoma/test/unit_soma_sparse_ndarray.cc @@ -146,9 +146,9 @@ TEST_CASE("SOMASparseNDArray: basic", "[SOMASparseNDArray]") { // Without current-domain support: this should throw since // one cannot resize what has not been sized. REQUIRE(!snda->has_current_domain()); - REQUIRE_THROWS(snda->resize(new_shape)); + REQUIRE_THROWS(snda->resize(new_shape, "testing")); // Now set the shape - snda->upgrade_shape(new_shape); + snda->upgrade_shape(new_shape, "testing"); snda->close(); snda->open(OpenMode::read); @@ -158,7 +158,7 @@ TEST_CASE("SOMASparseNDArray: basic", "[SOMASparseNDArray]") { snda->open(OpenMode::write); REQUIRE(snda->has_current_domain()); // Should not fail since we're setting it to what it already is. - snda->resize(new_shape); + snda->resize(new_shape, "testing"); snda->close(); snda = SOMASparseNDArray::open(uri, OpenMode::read, ctx); @@ -171,8 +171,8 @@ TEST_CASE("SOMASparseNDArray: basic", "[SOMASparseNDArray]") { snda = SOMASparseNDArray::open(uri, OpenMode::write, ctx); // Should throw since this already has a shape (core current // domain). - REQUIRE_THROWS(snda->upgrade_shape(new_shape)); - snda->resize(new_shape); + REQUIRE_THROWS(snda->upgrade_shape(new_shape, "testing")); + snda->resize(new_shape, "testing"); snda->close(); // Try out-of-bounds write after resize. @@ -394,21 +394,21 @@ TEST_CASE( std::vector newshape_too_big({dim_max + 10}); std::vector newshape_good({40}); - auto check = snda->can_upgrade_shape(newshape_wrong_dims); + auto check = snda->can_upgrade_shape(newshape_wrong_dims, "testing"); REQUIRE(check.first == false); REQUIRE( check.second == - "cannot tiledbsoma_upgrade_shape: provided shape has ndim 2, while the " + "testing: provided shape has ndim 2, while the " "array has 1"); - check = snda->can_upgrade_shape(newshape_too_big); + check = snda->can_upgrade_shape(newshape_too_big, "testing"); REQUIRE(check.first == false); REQUIRE( check.second == - "cannot tiledbsoma_upgrade_shape for soma_dim_0: new 1009 < maxshape " + "testing for soma_dim_0: new 1009 < maxshape " "1000"); - check = snda->can_upgrade_shape(newshape_good); + check = snda->can_upgrade_shape(newshape_good, "testing"); REQUIRE(check.first == true); REQUIRE(check.second == ""); } @@ -462,19 +462,18 @@ TEST_CASE("SOMASparseNDArray: can_resize", "[SOMASparseNDArray]") { std::vector newshape_too_small({40}); std::vector newshape_good({2000}); - auto check = snda->can_resize(newshape_wrong_dims); + auto check = snda->can_resize(newshape_wrong_dims, "testing"); REQUIRE(check.first == false); REQUIRE( check.second == - "cannot resize: provided shape has ndim 2, while the array has 1"); + "testing: provided shape has ndim 2, while the array has 1"); - check = snda->can_resize(newshape_too_small); + check = snda->can_resize(newshape_too_small, "testing"); REQUIRE(check.first == false); REQUIRE( - check.second == - "cannot resize for soma_dim_0: new 40 < existing shape 1000"); + check.second == "testing for soma_dim_0: new 40 < existing shape 1000"); - check = snda->can_resize(newshape_good); + check = snda->can_resize(newshape_good, "testing"); REQUIRE(check.first == true); REQUIRE(check.second == ""); }