Skip to content

qa_utils: print errors with enough precision to represent tolerance#860

Open
marcusmueller wants to merge 1 commit intomainfrom
marcus/better_error_printing
Open

qa_utils: print errors with enough precision to represent tolerance#860
marcusmueller wants to merge 1 commit intomainfrom
marcus/better_error_printing

Conversation

@marcusmueller
Copy link
Copy Markdown
Member

Issues like #859 highlight that we're not seeing the numerical values to a precision good enough to debug. Change that.

Signed-off-by: Marcus Müller <mmueller@gnuradio.org>
Copy link
Copy Markdown
Contributor

@jdemel jdemel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot. Only very minor comments.

Comment thread lib/qa_utils.cc

#include <fmt/core.h>
#include <fmt/format.h>
#include <fmt/ranges.h>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a double include. I suggest to remove the empty lines between includes, let clang-format do the sorting and automatically remove duplicates =D

Comment thread lib/qa_utils.cc
float tol,
int max_errors = 10)
{
constexpr std::array<const char*, 5> columns{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we able to use std::string_view in place of char* here?

Comment thread lib/qa_utils.cc
Comment on lines +631 to +632
template <class T>
unsigned int max_col_length(const T& columns)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you add a new line between functions? =D

could you rename the function to max_column_width? That's what is essentially computed, correct?

Comment thread lib/qa_utils.cc
unsigned int index_len = fmt::formatted_size("{}", columns[0]) + 1;
unsigned int col_len = max_col_length(columns);
/* choose enough digits to represent tolerance */
const auto prec_tup = tol_precision(tol, col_len);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to use structured binding here. Something like:

Suggested change
const auto prec_tup = tol_precision(tol, col_len);
const auto [tol_length, value_prec] = tol_precision(tol, col_len);

This would improve readability here a lot. I was looking for the exact meaning of these variables for a while.

Comment thread lib/qa_utils.cc
Comment on lines 664 to 665
if (fail_indices.empty())
return;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you do me a favor and add curly braces here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants