Skip to content

Commit

Permalink
[MISC] automatic linting
Browse files Browse the repository at this point in the history
  • Loading branch information
seqan-actions committed Jul 12, 2024
1 parent 0d08759 commit 5d7acc9
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 25 deletions.
10 changes: 5 additions & 5 deletions include/hibf/sketch/compute_sketches.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ void compute_sketches(config const & config,
std::vector<sketch::hyperloglog> & sketches);

void compute_sketches_with_minhash(config const & config,
std::vector<sketch::hyperloglog> & sketches,
std::vector<sketch::minHashes> & minHash_sketches);
std::vector<sketch::hyperloglog> & sketches,
std::vector<sketch::minHashes> & minHash_sketches);

void compute_sketches_with_minhash(config const & config,
std::vector<size_t> & kmer_counts,
std::vector<sketch::hyperloglog> & sketches,
std::vector<sketch::minHashes> & minHash_sketches);
std::vector<size_t> & kmer_counts,
std::vector<sketch::hyperloglog> & sketches,
std::vector<sketch::minHashes> & minHash_sketches);

} // namespace seqan::hibf::sketch
10 changes: 5 additions & 5 deletions include/hibf/sketch/minHashes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ struct minHashes
}
}

inline static uint64_t const register_id_mask{15}; /// ...00001111
inline static size_t const num_sketches{16};
inline static size_t const sketch_size{40};
static inline uint64_t const register_id_mask{15}; /// ...00001111
static inline size_t const num_sketches{16};
static inline size_t const sketch_size{40};

//!\brief A table of sketches. For LSH we need multiple sketches, stored in a table.
std::vector<std::vector<uint64_t>> table{};
Expand Down Expand Up @@ -90,8 +90,8 @@ struct minHashes
if (k_hash < heap[0]) // 0 because it is a max heap
{
// we do not need a guard (hash table) to check for duplications because `kmers` is already a set
std::pop_heap(heap.begin(), heap.end()); // max elements move to end of vector
heap.back() = k_hash; // replace last elements instead of physically popping and pushing
std::pop_heap(heap.begin(), heap.end()); // max elements move to end of vector
heap.back() = k_hash; // replace last elements instead of physically popping and pushing
std::push_heap(heap.begin(), heap.end()); // last elements is rearranged in the heap to be pushed
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/sketch/compute_sketches.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#include <cinttypes> // for uint64_t
#include <cstddef> // for size_t
#include <functional> // for function
#include <span> // for vector
#include <vector> // for vector
#include <span> // for vector

#include <hibf/config.hpp> // for config, insert_iterator
#include <hibf/contrib/robin_hood.hpp> // for unordered_flat_set
Expand Down Expand Up @@ -49,8 +49,8 @@ void compute_sketches(config const & config,
// Vector L2 : number_of_max_minHash_sketches (LSH ADD+OR parameter b)
// Vector L3 : minHash_sketche_size (LSH ADD+OR parameter r)
void compute_sketches_with_minhash(config const & config,
std::vector<sketch::hyperloglog> & sketches,
std::vector<sketch::minHashes> & minHash_sketches)
std::vector<sketch::hyperloglog> & sketches,
std::vector<sketch::minHashes> & minHash_sketches)
{
//inititalise
sketches.resize(config.number_of_user_bins);
Expand Down Expand Up @@ -84,7 +84,7 @@ void compute_sketches_with_minhash(config const & config,
// that already had been in the heap because they are still the smallest ones.
while (!minHash_sketch.is_valid())
{
heap_size *=2;
heap_size *= 2;
heap.resize(heap_size, std::numeric_limits<uint64_t>::max());
std::make_heap(heap.begin(), heap.end());

Expand All @@ -95,7 +95,7 @@ void compute_sketches_with_minhash(config const & config,

std::sort(heap.begin(), heap.end()); // sort ascending to get the smallest numbers first

std::span<uint64_t> const heap_to_consider(heap.begin() + heap_size/2, heap.end());
std::span<uint64_t> const heap_to_consider(heap.begin() + heap_size / 2, heap.end());
minHash_sketch.fill_up_sketches(heap_to_consider);
}

Expand All @@ -105,9 +105,9 @@ void compute_sketches_with_minhash(config const & config,
}

void compute_sketches_with_minhash(config const & config,
std::vector<size_t> & kmer_counts,
std::vector<sketch::hyperloglog> & sketches,
std::vector<sketch::minHashes> & minHash_sketches)
std::vector<size_t> & kmer_counts,
std::vector<sketch::hyperloglog> & sketches,
std::vector<sketch::minHashes> & minHash_sketches)
{
compute_sketches_with_minhash(config, sketches, minHash_sketches);
kmer_counts.resize(config.number_of_user_bins);
Expand Down
3 changes: 2 additions & 1 deletion test/unit/hibf/sketch/compute_sketches_test.cpp
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ TEST(compute_sketches_test, with_minHash)
{
for (size_t hidx = 0; hidx < seqan::hibf::sketch::minHashes::sketch_size; ++hidx)
{
EXPECT_EQ(minHash_sketches[ub_id].table[sidx][hidx], start[ub_id] + hidx) << "ub_id:" << ub_id << " sidx:" << sidx << " hidx:" << hidx;
EXPECT_EQ(minHash_sketches[ub_id].table[sidx][hidx], start[ub_id] + hidx)
<< "ub_id:" << ub_id << " sidx:" << sidx << " hidx:" << hidx;
}
}
}
Expand Down
11 changes: 5 additions & 6 deletions test/unit/hibf/sketch/minHashes_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@

#include <gtest/gtest.h> // for Test, Message, TestInfo, TestPartResult, TEST, EXPECT_EQ

#include <hibf/misc/iota_vector.hpp> // for iota_vector
#include <hibf/sketch/minHashes.hpp> // for minHashes

#include <hibf/test/expect_range_eq.hpp> // for expect_range_eq, EXPECT_RANGE_EQ
#include <hibf/misc/iota_vector.hpp> // for iota_vector
#include <hibf/sketch/minHashes.hpp> // for minHashes
#include <hibf/test/expect_range_eq.hpp> // for expect_range_eq, EXPECT_RANGE_EQ

TEST(minHashes_test, static_update_heap_with)
{
std::vector<uint64_t> heap{3,4,5,6,7,8};
std::vector<uint64_t> heap{3, 4, 5, 6, 7, 8};
std::make_heap(heap.begin(), heap.end()); // make into proper heap

// no change because 10 is larger than all values in the heap
Expand Down Expand Up @@ -64,7 +63,7 @@ TEST(minHashes_test, fill_up_sketches)
ASSERT_FALSE(minHash_sketch.is_valid());

// recreate bigger heap
std::vector<uint64_t> bigger_heap = seqan::hibf::iota_vector(1000);
std::vector<uint64_t> bigger_heap = seqan::hibf::iota_vector(1000);
std::span<uint64_t> const bigger_heap_non_redundant(bigger_heap.begin() + heap.size(), bigger_heap.end());
minHash_sketch.fill_up_sketches(bigger_heap_non_redundant);

Expand Down

0 comments on commit 5d7acc9

Please sign in to comment.