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

[python] Fix readback of some older-style metadata #3653

Merged
merged 2 commits into from
Jan 31, 2025
Merged
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
4 changes: 2 additions & 2 deletions apis/python/src/tiledbsoma/common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ py::dict meta(std::map<std::string, MetadataValue> metadata_mapping) {
for (auto [key, val] : metadata_mapping) {
auto [tdb_type, value_num, value] = val;

if (tdb_type == TILEDB_STRING_UTF8) {
if (tdb_type == TILEDB_STRING_UTF8 || tdb_type == TILEDB_STRING_ASCII) {
// Empty strings stored as nullptr have a value_num of 1 and a \x00
// value
if (value_num == 1 && value == nullptr) {
Expand All @@ -235,7 +235,7 @@ py::dict meta(std::map<std::string, MetadataValue> metadata_mapping) {
results[py::str(key)] = py::array(value_type, value_num, value)
.attr("item")(0);
} else {
py::dtype value_type = tdb_to_np_dtype(tdb_type, 1);
py::dtype value_type = tdb_to_np_dtype(tdb_type, value_num);
Copy link
Member Author

Choose a reason for hiding this comment

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

Either of these two lines fix the symptom. As noted in the description field, though, we need more unit-test coverage here.

Copy link
Member Author

Choose a reason for hiding this comment

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

results[py::str(key)] = py::array(value_type, value_num, value)
.attr("item")(0);
}
Expand Down