From 08931d3f4a58d6456f0eb203e2c099389c4a19ae Mon Sep 17 00:00:00 2001 From: Behnam Robatmili Date: Thu, 18 Jan 2024 12:52:05 -0800 Subject: [PATCH] [c++, python] Apply latest reviews for re-indexer --- .github/workflows/r-ci.yml | 3 --- apis/python/src/tiledbsoma/_experiment.py | 1 + libtiledbsoma/src/reindexer/example.py | 2 +- libtiledbsoma/src/reindexer/reindexer.cc | 13 +++---------- libtiledbsoma/src/reindexer/reindexer.h | 8 ++++++-- libtiledbsoma/test/test_indexer.cc | 4 ++-- libtiledbsoma/test/test_indexer.py | 6 +----- 7 files changed, 14 insertions(+), 23 deletions(-) diff --git a/.github/workflows/r-ci.yml b/.github/workflows/r-ci.yml index a9d812d250..70af88732e 100644 --- a/.github/workflows/r-ci.yml +++ b/.github/workflows/r-ci.yml @@ -51,9 +51,6 @@ jobs: - name: Bootstrap run: cd apis/r && tools/r-ci.sh bootstrap - - name: Install tiledb - run: cd apis/r && Rscript -e 'remotes::install_version("tiledb", "0.22.0")' - - name: Install BioConductor package SingleCellExperiment run: cd apis/r && tools/r-ci.sh install_bioc SingleCellExperiment diff --git a/apis/python/src/tiledbsoma/_experiment.py b/apis/python/src/tiledbsoma/_experiment.py index c2b3c94936..25c31e28d5 100644 --- a/apis/python/src/tiledbsoma/_experiment.py +++ b/apis/python/src/tiledbsoma/_experiment.py @@ -45,6 +45,7 @@ class Experiment( # type: ignore[misc] # __eq__ false positive A collection of named measurements. Example: + >>> import tiledbsoma >>> with tiledbsoma.open("/path/to/experiment") as exp: ... # While users can interact directly with an Experiment's fields: ... obs_df = exp.obs diff --git a/libtiledbsoma/src/reindexer/example.py b/libtiledbsoma/src/reindexer/example.py index 1bf6ca5b9f..3b2a8b9c8e 100644 --- a/libtiledbsoma/src/reindexer/example.py +++ b/libtiledbsoma/src/reindexer/example.py @@ -11,7 +11,7 @@ def main(): with cellxgene_census.open_soma(**census_s3) as census: with census["census_data"]["homo_sapiens"].axis_query( measurement_name="RNA", - obs_query=soma.AxisQuery(value_filter="""tissue_general == 'eye'"""), + obs_query=soma.AxisQuery(value_filter="tissue_general == 'eye'"), ) as query: query.to_anndata(X_name="raw") t2 = perf_counter() diff --git a/libtiledbsoma/src/reindexer/reindexer.cc b/libtiledbsoma/src/reindexer/reindexer.cc index 0ef486016a..68331f7587 100644 --- a/libtiledbsoma/src/reindexer/reindexer.cc +++ b/libtiledbsoma/src/reindexer/reindexer.cc @@ -5,7 +5,7 @@ * * The MIT License * - * @copyright Copyright (c) 2022 TileDB, Inc. + * @copyright Copyright (c) 2024 TileDB, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -76,11 +76,7 @@ void IntIndexer::map_locations(const int64_t* keys, int size, int threads) { int64_t counter = 0; // Hash map construction for (int i = 0; i < size; i++) { - k = kh_put( - m64, - hash_, - keys[i], - &ret); // hash_wrapper::put(hash_, key, &ret); + k = kh_put(m64, hash_, keys[i], &ret); assert(k != kh_end(hash_)); kh_val(hash_, k) = counter; counter++; @@ -100,10 +96,7 @@ void IntIndexer::lookup(const int64_t* keys, int64_t* results, int size) { size)); if (tiledb_thread_pool_->concurrency_level() == 1) { for (int i = 0; i < size; i++) { - auto k = kh_get( - m64, - hash_, - keys[i]); // hash_wrapper::get(hash_, keys[i]); + auto k = kh_get(m64, hash_, keys[i]); if (k == kh_end(hash_)) { // According to pandas behavior results[i] = -1; diff --git a/libtiledbsoma/src/reindexer/reindexer.h b/libtiledbsoma/src/reindexer/reindexer.h index 076a13f9d6..a83305bcac 100644 --- a/libtiledbsoma/src/reindexer/reindexer.h +++ b/libtiledbsoma/src/reindexer/reindexer.h @@ -5,7 +5,7 @@ * * The MIT License * - * @copyright Copyright (c) 2022 TileDB, Inc. + * @copyright Copyright (c) 2024 TileDB, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,9 @@ * This file defines the a pybind11 api into SOMA C++ library. */ -#pragma once +#ifndef TILEDBSOMA_REINDEXER_H +#define TILEDBSOMA_REINDEXER_H + #include #include #include @@ -97,3 +99,5 @@ class IntIndexer { }; } // namespace tiledbsoma + +#endif // TILEDBSOMA_REINDEXER_H \ No newline at end of file diff --git a/libtiledbsoma/test/test_indexer.cc b/libtiledbsoma/test/test_indexer.cc index 96d035d920..dc324eb1ee 100644 --- a/libtiledbsoma/test/test_indexer.cc +++ b/libtiledbsoma/test/test_indexer.cc @@ -5,7 +5,7 @@ * * The MIT License * - * @copyright Copyright (c) 2022 TileDB, Inc. + * @copyright Copyright (c) 2024 TileDB, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -27,7 +27,7 @@ * * @section DESCRIPTION * - * This file manages unit tests for column buffers + * This file manages unit tests for re-indexer */ #include diff --git a/libtiledbsoma/test/test_indexer.py b/libtiledbsoma/test/test_indexer.py index 334b7ec338..3bbd9ec520 100644 --- a/libtiledbsoma/test/test_indexer.py +++ b/libtiledbsoma/test/test_indexer.py @@ -182,10 +182,6 @@ def indexer_test_pass(keys: np.array, lookups: np.array): ] -def main(): +def test_indexer(): for data in test_data: indexer_test(data["keys"], data["lookups"], not data["pass"]) - - -if __name__ == "__main__": - main()