From 54f79700c821655a321597f851b98c1e42f21d62 Mon Sep 17 00:00:00 2001 From: pescap Date: Sun, 13 Oct 2024 18:22:21 -0300 Subject: [PATCH] raise ValueError for Gauss order out of the range --- bempp/api/integration/gauss.py | 4 ++++ bempp/api/integration/triangle_gauss.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/bempp/api/integration/gauss.py b/bempp/api/integration/gauss.py index 889f4cd0..0121a2cb 100644 --- a/bempp/api/integration/gauss.py +++ b/bempp/api/integration/gauss.py @@ -1045,6 +1045,10 @@ def rule(order): Orders between 1 and 30 are supported. """ + if order < 1 or order > 30: + raise ValueError( + f"Gauss quadrature order must be between 1 and 30. Provided: {order}" + ) npoints = order address = (npoints * (npoints - 1)) // 2 return ( diff --git a/bempp/api/integration/triangle_gauss.py b/bempp/api/integration/triangle_gauss.py index 7858a20c..567bf45f 100644 --- a/bempp/api/integration/triangle_gauss.py +++ b/bempp/api/integration/triangle_gauss.py @@ -2931,6 +2931,10 @@ def rule(order): The order must be between 1 and 20. """ + if order < 1 or order > 20: + raise ValueError( + f"Symmetric Gauss quadrature order must be between 1 and 20. Provided: {order}" + ) npoints = points_per_order[order - 1] address = points_address[npoints - 1] bary_coords = coords[3 * address : 3 * (address + npoints)].reshape(