From: Luca Vizzarro <Luca.Vizzarro@arm.com>
To: Dean Marx <dmarx@iol.unh.edu>,
probb@iol.unh.edu, npratte@iol.unh.edu, yoan.picchi@foss.arm.com,
Honnappa.Nagarahalli@arm.com, paul.szczepanek@arm.com
Cc: dev@dpdk.org
Subject: Re: [PATCH v1] dts: fix pass rate edge case in results json
Date: Wed, 15 Jan 2025 10:10:14 +0000 [thread overview]
Message-ID: <c1a960a9-79c2-488f-a025-4116c304e15f@arm.com> (raw)
In-Reply-To: <20250113215230.13942-1-dmarx@iol.unh.edu>
Hi Dean,
good timing! I actually noticed this issue last week and was going to
tackle it soon.
On 13/01/2025 21:52, Dean Marx wrote:
> @@ -324,13 +324,15 @@ def generate_pass_rate_dict(self, test_run_summary) -> dict[str, float]:
> Returns:
> A dictionary with the PASS/FAIL ratio of all test cases.
> """
> - return {
> - "PASS_RATE": (
> - float(test_run_summary[Result.PASS.name])
> - * 100
> - / sum(test_run_summary[result.name] for result in Result if result != Result.SKIP)
> - )
> - }
> + cases_not_skipped = sum(
> + test_run_summary[result.name] for result in Result if result != Result.SKIP
> + )
> + if cases_not_skipped == 0:
> + return {"PASS_RATE": 0.0}
> + else:
> + return {
> + "PASS_RATE": (float(test_run_summary[Result.PASS.name]) * 100 / cases_not_skipped)
> + }
The solution feels a bit overcomplicated, you can just throw a
max(sum(..), 1), so:
ran_tests = sum(test_run_summary[result.name] for result in Result
if result != Result.SKIP)
return {
"PASS_RATE": test_run_summary[Result.PASS.name] * 100.0 /
max(ran_tests, 1)
}
also while you are at it, changing the 100 to 100.0 will spare us from
writing a longer float(..) expression.
prev parent reply other threads:[~2025-01-15 10:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-13 21:52 Dean Marx
2025-01-15 10:10 ` Luca Vizzarro [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c1a960a9-79c2-488f-a025-4116c304e15f@arm.com \
--to=luca.vizzarro@arm.com \
--cc=Honnappa.Nagarahalli@arm.com \
--cc=dev@dpdk.org \
--cc=dmarx@iol.unh.edu \
--cc=npratte@iol.unh.edu \
--cc=paul.szczepanek@arm.com \
--cc=probb@iol.unh.edu \
--cc=yoan.picchi@foss.arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).