Skip to content

Commit 2cdbf08

Browse files
committed
Enable and resolve some of the compile-time warnings.
1 parent f01e59f commit 2cdbf08

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

lib/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ target_include_directories(singler PRIVATE "${KNNCOLLE_INCLUDE_DIR}")
2525
set_property(TARGET singler PROPERTY CXX_STANDARD 17)
2626

2727
target_link_libraries(singler PRIVATE pybind11::pybind11)
28+
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
29+
target_compile_options(singler PRIVATE -Wall -Wpedantic -Wextra)
30+
endif()
2831

2932
set_target_properties(singler PROPERTIES
3033
OUTPUT_NAME _lib_singler

lib/src/find_classic_markers.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include "singlepp/singlepp.hpp"
66
#include "tatami/tatami.hpp"
7+
#include "sanisizer/sanisizer.hpp"
78
#include "pybind11/pybind11.h"
89

910
#include <vector>
@@ -12,7 +13,7 @@
1213

1314
pybind11::list find_classic_markers(uint32_t num_labels, uint32_t num_genes, const pybind11::list& reference, const pybind11::list& labels, int de_n, int nthreads) {
1415
size_t num_ref = reference.size();
15-
if (num_ref != static_cast<size_t>(labels.size())) {
16+
if (!sanisizer::is_equal(num_ref, labels.size())) {
1617
throw std::runtime_error("'ref' and 'labels' should have the same length");
1718
}
1819

@@ -24,13 +25,13 @@ pybind11::list find_classic_markers(uint32_t num_labels, uint32_t num_genes, con
2425
for (size_t r = 0; r < num_ref; ++r) {
2526
auto ptr = mattress::cast(reference[r].cast<uintptr_t>())->ptr.get();
2627
ref_ptrs.emplace_back(ptr);
27-
if (ptr->nrow() != num_genes) {
28+
if (!sanisizer::is_equal(ptr->nrow(), num_genes)) {
2829
throw std::runtime_error("each entry of 'ref' should have number of rows equal to 'ngenes'");
2930
}
3031

3132
// No copy, so it's fine to create a pointer and discard the casted array.
3233
auto lab = labels[r].cast<pybind11::array>();
33-
if (lab.size() != static_cast<size_t>(ptr->ncol())) {
34+
if (!sanisizer::is_equal(lab.size(), ptr->ncol())) {
3435
throw std::runtime_error("number of columns in each 'ref' should equal the length of the corresponding entry of 'labels'");
3536
}
3637

lib/src/train_single.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "singlepp/singlepp.hpp"
77
#include "tatami/tatami.hpp"
88
#include "knncolle/knncolle.hpp"
9+
#include "sanisizer/sanisizer.hpp"
910
#include "pybind11/pybind11.h"
1011

1112
#include <vector>
@@ -30,9 +31,8 @@ TrainedSingleIntersectPointer train_single(
3031
typedef std::shared_ptr<knncolle::Builder<knncolle_py::Index, knncolle_py::MatrixValue, knncolle_py::Distance> > BuilderPointer;
3132
opts.trainer = BuilderPointer(BuilderPointer{}, builder.get()); // make a no-op shared pointer.
3233

33-
auto NR = ref->nrow();
3434
auto NC = ref->ncol();
35-
if (static_cast<mattress::MatrixIndex>(labels.size()) != NC) {
35+
if (!sanisizer::is_equal(labels.size(), NC)) {
3636
throw std::runtime_error("length of 'labels' is equal to the number of columns of 'ref'");
3737
}
3838

0 commit comments

Comments
 (0)