diff --git a/apis/python/src/tiledbsoma/pytiledbsoma.cc b/apis/python/src/tiledbsoma/pytiledbsoma.cc index 2936478d7d..3bc48fb3ca 100644 --- a/apis/python/src/tiledbsoma/pytiledbsoma.cc +++ b/apis/python/src/tiledbsoma/pytiledbsoma.cc @@ -693,6 +693,12 @@ PYBIND11_MODULE(pytiledbsoma, m) { .def_property_readonly("shape", &SOMAArray::shape) + .def_property_readonly("uri", &SOMAArray::uri) + + .def_property_readonly("column_names", &SOMAArray::column_names) + + .def_property_readonly("result_order", &SOMAArray::result_order) + .def("get_enum", get_enum) .def("get_enum_is_ordered", get_enum_is_ordered) diff --git a/libtiledbsoma/src/soma/soma_array.h b/libtiledbsoma/src/soma/soma_array.h index 46d0367eaf..a18c9fdbe4 100644 --- a/libtiledbsoma/src/soma/soma_array.h +++ b/libtiledbsoma/src/soma/soma_array.h @@ -354,6 +354,15 @@ class SOMAArray { return mq_->column_names(); } + /** + * @brief Returns the result order set by the query. + * + * @return ResultOrder + */ + ResultOrder result_order() { + return result_order_; + } + /** * @brief Read the next chunk of results from the query. If all results * have already been read, std::nullopt is returned. @@ -660,4 +669,4 @@ class SOMAArray { } // namespace tiledbsoma -#endif // SOMA_ARRAY \ No newline at end of file +#endif // SOMA_ARRAY diff --git a/libtiledbsoma/test/test_soma_array.py b/libtiledbsoma/test/test_soma_array.py index 76650435e4..4139c1cf3b 100644 --- a/libtiledbsoma/test/test_soma_array.py +++ b/libtiledbsoma/test/test_soma_array.py @@ -15,6 +15,30 @@ clib.config_logging("debug") +def test_soma_array_basic_getters(): + name = "obs" + uri = os.path.join(SOMA_URI, name) + column_names = [ + "soma_joinid", + "obs_id", + "n_genes", + "percent_mito", + "n_counts", + "louvain", + "is_b_cell", + ] + result_order = clib.ResultOrder.colmajor + + sr = clib.SOMAArray( + uri=uri, name=name, column_names=column_names, result_order=result_order + ) + + assert sr.uri == uri + assert sr.nnz() == 2638 + assert sr.result_order == result_order + assert sr.column_names == column_names + + def test_soma_array_obs(): """Read all values from obs array into an arrow table.""" @@ -225,16 +249,6 @@ def test_soma_array_column_names(): assert arrow_table.num_columns == 2 -def test_nnz(): - name = "obs" - uri = os.path.join(SOMA_URI, name) - sr = clib.SOMAArray(uri) - - total_cell_count = sr.nnz() - - assert total_cell_count == 2638 - - def test_soma_array_reset(): """Submit a query with a SOMAArray object, reset the SOMAArray, and submit another query."""