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 Jan 25, 2024
1 parent 5c7ed74 commit e0406f3
Show file tree
Hide file tree
Showing 11 changed files with 219 additions and 167 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,17 @@ inline debug_stream_type<char_t> & operator<<(debug_stream_type<char_t> & stream
{
#else
template <typename alignment_t>
requires (tuple_like<std::remove_cvref_t<alignment_t>> && detail::all_model_aligned_seq<detail::tuple_type_list_t<std::remove_cvref_t<alignment_t>>>)
requires (tuple_like<std::remove_cvref_t<alignment_t>>
&& detail::all_model_aligned_seq<detail::tuple_type_list_t<std::remove_cvref_t<alignment_t>>>)
struct alignment_printer<alignment_t>
{
constexpr static auto print = [](auto & stream, auto && alignment)
static constexpr auto print = [](auto & stream, auto && alignment)
{
constexpr size_t sequence_count = std::tuple_size_v<std::remove_cvref_t<alignment_t>>;
constexpr size_t sequence_count = std::tuple_size_v<std::remove_cvref_t<alignment_t>>;

static_assert(sequence_count >= 2, "An alignment requires at least two sequences.");
static_assert(sequence_count >= 2, "An alignment requires at least two sequences.");

detail::stream_alignment(stream, alignment, std::make_index_sequence<sequence_count - 1>{});
detail::stream_alignment(stream, alignment, std::make_index_sequence<sequence_count - 1>{});
};
};
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,9 @@ template <typename coordinate_type>
detail::advanceable_alignment_coordinate>
struct advanceable_alignment_coordinate_printer<coordinate_type>
{
constexpr static auto print = [](auto & s, coordinate_type const & c)
static constexpr auto print = [](auto & s, coordinate_type const & c)
{
s << std::tie(c.first, c.second);
s << std::tie(c.first, c.second);
};
};
#endif
Expand Down
10 changes: 5 additions & 5 deletions include/seqan3/alignment/matrix/detail/debug_matrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -488,13 +488,13 @@ template <typename alignment_matrix_t>
requires detail::matrix<std::remove_cvref_t<alignment_matrix_t>>
struct alignment_matrix_printer<alignment_matrix_t>
{
constexpr static auto print = [](auto & s, auto && matrix)
static constexpr auto print = [](auto & s, auto && matrix)
{
detail::debug_matrix debug{std::forward<alignment_matrix_t>(matrix)};
detail::debug_matrix debug{std::forward<alignment_matrix_t>(matrix)};

std::stringstream sstream{};
debug.stream_matrix(sstream, s.flags2());
s << sstream.str();
std::stringstream sstream{};
debug.stream_matrix(sstream, s.flags2());
s << sstream.str();
};
};
#endif
Expand Down
21 changes: 11 additions & 10 deletions include/seqan3/alignment/matrix/detail/trace_directions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,21 @@ template <typename trace_directions_t>
requires std::is_same_v<std::remove_cvref_t<trace_directions_t>, detail::trace_directions>
struct trace_directions_printer<trace_directions_t>
{
constexpr static auto print = [](auto & s, detail::trace_directions const trace)
static constexpr auto print = [](auto & s, detail::trace_directions const trace)
{
static char const * unicode[32]{"", "", "", "↖↑", "", "↖⇡", "↑⇡", "↖↑⇡", "", "↖←", "↑←",
"↖↑←", "⇡←", "↖⇡←", "↑⇡←", "↖↑⇡←", "", "↖⇠", "↑⇠", "↖↑⇠", "⇡⇠", "↖⇡⇠",
"↑⇡⇠", "↖↑⇡⇠", "←⇠", "↖←⇠", "↑←⇠", "↖↑←⇠", "⇡←⇠", "↖⇡←⇠", "↑⇡←⇠", "↖↑⇡←⇠"};
static char const * unicode[32]{"", "", "", "↖↑", "", "↖⇡", "↑⇡", "↖↑⇡",
"", "↖←", "↑←", "↖↑←", "⇡←", "↖⇡←", "↑⇡←", "↖↑⇡←",
"", "↖⇠", "↑⇠", "↖↑⇠", "⇡⇠", "↖⇡⇠", "↑⇡⇠", "↖↑⇡⇠",
"←⇠", "↖←⇠", "↑←⇠", "↖↑←⇠", "⇡←⇠", "↖⇡←⇠", "↑⇡←⇠", "↖↑⇡←⇠"};

static char const * csv[32]{"N", "D", "U", "DU", "u", "Du", "Uu", "DUu", "L", "DL", "UL",
"DUL", "uL", "DuL", "UuL", "DUuL", "l", "Dl", "Ul", "DUl", "ul", "Dul",
"Uul", "DUul", "Ll", "DLl", "ULl", "DULl", "uLl", "DuLl", "UuLl", "DUuLl"};
static char const * csv[32]{"N", "D", "U", "DU", "u", "Du", "Uu", "DUu", "L", "DL", "UL",
"DUL", "uL", "DuL", "UuL", "DUuL", "l", "Dl", "Ul", "DUl", "ul", "Dul",
"Uul", "DUul", "Ll", "DLl", "ULl", "DULl", "uLl", "DuLl", "UuLl", "DUuLl"};

bool is_unicode = (s.flags2() & fmtflags2::utf8) == fmtflags2::utf8;
auto const & trace_dir = is_unicode ? unicode : csv;
bool is_unicode = (s.flags2() & fmtflags2::utf8) == fmtflags2::utf8;
auto const & trace_dir = is_unicode ? unicode : csv;

s << trace_dir[static_cast<size_t>(trace)];
s << trace_dir[static_cast<size_t>(trace)];
};
};
#endif
Expand Down
83 changes: 44 additions & 39 deletions include/seqan3/alignment/pairwise/alignment_result.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,50 +421,55 @@ inline debug_stream_type<char_t> & operator<<(debug_stream_type<char_t> & stream
template <typename T>
requires (!std::is_same_v<T, std::remove_cvref_t<T>>)
struct alignment_result_printer<T> : public alignment_result_printer<std::remove_cvref_t<T>>
{
};
{};

template <typename result_value_t>
struct alignment_result_printer<alignment_result<result_value_t>>
{
constexpr static auto print = [](auto & stream, alignment_result<result_value_t> const & result)
{
using alignment_result_t = alignment_result<result_value_t>;
using disabled_t = std::nullopt_t *;
using result_data_t =
typename detail::alignment_result_value_type_accessor<std::remove_cvref_t<alignment_result_t>>::type;

constexpr bool has_sequence1_id = !std::is_same_v<decltype(std::declval<result_data_t>().sequence1_id), disabled_t>;
constexpr bool has_sequence2_id = !std::is_same_v<decltype(std::declval<result_data_t>().sequence2_id), disabled_t>;
constexpr bool has_score = !std::is_same_v<decltype(std::declval<result_data_t>().score), disabled_t>;
constexpr bool has_end_positions =
!std::is_same_v<decltype(std::declval<result_data_t>().end_positions), disabled_t>;
constexpr bool has_begin_positions =
!std::is_same_v<decltype(std::declval<result_data_t>().begin_positions), disabled_t>;
constexpr bool has_alignment = !std::is_same_v<decltype(std::declval<result_data_t>().alignment), disabled_t>;

bool prepend_comma = false;
auto append_to_stream = [&](auto &&... args)
static constexpr auto print = [](auto & stream, alignment_result<result_value_t> const & result)
{
((stream << (prepend_comma ? std::string{", "} : std::string{})) << ... << std::forward<decltype(args)>(args));
prepend_comma = true;
};

stream << '{';
if constexpr (has_sequence1_id)
append_to_stream("sequence1 id: ", result.sequence1_id());
if constexpr (has_sequence2_id)
append_to_stream("sequence2 id: ", result.sequence2_id());
if constexpr (has_score)
append_to_stream("score: ", result.score());
if constexpr (has_begin_positions)
append_to_stream("begin: (", result.sequence1_begin_position(), ",", result.sequence2_begin_position(), ")");
if constexpr (has_end_positions)
append_to_stream("end: (", result.sequence1_end_position(), ",", result.sequence2_end_position(), ")");
if constexpr (has_alignment)
append_to_stream("\nalignment:\n", result.alignment());
stream << '}';

using alignment_result_t = alignment_result<result_value_t>;
using disabled_t = std::nullopt_t *;
using result_data_t =
typename detail::alignment_result_value_type_accessor<std::remove_cvref_t<alignment_result_t>>::type;

constexpr bool has_sequence1_id =
!std::is_same_v<decltype(std::declval<result_data_t>().sequence1_id), disabled_t>;
constexpr bool has_sequence2_id =
!std::is_same_v<decltype(std::declval<result_data_t>().sequence2_id), disabled_t>;
constexpr bool has_score = !std::is_same_v<decltype(std::declval<result_data_t>().score), disabled_t>;
constexpr bool has_end_positions =
!std::is_same_v<decltype(std::declval<result_data_t>().end_positions), disabled_t>;
constexpr bool has_begin_positions =
!std::is_same_v<decltype(std::declval<result_data_t>().begin_positions), disabled_t>;
constexpr bool has_alignment = !std::is_same_v<decltype(std::declval<result_data_t>().alignment), disabled_t>;

bool prepend_comma = false;
auto append_to_stream = [&](auto &&... args)
{
((stream << (prepend_comma ? std::string{", "} : std::string{}))
<< ... << std::forward<decltype(args)>(args));
prepend_comma = true;
};

stream << '{';
if constexpr (has_sequence1_id)
append_to_stream("sequence1 id: ", result.sequence1_id());
if constexpr (has_sequence2_id)
append_to_stream("sequence2 id: ", result.sequence2_id());
if constexpr (has_score)
append_to_stream("score: ", result.score());
if constexpr (has_begin_positions)
append_to_stream("begin: (",
result.sequence1_begin_position(),
",",
result.sequence2_begin_position(),
")");
if constexpr (has_end_positions)
append_to_stream("end: (", result.sequence1_end_position(), ",", result.sequence2_end_position(), ")");
if constexpr (has_alignment)
append_to_stream("\nalignment:\n", result.alignment());
stream << '}';
};
};
#endif
Expand Down
4 changes: 2 additions & 2 deletions include/seqan3/alphabet/detail/debug_stream_alphabet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ template <typename alphabet_t>
requires alphabet<alphabet_t>
struct alphabet_printer<alphabet_t>
{
constexpr static auto print = [](auto & s, alphabet_t l)
static constexpr auto print = [](auto & s, alphabet_t l)
{
s << to_char(l);
};
Expand Down Expand Up @@ -69,7 +69,7 @@ template <typename alphabet_t>
requires std::same_as<std::remove_cvref_t<alphabet_t>, mask>
struct mask_printer<alphabet_t>
{
constexpr static auto print = [](auto & s, alphabet_t const l)
static constexpr auto print = [](auto & s, alphabet_t const l)
{
s << (l == std::remove_cvref_t<alphabet_t>{} ? "UNMASKED" : "MASKED");
};
Expand Down
19 changes: 12 additions & 7 deletions include/seqan3/core/debug_stream/debug_stream_type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,12 @@ class debug_stream_type
{
using t_ = std::remove_cvref_t<t>;

if constexpr(default_printer::is_printable<t_>) {
if constexpr (default_printer::is_printable<t_>)
{
default_printer::print(s, v);
} else {
}
else
{
std::string const msg = std::string{"debug_stream has no print overload for type: "} + typeid(v).name();
throw std::runtime_error{msg};
}
Expand Down Expand Up @@ -171,10 +174,10 @@ class debug_stream_type
}
#else

template<typename T>
template <typename T>
friend struct debug_stream_printer;

template<typename T>
template <typename T>
friend struct std_printer;

#endif
Expand Down Expand Up @@ -216,14 +219,14 @@ class debug_stream_type
#ifdef _LIBCPP_VERSION
static_assert(std::same_as<fmtflags, unsigned>);
#else
#if 0
# if 0
//!\copybrief setf()
debug_stream_type & operator<<(fmtflags const flag)
{
setf(flag);
return *this;
}
#endif
# endif
//!\}
#endif

Expand Down Expand Up @@ -275,7 +278,9 @@ class debug_stream_type
};

template <typename value_t>
requires (std::is_same_v<std::remove_cvref_t<value_t>, int8_t> || std::is_same_v<std::remove_cvref_t<value_t>, uint8_t> || std::is_same_v<std::remove_cvref_t<value_t>, fmtflags2>)
requires (std::is_same_v<std::remove_cvref_t<value_t>, int8_t>
|| std::is_same_v<std::remove_cvref_t<value_t>, uint8_t>
|| std::is_same_v<std::remove_cvref_t<value_t>, fmtflags2>)
struct debug_stream_printer<value_t>
{
struct print_fn
Expand Down
Loading

0 comments on commit e0406f3

Please sign in to comment.