Skip to content

Commit

Permalink
Avoid warnings for signed integer comparison in choose_hvgs_index.
Browse files Browse the repository at this point in the history
  • Loading branch information
LTLA committed Aug 18, 2024
1 parent 919afd0 commit 4f2038d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.14)

project(scran_variances
VERSION 0.1.0
VERSION 0.1.1
DESCRIPTION "Model per-gene variances in single-cell expression"
LANGUAGES CXX)

Expand Down
2 changes: 1 addition & 1 deletion include/scran_variances/choose_highly_variable_genes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ std::vector<Bool_> choose_highly_variable_genes(size_t n, const Stat_* statistic
*/
template<typename Index_, typename Stat_>
std::vector<Index_> choose_highly_variable_genes_index(Index_ n, const Stat_* statistic, const ChooseHighlyVariableGenesOptions& options) {
if (options.top >= n) {
if (options.top >= static_cast<size_t>(n)) {
std::vector<Index_> output(n);
std::iota(output.begin(), output.end(), static_cast<Index_>(0));
return output;
Expand Down
3 changes: 3 additions & 0 deletions tests/src/choose_highly_variable_genes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ TEST_P(ChooseHvgsTest, Basic) {
auto ioutput = scran_variances::choose_highly_variable_genes_index(ngenes, x.data(), opt);
compare_bool_with_index(output, ioutput);

auto ioutput2 = scran_variances::choose_highly_variable_genes_index<int>(ngenes, x.data(), opt); // check for different integer types.
EXPECT_EQ(std::vector<size_t>(ioutput2.begin(), ioutput2.end()), ioutput);

// Checking that it works for smaller values.
opt.larger = false;
auto output_low = scran_variances::choose_highly_variable_genes(ngenes, x.data(), opt);
Expand Down

0 comments on commit 4f2038d

Please sign in to comment.