[3/5] test: ipa: libipa: histogram: Add tests for quantile() returning a fraction
diff mbox series

Message ID 20250324170803.103296-4-stefan.klug@ideasonboard.com
State New
Headers show
Series
  • Fix histogram for some (corner) cases
Related show

Commit Message

Stefan Klug March 24, 2025, 5:07 p.m. UTC
Add tests for quantile() returning a fractional value. These cases were
fixed in the last commit.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
---
 test/ipa/libipa/histogram.cpp | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Kieran Bingham March 31, 2025, 6:09 p.m. UTC | #1
Quoting Stefan Klug (2025-03-24 17:07:38)
> Add tests for quantile() returning a fractional value. These cases were
> fixed in the last commit.
> 
> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
> ---
>  test/ipa/libipa/histogram.cpp | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/test/ipa/libipa/histogram.cpp b/test/ipa/libipa/histogram.cpp
> index 220a329e33b3..b96626054af0 100644
> --- a/test/ipa/libipa/histogram.cpp
> +++ b/test/ipa/libipa/histogram.cpp
> @@ -42,10 +42,19 @@ protected:
>                 ASSERT_EQ(hist.quantile(1.0), 2.0);
>                 ASSERT_EQ(hist.quantile(0.5), 1.0);
>  
> +               /* Test quantile in the middle of a bin. */
> +               ASSERT_EQ(hist.quantile(0.75), 1.5);
> +
> +               /* Test quantile smaller than the smallest histogram step. */
> +               ASSERT_EQ(hist.quantile(0.001), 0.002);
> +
>                 ASSERT_EQ(hist.interQuantileMean(0.0, 1.0), 1.0);
>                 ASSERT_EQ(hist.interQuantileMean(0.0, 0.5), 0.5);
>                 ASSERT_EQ(hist.interQuantileMean(0.5, 1.0), 1.5);
>  
> +               /* Test quantile means that are in the middle of the bins */
> +               ASSERT_EQ(hist.interQuantileMean(0.25, 0.75), 1.0);
> +

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

>                 return TestPass;
>         }
>  };
> -- 
> 2.43.0
>
Laurent Pinchart March 31, 2025, 9:56 p.m. UTC | #2
Hi Stefan,

Thank you for the patch.

On Mon, Mar 24, 2025 at 06:07:38PM +0100, Stefan Klug wrote:
> Add tests for quantile() returning a fractional value. These cases were
> fixed in the last commit.
> 
> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
> ---
>  test/ipa/libipa/histogram.cpp | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/test/ipa/libipa/histogram.cpp b/test/ipa/libipa/histogram.cpp
> index 220a329e33b3..b96626054af0 100644
> --- a/test/ipa/libipa/histogram.cpp
> +++ b/test/ipa/libipa/histogram.cpp
> @@ -42,10 +42,19 @@ protected:
>  		ASSERT_EQ(hist.quantile(1.0), 2.0);
>  		ASSERT_EQ(hist.quantile(0.5), 1.0);
>  
> +		/* Test quantile in the middle of a bin. */
> +		ASSERT_EQ(hist.quantile(0.75), 1.5);
> +
> +		/* Test quantile smaller than the smallest histogram step. */
> +		ASSERT_EQ(hist.quantile(0.001), 0.002);
> +
>  		ASSERT_EQ(hist.interQuantileMean(0.0, 1.0), 1.0);
>  		ASSERT_EQ(hist.interQuantileMean(0.0, 0.5), 0.5);
>  		ASSERT_EQ(hist.interQuantileMean(0.5, 1.0), 1.5);
>  
> +		/* Test quantile means that are in the middle of the bins */

s/quantile/interquantile/
s/bins/bins./

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> +		ASSERT_EQ(hist.interQuantileMean(0.25, 0.75), 1.0);
> +
>  		return TestPass;
>  	}
>  };

Patch
diff mbox series

diff --git a/test/ipa/libipa/histogram.cpp b/test/ipa/libipa/histogram.cpp
index 220a329e33b3..b96626054af0 100644
--- a/test/ipa/libipa/histogram.cpp
+++ b/test/ipa/libipa/histogram.cpp
@@ -42,10 +42,19 @@  protected:
 		ASSERT_EQ(hist.quantile(1.0), 2.0);
 		ASSERT_EQ(hist.quantile(0.5), 1.0);
 
+		/* Test quantile in the middle of a bin. */
+		ASSERT_EQ(hist.quantile(0.75), 1.5);
+
+		/* Test quantile smaller than the smallest histogram step. */
+		ASSERT_EQ(hist.quantile(0.001), 0.002);
+
 		ASSERT_EQ(hist.interQuantileMean(0.0, 1.0), 1.0);
 		ASSERT_EQ(hist.interQuantileMean(0.0, 0.5), 0.5);
 		ASSERT_EQ(hist.interQuantileMean(0.5, 1.0), 1.5);
 
+		/* Test quantile means that are in the middle of the bins */
+		ASSERT_EQ(hist.interQuantileMean(0.25, 0.75), 1.0);
+
 		return TestPass;
 	}
 };