Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[c++] Extend some unit-test cases for new shape #3068

Merged
merged 2 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions libtiledbsoma/src/soma/soma_array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1422,11 +1422,6 @@ void SOMAArray::_set_current_domain_from_shape(
// Variant-indexed dataframes must use a separate path
_check_dims_are_int64();

if (_get_current_domain().is_empty()) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was wrong, and not caught sooner b/c I didn't loop over both false & true in the unit-test code.

The is-empty check is done in both callers of this method.

throw TileDBSOMAError(
"[SOMAArray::resize] array must already be sized");
}

auto tctx = ctx_->tiledb_ctx();
ArraySchema schema = arr_->schema();
Domain domain = schema.domain();
Expand Down
18 changes: 14 additions & 4 deletions libtiledbsoma/test/unit_soma_dataframe.cc
Original file line number Diff line number Diff line change
Expand Up @@ -879,8 +879,7 @@ TEST_CASE_METHOD(
VariouslyIndexedDataFrameFixture,
"SOMADataFrame: variant-indexed dataframe dim-sjid-str attr-u32",
"[SOMADataFrame]") {
// auto use_current_domain = GENERATE(false, true);
auto use_current_domain = GENERATE(false);
auto use_current_domain = GENERATE(false, true);
std::ostringstream section;
section << "- use_current_domain=" << use_current_domain;
SECTION(section.str()) {
Expand Down Expand Up @@ -979,7 +978,12 @@ TEST_CASE_METHOD(
REQUIRE(dom_sjid == std::vector<int64_t>({0, 99}));
REQUIRE(dom_str == std::vector<std::string>({"", ""}));

REQUIRE(maxdom_sjid == std::vector<int64_t>({0, 99}));
if (!use_current_domain) {
REQUIRE(maxdom_sjid == std::vector<int64_t>({0, 99}));
} else {
REQUIRE(maxdom_sjid[0] == 0);
REQUIRE(maxdom_sjid[1] > 2000000000);
}
REQUIRE(maxdom_str == std::vector<std::string>({"", ""}));

soma_dataframe->close();
Expand Down Expand Up @@ -1059,7 +1063,13 @@ TEST_CASE_METHOD(
REQUIRE(dom_sjid == std::vector<int64_t>({0, 99}));
REQUIRE(dom_str == std::vector<std::string>({"", ""}));

REQUIRE(maxdom_sjid == std::vector<int64_t>({0, 99}));
if (!use_current_domain) {
REQUIRE(maxdom_sjid == std::vector<int64_t>({0, 99}));
} else {
REQUIRE(maxdom_sjid[0] == 0);
REQUIRE(maxdom_sjid[1] > 2000000000);
}

REQUIRE(maxdom_str == std::vector<std::string>({"", ""}));

REQUIRE(ned_str == std::vector<std::string>({"", ""}));
Expand Down
10 changes: 8 additions & 2 deletions libtiledbsoma/test/unit_soma_sparse_ndarray.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ TEST_CASE("SOMASparseNDArray: basic", "[SOMASparseNDArray]") {
int64_t dim_max = 999;
int64_t shape = 1000;

// auto use_current_domain = GENERATE(false, true);
auto use_current_domain = GENERATE(true);
auto use_current_domain = GENERATE(false, true);
// TODO this could be formatted with fmt::format which is part of internal
// header spd/log/fmt/fmt.h and should not be used. In C++20, this can be
// replaced with std::format.
Expand Down Expand Up @@ -148,6 +147,13 @@ TEST_CASE("SOMASparseNDArray: basic", "[SOMASparseNDArray]") {
REQUIRE_THROWS(soma_sparse->resize(new_shape));
// Now set the shape
soma_sparse->upgrade_shape(new_shape);
soma_sparse->close();

soma_sparse->open(OpenMode::read);
REQUIRE(soma_sparse->has_current_domain());
soma_sparse->close();

soma_sparse->open(OpenMode::write);
REQUIRE(soma_sparse->has_current_domain());
// Should not fail since we're setting it to what it already is.
soma_sparse->resize(new_shape);
Expand Down
Loading