Skip to content

Commit c25df53

Browse files
committed
Updates to use the latest versions of all dependencies.
1 parent 246d648 commit c25df53

File tree

10 files changed

+118
-80
lines changed

10 files changed

+118
-80
lines changed

CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required(VERSION 3.14)
22

33
project(singlepp_loaders
4-
VERSION 0.1.1
4+
VERSION 0.2.0
55
DESCRIPTION "Load pre-prepared reference datasets for SingleR"
66
LANGUAGES CXX)
77

@@ -22,9 +22,9 @@ option(SINGLEPP_LOADERS_FETCH_EXTERN "Automatically fetch singlepp_loaders's ext
2222
if(SINGLEPP_LOADERS_FETCH_EXTERN)
2323
add_subdirectory(extern)
2424
else()
25-
find_package(singler_singlepp 2.0.0 CONFIG REQUIRED)
26-
find_package(tatami_tatami 3.0.0 CONFIG REQUIRED)
27-
find_package(ltla_byteme 1.2.0 CONFIG REQUIRED)
25+
find_package(singler_singlepp 3.0.0 CONFIG REQUIRED)
26+
find_package(tatami_tatami 4.0.0 CONFIG REQUIRED)
27+
find_package(ltla_byteme 2.0.0 CONFIG REQUIRED)
2828
endif()
2929

3030
target_link_libraries(singlepp_loaders INTERFACE singler::singlepp tatami::tatami ltla::byteme)

cmake/Config.cmake.in

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
@PACKAGE_INIT@
22

33
include(CMakeFindDependencyMacro)
4-
find_dependency(tatami_tatami 3.0.0 CONFIG REQUIRED)
5-
find_dependency(singler_singlepp 2.0.0 CONFIG REQUIRED)
6-
find_dependency(ltla_byteme 1.2.0 CONFIG REQUIRED)
4+
find_dependency(tatami_tatami 4.0.0 CONFIG REQUIRED)
5+
find_dependency(singler_singlepp 3.0.0 CONFIG REQUIRED)
6+
find_dependency(ltla_byteme 2.0.0 CONFIG REQUIRED)
77

88
include("${CMAKE_CURRENT_LIST_DIR}/singler_singlepp_loadersTargets.cmake")

extern/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ include(FetchContent)
33
FetchContent_Declare(
44
singlepp
55
GIT_REPOSITORY https://github.com/SingleR-inc/singlepp
6-
GIT_TAG master # ^2.0.0
6+
GIT_TAG master # ^3.0.0
77
)
88

99
FetchContent_Declare(
1010
tatami
1111
GIT_REPOSITORY https://github.com/tatami-inc/tatami
12-
GIT_TAG master # ^3.0.0
12+
GIT_TAG master # ^4.0.0
1313
)
1414

1515
FetchContent_Declare(
1616
byteme
1717
GIT_REPOSITORY https://github.com/LTLA/byteme
18-
GIT_TAG master # ^1.2.0
18+
GIT_TAG master # ^2.0.0
1919
)
2020

2121
FetchContent_MakeAvailable(singlepp)

include/singlepp_loaders/labels.hpp

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,20 @@ struct LoadLabelsOptions {
4242
*/
4343
namespace internal {
4444

45-
template<typename Label_, bool parallel_>
46-
std::vector<Label_> load_labels(byteme::Reader& reader) {
45+
template<typename Label_>
46+
std::vector<Label_> load_labels(byteme::Reader& reader, bool parallel) {
4747
bool non_empty = false;
4848
int current = 0;
4949
std::vector<Label_> labels;
5050

51-
typename std::conditional<parallel_, byteme::PerByte<char>, byteme::PerByteParallel<char> >::type pb(&reader);
51+
std::unique_ptr<byteme::PerByteInterface<char> > pbptr;
52+
if (parallel) {
53+
pbptr.reset(new byteme::PerByteParallel<char, byteme::Reader*>(&reader));
54+
} else {
55+
pbptr.reset(new byteme::PerByteSerial<char, byteme::Reader*>(&reader));
56+
}
57+
auto& pb = *pbptr;
58+
5259
bool okay = pb.valid();
5360
while (okay) {
5461
char x = pb.get();
@@ -77,15 +84,6 @@ std::vector<Label_> load_labels(byteme::Reader& reader) {
7784
return labels;
7885
}
7986

80-
template<typename Label_>
81-
std::vector<Label_> load_labels(byteme::Reader& reader, bool parallel) {
82-
if (parallel) {
83-
return load_labels<Label_, true>(reader);
84-
} else {
85-
return load_labels<Label_, false>(reader);
86-
}
87-
}
88-
8987
}
9088
/**
9189
* @endcond
@@ -106,7 +104,9 @@ std::vector<Label_> load_labels(byteme::Reader& reader, bool parallel) {
106104
*/
107105
template<typename Label_ = singlepp::DefaultLabel>
108106
std::vector<Label_> load_labels_from_text_file(const char* path, const LoadLabelsOptions& options) {
109-
byteme::RawFileReader reader(path, options.buffer_size);
107+
byteme::RawFileReaderOptions read_opt;
108+
read_opt.buffer_size = options.buffer_size;
109+
byteme::RawFileReader reader(path, read_opt);
110110
return internal::load_labels<Label_>(reader, options.parallel);
111111
}
112112

@@ -122,7 +122,9 @@ std::vector<Label_> load_labels_from_text_file(const char* path, const LoadLabel
122122
*/
123123
template<typename Label_ = singlepp::DefaultLabel>
124124
std::vector<Label_> load_labels_from_gzip_file(const char* path, const LoadLabelsOptions& options) {
125-
byteme::GzipFileReader reader(path, options.buffer_size);
125+
byteme::GzipFileReaderOptions read_opt;
126+
read_opt.buffer_size = options.buffer_size;
127+
byteme::GzipFileReader reader(path, read_opt);
126128
return internal::load_labels<Label_>(reader, options.parallel);
127129
}
128130

@@ -139,7 +141,10 @@ std::vector<Label_> load_labels_from_gzip_file(const char* path, const LoadLabel
139141
*/
140142
template<typename Label_ = singlepp::DefaultLabel>
141143
std::vector<Label_> load_labels_from_zlib_buffer(const unsigned char* buffer, size_t len, const LoadLabelsOptions& options) {
142-
byteme::ZlibBufferReader reader(buffer, len, 3, options.buffer_size);
144+
byteme::ZlibBufferReaderOptions read_opt;
145+
read_opt.mode = 3;
146+
read_opt.buffer_size = options.buffer_size;
147+
byteme::ZlibBufferReader reader(buffer, len, read_opt);
143148
return internal::load_labels<Label_>(reader, options.parallel);
144149
}
145150

include/singlepp_loaders/markers.hpp

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,17 @@ struct LoadMarkersOptions {
4242
*/
4343
namespace internal {
4444

45-
template<typename Index_, bool parallel_>
46-
singlepp::Markers<Index_> load_markers(byteme::Reader& reader) {
45+
template<typename Index_>
46+
singlepp::Markers<Index_> load_markers(byteme::Reader& reader, bool parallel) {
4747
singlepp::Markers<Index_> markers;
48-
typename std::conditional<parallel_, byteme::PerByte<char>, byteme::PerByteParallel<char> >::type pb(&reader);
48+
49+
std::unique_ptr<byteme::PerByteInterface<char> > pbptr;
50+
if (parallel) {
51+
pbptr.reset(new byteme::PerByteParallel<char, byteme::Reader*>(&reader));
52+
} else {
53+
pbptr.reset(new byteme::PerByteSerial<char, byteme::Reader*>(&reader));
54+
}
55+
auto& pb = *pbptr;
4956

5057
bool okay = pb.valid();
5158
while (okay) {
@@ -142,15 +149,6 @@ singlepp::Markers<Index_> load_markers(byteme::Reader& reader) {
142149
return markers;
143150
}
144151

145-
template<typename Index_>
146-
singlepp::Markers<Index_> load_markers(byteme::Reader& reader, bool parallel) {
147-
if (parallel) {
148-
return load_markers<Index_, true>(reader);
149-
} else {
150-
return load_markers<Index_, false>(reader);
151-
}
152-
}
153-
154152
}
155153
/**
156154
* @endcond
@@ -172,7 +170,9 @@ singlepp::Markers<Index_> load_markers(byteme::Reader& reader, bool parallel) {
172170
*/
173171
template<typename Index_ = singlepp::DefaultIndex>
174172
singlepp::Markers<Index_> load_markers_from_text_file(const char* path, const LoadMarkersOptions& options) {
175-
byteme::RawFileReader reader(path, options.buffer_size);
173+
byteme::RawFileReaderOptions read_opt;
174+
read_opt.buffer_size = options.buffer_size;
175+
byteme::RawFileReader reader(path, read_opt);
176176
return internal::load_markers<Index_>(reader, options.parallel);
177177
}
178178

@@ -188,7 +188,9 @@ singlepp::Markers<Index_> load_markers_from_text_file(const char* path, const Lo
188188
*/
189189
template<typename Index_ = singlepp::DefaultIndex>
190190
singlepp::Markers<Index_> load_markers_from_gzip_file(const char* path, const LoadMarkersOptions& options) {
191-
byteme::GzipFileReader reader(path, options.buffer_size);
191+
byteme::GzipFileReaderOptions read_opt;
192+
read_opt.buffer_size = options.buffer_size;
193+
byteme::GzipFileReader reader(path, read_opt);
192194
return internal::load_markers<Index_>(reader, options.parallel);
193195
}
194196

@@ -205,7 +207,10 @@ singlepp::Markers<Index_> load_markers_from_gzip_file(const char* path, const Lo
205207
*/
206208
template<typename Index_ = singlepp::DefaultIndex>
207209
singlepp::Markers<Index_> load_markers_from_zlib_buffer(const unsigned char* buffer, size_t len, const LoadMarkersOptions& options) {
208-
byteme::ZlibBufferReader reader(buffer, len, 3, options.buffer_size);
210+
byteme::ZlibBufferReaderOptions read_opt;
211+
read_opt.mode = 3;
212+
read_opt.buffer_size = options.buffer_size;
213+
byteme::ZlibBufferReader reader(buffer, len, read_opt);
209214
return internal::load_markers<Index_>(reader, options.parallel);
210215
}
211216

include/singlepp_loaders/rankings.hpp

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ struct LoadRankingsOptions {
5555
*/
5656
namespace internal {
5757

58-
template<typename Value_, typename Index_, bool parallel_>
59-
RankMatrix<Value_, Index_> load_rankings(byteme::Reader& reader) {
58+
template<typename Value_, typename Index_>
59+
RankMatrix<Value_, Index_> load_rankings(byteme::Reader& reader, bool parallel) {
6060
size_t nfeatures = 0;
6161
size_t line = 0;
6262
std::vector<int> values;
@@ -75,7 +75,14 @@ RankMatrix<Value_, Index_> load_rankings(byteme::Reader& reader) {
7575
}
7676
};
7777

78-
typename std::conditional<parallel_, byteme::PerByte<char>, byteme::PerByteParallel<char> >::type pb(&reader);
78+
std::unique_ptr<byteme::PerByteInterface<char> > pbptr;
79+
if (parallel) {
80+
pbptr.reset(new byteme::PerByteParallel<char, byteme::Reader*>(&reader));
81+
} else {
82+
pbptr.reset(new byteme::PerByteSerial<char, byteme::Reader*>(&reader));
83+
}
84+
auto& pb = *pbptr;
85+
7986
bool okay = pb.valid();
8087
while (okay) {
8188
char x = pb.get();
@@ -123,15 +130,6 @@ RankMatrix<Value_, Index_> load_rankings(byteme::Reader& reader) {
123130
return RankMatrix<Value_, Index_>(nfeatures, line, std::move(values), false);
124131
}
125132

126-
template<typename Value_, typename Index_>
127-
RankMatrix<Value_, Index_> load_rankings(byteme::Reader& reader, bool parallel) {
128-
if (parallel) {
129-
return load_rankings<Value_, Index_, true>(reader);
130-
} else {
131-
return load_rankings<Value_, Index_, false>(reader);
132-
}
133-
}
134-
135133
}
136134
/**
137135
* @endcond
@@ -154,7 +152,9 @@ RankMatrix<Value_, Index_> load_rankings(byteme::Reader& reader, bool parallel)
154152
*/
155153
template<typename Value_ = singlepp::DefaultValue, typename Index_ = singlepp::DefaultIndex>
156154
RankMatrix<Value_, Index_> load_rankings_from_text_file(const char* path, const LoadRankingsOptions& options) {
157-
byteme::RawFileReader reader(path, options.buffer_size);
155+
byteme::RawFileReaderOptions read_opt;
156+
read_opt.buffer_size = options.buffer_size;
157+
byteme::RawFileReader reader(path, read_opt);
158158
return internal::load_rankings<Value_, Index_>(reader, options.parallel);
159159
}
160160

@@ -172,7 +172,9 @@ RankMatrix<Value_, Index_> load_rankings_from_text_file(const char* path, const
172172
*/
173173
template<typename Value_ = singlepp::DefaultValue, typename Index_ = singlepp::DefaultIndex>
174174
RankMatrix<Value_, Index_> load_rankings_from_gzip_file(const char* path, const LoadRankingsOptions& options) {
175-
byteme::GzipFileReader reader(path, options.buffer_size);
175+
byteme::GzipFileReaderOptions read_opt;
176+
read_opt.buffer_size = options.buffer_size;
177+
byteme::GzipFileReader reader(path, read_opt);
176178
return internal::load_rankings<Value_, Index_>(reader, options.parallel);
177179
}
178180

@@ -191,7 +193,10 @@ RankMatrix<Value_, Index_> load_rankings_from_gzip_file(const char* path, const
191193
*/
192194
template<typename Value_ = singlepp::DefaultValue, typename Index_ = singlepp::DefaultIndex>
193195
RankMatrix<Value_, Index_> load_rankings_from_zlib_buffer(const unsigned char* buffer, size_t len, const LoadRankingsOptions& options) {
194-
byteme::ZlibBufferReader reader(buffer, len, 3, options.buffer_size);
196+
byteme::ZlibBufferReaderOptions read_opt;
197+
read_opt.mode = 3;
198+
read_opt.buffer_size = options.buffer_size;
199+
byteme::ZlibBufferReader reader(buffer, len, read_opt);
195200
return internal::load_rankings<Value_, Index_>(reader, options.parallel);
196201
}
197202

tests/src/labels.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include <gtest/gtest.h>
22

33
#include "singlepp_loaders/labels.hpp"
4-
#include "byteme/temp_file_path.hpp"
4+
#include "temp_file_path.h"
55
#include "zlib.h"
66

77
#include "utils.h"
@@ -13,7 +13,7 @@
1313
class LoadLabelsTest : public ::testing::TestWithParam<std::tuple<int, bool> > {};
1414

1515
TEST_P(LoadLabelsTest, TextFile) {
16-
auto path = byteme::temp_file_path("lab_text");
16+
auto path = temp_file_path("lab_text");
1717
std::vector<int> labels;
1818
{
1919
std::ofstream out(path, std::ofstream::out);
@@ -33,7 +33,7 @@ TEST_P(LoadLabelsTest, TextFile) {
3333
}
3434

3535
TEST_P(LoadLabelsTest, GzipFile) {
36-
auto path = byteme::temp_file_path("lab_gzip");
36+
auto path = temp_file_path("lab_gzip");
3737
std::vector<int> labels;
3838
{
3939
std::string output;
@@ -84,20 +84,20 @@ void quick_label_err(std::string path, std::string msg) {
8484

8585
TEST(LoadLabels, EdgeCases) {
8686
{
87-
auto path = byteme::temp_file_path("label_err");
87+
auto path = temp_file_path("label_err");
8888
quick_dump(path, "1\n2\n3a\n4\n");
8989
quick_label_err(path, "must be an integer");
9090
}
9191

9292
{
93-
auto path = byteme::temp_file_path("label_err");
93+
auto path = temp_file_path("label_err");
9494
quick_dump(path, "1\n2\n\n4\n");
9595
quick_label_err(path, "must be an integer");
9696
}
9797

9898
// Non-newline termination is ok, as are empty fields.
9999
{
100-
auto path = byteme::temp_file_path("feat_ok");
100+
auto path = temp_file_path("feat_ok");
101101
quick_dump(path, "1\n2");
102102
auto output = singlepp_loaders::load_labels_from_text_file(path.c_str(), singlepp_loaders::LoadLabelsOptions());
103103
EXPECT_EQ(output.size(), 2);

0 commit comments

Comments
 (0)