Skip to content

Add GaussianQuadrature2D - #476

Open
Mateasek wants to merge 19 commits into
cherab:developmentfrom
Mateasek:feature/GaussianQuadrature2D
Open

Add GaussianQuadrature2D#476
Mateasek wants to merge 19 commits into
cherab:developmentfrom
Mateasek:feature/GaussianQuadrature2D

Conversation

@Mateasek

Copy link
Copy Markdown
Member

Adds GaussianQuadrature2D class mentioned in #475.

Adds also integrators (1D, 2D) to our documentation.

This PR will be marked as draft until PR #473 is merged.

@Mateasek
Mateasek marked this pull request as ready for review November 25, 2025 21:39

@jacklovell jacklovell left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Very nice, only minor comments from me. Some of the (code comment related) comments apply equally to the existing GaussianQuadrature class on which this is based, so if you can add some clarifying code comments there too that would be nice but not a deal breaker.

Comment thread cherab/core/math/integrators/__init__.pxd Outdated
Comment thread cherab/core/math/integrators/__init__.py Outdated
Comment thread cherab/core/math/integrators/integrators2d.pxd Outdated
Comment on lines +83 to +86
- :math:`x_{\mathrm{lower}}`: Lower limit of integration for the x-dimension.
- :math:`x_{\mathrm{upper}}`: Upper limit of integration for the x-dimension.
- :math:`y_{\mathrm{lower}}(x)`: Lower limit of integration for the y-dimension, a function of :math:`x`.
- :math:`y_{\mathrm{upper}}(x)`: Upper limit of integration for the y-dimension, a function of :math:`x`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Either double-escape \mathrm or (preferably) use a raw string for the docstring (r''') and go with single backslashes for all the Latex code.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

made the docstring a raw string

@jacklovell jacklovell Jul 29, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You'll also need to un-escape the backslashes for TeX macros elsewhere in the docstring now that it is a raw string: a single backslash is needed everywhere otherwise the maths isn't rendered correctly when building the HTML docs.

There should also be a blank line after the .. math:: block and before where:, otherwise Sphinx complains with WARNING: Explicit markup ends without a blank line; unexpected unindent. [docutils]

./dev/build_docs.sh from the root directory of the repo is good for locally checking how the docstrings render. You'll need the sphinx, sphinx-tabs and sphinx-rtd-theme Python packages installed.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks, I hope that now it is ok.

Comment thread cherab/core/math/integrators/integrators2d.pyx
Comment thread cherab/core/math/integrators/integrators2d.pyx Outdated
Comment thread cherab/core/math/integrators/integrators2d.pyx
Comment thread cherab/core/math/integrators/integrators2d.pyx Outdated
Comment thread cherab/core/math/integrators/integrators2d.pyx Outdated
Comment thread cherab/core/math/tests/test_integrators.py
@Mateasek

Copy link
Copy Markdown
Member Author

Thanks for the review @jacklovell! I implemented changes to take into account the suggestions.

I refactored the GaussianQuadrature2D.evaluate method to simplify it. The part of code evaluating the integral was moved to a separate method and the end condicions were simplified. The readability is now improved I think.

Mateasek added 5 commits July 21, 2026 10:48
Docstring was improved, explanation of order increase added.
The evaluate method was refactored to improve efficiency

Redundant methods for testing were removed
Multiple values and combinations of max_orders and min_orders are now
tested.
Comment thread docs/source/math/integrators.rst Outdated
Integrators
-------------

.. autoclass:: cherab.core.math.integrators.integrators1d.GaussianQuadrature

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should be GaussianQuadrature1D

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good catch, I found few more GaussianQuadrature imports/usage and replaced it. I hope that it is all now.

@jacklovell

Copy link
Copy Markdown
Member

Great, thanks. 2 final (minor) unresolved comments relating to the documentation and then it'll be good to merge.

@Mateasek

Copy link
Copy Markdown
Member Author

I hope I've addressed all the outstanding comments and problems, so this one is ready for another go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants