Skip to content

Conversation

@ahms5
Copy link
Member

@ahms5 ahms5 commented Jul 29, 2025

Changes proposed in this pull request:

  • add paris equation after Kuttruff
  • add doc and tests

@ahms5 ahms5 added this to the v0.1.0 milestone Jul 29, 2025
@ahms5 ahms5 self-assigned this Jul 29, 2025
@ahms5 ahms5 added the enhancement New feature or request label Jul 29, 2025
@ahms5 ahms5 moved this from Backlog to Require review in Weekly Planning Jul 29, 2025
@ahms5 ahms5 requested a review from Copilot July 29, 2025 10:09
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds the Paris formula implementation to calculate random-incidence coefficients based on Kuttruff's equation 2.53. The implementation provides a utility function for acoustic analysis with proper error handling and comprehensive test coverage.

  • Implements paris_formula function in imkar.utils module with mathematical formula for random-incidence coefficient calculation
  • Adds comprehensive test suite covering various scenarios including constant/non-constant coefficients and error conditions
  • Updates documentation structure to include the new utils module in API reference

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
imkar/utils.py New module implementing the Paris formula with input validation and documentation
tests/test_utils.py Comprehensive test suite covering function behavior and error cases
imkar/init.py Exposes utils module in package interface
docs/modules/imkar.utils.rst Documentation file for the utils module
docs/api_reference.rst Updates API reference to include utils module
Comments suppressed due to low confidence (1)

tests/test_utils.py:50

  • This test expects an error message that mentions 'None or Coordinates', but passing None should be invalid based on the function logic. The test should either pass a valid non-Coordinates object or update the expected error message.
            match="incident_directions have to be None or Coordinates"):

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Member

@f-brinkmann f-brinkmann left a comment

Choose a reason for hiding this comment

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

Thanks for the draft! Mostly had suggestions for documentation and improved robustness.

Calculate the random-incidence coefficient
according to Paris formula.

The implementation follows the Equation 2.53 from [#]_ and is
Copy link
Member

Choose a reason for hiding this comment

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

Can you please add a little general introduction? Something like: 'The Paris formula computes the ... It is valid for... and requires ...'. This is valid for scattering, absorption and generally all direction dependend energetic properties?

imkar/utils.py Outdated
coefficients : pyfar.FrequencyData
coefficients for different incident directions. Its cshape
needs to be (..., n_incident_directions)
incident_directions : pyfar.Coordinates
Copy link
Member

Choose a reason for hiding this comment

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

SamplingSphere would have the check for equal radii built in, but it has a 4 pi restriction on the sum of the weights, which we probably do not want here. Check for equal radius and add radius tolerance in this function as well?

imkar/utils.py Outdated
Comment on lines 47 to 49
if not isinstance(coefficients, pf.FrequencyData):
raise ValueError("coefficients has to be FrequencyData")
if not isinstance(incident_directions, pf.Coordinates):
Copy link
Member

Choose a reason for hiding this comment

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

using e.g. type(coefficients) != pf.FrequencyData is more future-safe because isinstance evaluates to True also for inherited classes.

with the ``coefficients`` :math:`c`, and the
area weights :math:`w` from the ``incident_directions``.
:math:`|\Omega_S \cdot n|` represent the cosine of the angle between the
surface normal and the incident direction.
Copy link
Member

Choose a reason for hiding this comment

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

This is very implicit. Can you please be more verbose here and also add a check for np.all(incident_directions.z >= 0?

(0), (0.2), (0.5), (0.8), (1)])
@pytest.mark.parametrize("frequencies", [
([100, 200]), ([100])])
def test_random_constant_coefficient(
Copy link
Member

Choose a reason for hiding this comment

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

A little docstring or comments for this test would be nice.

assert c_rand.comment == 'random-incidence coefficient'


def test_random_non_constant_coefficient():
Copy link
Member

Choose a reason for hiding this comment

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

docstring and/or comments would be nice.

(0), (0.2), (0.5), (0.8), (1)])
@pytest.mark.parametrize("frequencies", [
([100, 200]), ([100])])
def test_random_constant_coefficient(
Copy link
Member

Choose a reason for hiding this comment

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

I would suggest that all tests start with test_paris_formula_ in case more functios are added to the module later.

ahms5 and others added 2 commits December 3, 2025 14:00
Co-authored-by: Fabian Brinkmann <fabian.brinkmann@mailbox.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: Require review

Development

Successfully merging this pull request may close these issues.

3 participants