Skip to content

Commit

Permalink
Bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
robomics committed Sep 28, 2023
1 parent 3399bb4 commit a12a1d6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand All @@ -397,7 +397,7 @@ inline void SparseMatrixChunked::marginalize(MargsVector& marg, BS::thread_pool*
std::unique_ptr<ZSTD_DCtx_s> 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)) {
Expand Down Expand Up @@ -440,7 +440,7 @@ inline void SparseMatrixChunked::marginalize_nnz(MargsVector& marg, BS::thread_p
std::unique_ptr<ZSTD_DCtx_s> 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)) {
Expand Down Expand Up @@ -484,7 +484,7 @@ inline void SparseMatrixChunked::times_outer_product_marg(MargsVector& marg,
std::unique_ptr<ZSTD_DCtx_s> 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)) {
Expand Down
12 changes: 6 additions & 6 deletions test/units/balancing/balancing_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ static void compare_vectors(const std::vector<T>& v1, const std::vector<T>& 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<ThinPixel<std::int32_t>> 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()); }
Expand Down Expand Up @@ -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<ThinPixel<std::int32_t>> 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";

Expand Down

0 comments on commit a12a1d6

Please sign in to comment.