Skip to content

Commit 396430d

Browse files
committed
Add comments to parts suggested by coderabbit
1 parent b3f7da5 commit 396430d

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

splinepy/helpme/integrate.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def _get_integral_measure(spline):
2020
.. math::
2121
\\mathcal{J}_S = det(\\mathbf(J))
2222
23-
If the physical dimension is bigger then the parametric dimension it will
23+
If the physical dimension is bigger than the parametric dimension it will
2424
return
2525
2626
.. math::
@@ -59,6 +59,7 @@ def measure(spline_patch, positions):
5959

6060

6161
def _default_quadrature_orders(spline):
62+
# Expected degree for quadrature based on spline's degrees and parametric dimension
6263
expected_degree = spline.degrees * spline.para_dim + 1
6364
if spline.is_rational:
6465
expected_degree += 2
@@ -132,6 +133,8 @@ def _get_quadrature_information(spline, orders=None):
132133
def volume(spline, orders=None):
133134
r"""Compute volume of a given spline
134135
136+
Uses quadrature to compute volume. Can handle patches with multiple elements.
137+
135138
Parameters
136139
----------
137140
spline : Spline
@@ -178,9 +181,11 @@ def parametric_function(
178181
Parameters
179182
----------
180183
spline : Spline
181-
(self if called via integrator)
184+
The geometry over which the function is integrated
182185
function : Callable
186+
The function to integrate
183187
orders : optional
188+
Quadrature orders for numerical integration
184189
185190
Returns
186191
-------
@@ -762,7 +767,14 @@ def precompute_transformation(self):
762767

763768
@property
764769
def supports(self):
765-
""" """
770+
"""
771+
Get the quadrature points' supports.
772+
773+
Returns
774+
-------
775+
supports: np.ndarray
776+
The supports
777+
"""
766778
if self._supports is None:
767779
self._supports = self._helpee.supports(self._trafo.all_quad_points)
768780

tests/helpme/test_integrate.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,20 @@ def test_volume_integration_embedded(np_rng):
3434
Test volume integration for splines using numerical integration of the
3535
Jacobi-Determinant
3636
"""
37-
# Test 1D -> 2D
37+
# Test 1D -> 2D volume integration for Bezier
3838
expected_result = 2.0**1.5
3939
bezier = splinepy.Bezier(degrees=[1], control_points=[[0, 0], [2, 2]])
4040

4141
assert np.allclose(bezier.integrate.volume(), expected_result)
4242

43-
# test for other types same spline
43+
# For same curve, test other spline types
4444
assert np.allclose(bezier.bspline.integrate.volume(), expected_result)
4545
assert np.allclose(
4646
bezier.rationalbezier.integrate.volume(), expected_result
4747
)
4848
assert np.allclose(bezier.nurbs.integrate.volume(), expected_result)
4949

50-
# Check if equal after refinement
50+
# Check if volume is equal after degree elevation
5151
bezier.elevate_degrees([0, 0, 0])
5252

5353
assert np.allclose(bezier.integrate.volume(), expected_result)
@@ -177,6 +177,7 @@ def test_assertions(np_rng):
177177
def test_function_integration(np_rng):
178178
col1_factor = 2
179179

180+
# Define vector-valued constant function
180181
def volume_function(x):
181182
vf = np.ones((x.shape[0], 2))
182183
# scale it with a factor to get a different value
@@ -186,6 +187,7 @@ def volume_function(x):
186187
bezier = splinepy.Bezier(
187188
degrees=[1, 2], control_points=np_rng.random((6, 2))
188189
)
190+
# Test function integration for constant functions
189191
assert np.allclose(
190192
[bezier.integrate.volume(), col1_factor * bezier.integrate.volume()],
191193
bezier.integrate.parametric_function(volume_function),

0 commit comments

Comments
 (0)