diff --git a/src/libhictk/balancing/include/hictk/balancing/impl/sparse_matrix_impl.hpp b/src/libhictk/balancing/include/hictk/balancing/impl/sparse_matrix_impl.hpp index 55016ba0..a152f6f6 100644 --- a/src/libhictk/balancing/include/hictk/balancing/impl/sparse_matrix_impl.hpp +++ b/src/libhictk/balancing/include/hictk/balancing/impl/sparse_matrix_impl.hpp @@ -351,7 +351,7 @@ inline SparseMatrixChunked::SparseMatrixChunked(std::filesystem::path tmp_file, _zstd_cctx(ZSTD_createCCtx()), _zstd_dctx(ZSTD_createDCtx()) { _fs.exceptions(std::ios::badbit); - _fs.open(_path, std::ios::out); + _fs.open(_path, std::ios::out | std::ios::binary); } inline SparseMatrixChunked::~SparseMatrixChunked() noexcept { @@ -388,7 +388,7 @@ inline void SparseMatrixChunked::finalize() { if (!_matrix.empty()) { write_chunk(); } - _fs.open(_path, std::ios::in); + _fs.open(_path, std::ios::in | std::ios::binary); } inline void SparseMatrixChunked::marginalize(MargsVector& marg, BS::thread_pool* tpool, @@ -397,7 +397,7 @@ inline void SparseMatrixChunked::marginalize(MargsVector& marg, BS::thread_pool* std::unique_ptr zstd_dctx(ZSTD_createDCtx()); std::fstream fs{}; fs.exceptions(_fs.exceptions()); - fs.open(_path, std::ios::in); + fs.open(_path, std::ios::in | std::ios::binary); auto matrix = _matrix; MargsVector marg_local(marg.size()); for (const auto offset : nonstd::span(_index).subspan(istart, iend - istart)) { @@ -440,7 +440,7 @@ inline void SparseMatrixChunked::marginalize_nnz(MargsVector& marg, BS::thread_p std::unique_ptr zstd_dctx(ZSTD_createDCtx()); std::fstream fs{}; fs.exceptions(_fs.exceptions()); - fs.open(_path, std::ios::in); + fs.open(_path, std::ios::in | std::ios::binary); auto matrix = _matrix; MargsVector marg_local(marg.size()); for (const auto offset : nonstd::span(_index).subspan(istart, iend - istart)) { @@ -484,7 +484,7 @@ inline void SparseMatrixChunked::times_outer_product_marg(MargsVector& marg, std::unique_ptr zstd_dctx(ZSTD_createDCtx()); std::fstream fs{}; fs.exceptions(_fs.exceptions()); - fs.open(_path, std::ios::in); + fs.open(_path, std::ios::in | std::ios::binary); auto matrix = _matrix; MargsVector marg_local(marg.size()); for (const auto offset : nonstd::span(_index).subspan(istart, iend - istart)) { diff --git a/test/units/balancing/balancing_test.cpp b/test/units/balancing/balancing_test.cpp index 68e01231..7c994305 100644 --- a/test/units/balancing/balancing_test.cpp +++ b/test/units/balancing/balancing_test.cpp @@ -55,15 +55,15 @@ static void compare_vectors(const std::vector& v1, const std::vector& v2) } // NOLINTNEXTLINE(readability-function-cognitive-complexity) -TEST_CASE("Balancing: SparseMatrix") { +TEST_CASE("Balancing: SparseMatrix", "[balancing][short]") { using SparseMatrix = hictk::balancing::SparseMatrix; const BinTable bins{Reference{Chromosome{0, "chr0", 50}, Chromosome{1, "chr1", 100}, Chromosome{2, "chr2", 50}, Chromosome{3, "chr3", 50}}, 50}; // clang-format off const std::vector> pixels{ - {1, 0, 1}, {1, 1, 2}, {2, 1, 3}, // chr1 - {3, 0, 4}, {3, 1, 5}}; // chr2 + {1, 1, 1}, {1, 2, 2}, {2, 2, 3}, // chr1 + {3, 3, 4}, {3, 4, 5}}; // chr2 // clang-format on SECTION("accessors") { CHECK(SparseMatrix{}.empty()); } @@ -126,15 +126,15 @@ TEST_CASE("Balancing: SparseMatrix") { } // NOLINTNEXTLINE(readability-function-cognitive-complexity) -TEST_CASE("Balancing: SparseMatrixChunked") { +TEST_CASE("Balancing: SparseMatrixChunked", "[balancing][short]") { using SparseMatrixChunked = hictk::balancing::SparseMatrixChunked; const BinTable bins{Reference{Chromosome{0, "chr0", 50}, Chromosome{1, "chr1", 100}, Chromosome{2, "chr2", 50}, Chromosome{3, "chr3", 50}}, 50}; // clang-format off const std::vector> pixels{ - {1, 0, 1}, {1, 1, 2}, {2, 1, 3}, // chr1 - {3, 0, 4}, {3, 1, 5}}; // chr2 + {1, 1, 1}, {1, 2, 2}, {2, 2, 3}, // chr1 + {3, 3, 4}, {3, 4, 5}}; // chr2 // clang-format on const auto tmpfile = testdir() / "sparse_matrix_chunked.tmp";