Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENH:
integrate.cubature
: support for infinite limits (scipy#21657)
* ENH: add `points` for subdividing initial region - Add `points` argument to `cubature` - Break up the region used for the initial estimate so that all `points` lie on the edge of a subregion - Add tests using the `points` argument * ENH: support infinite limits via variable transformation - Handle limits where a > b by flipping them around and keeping track of the sign - Add `_VariableTransform` base class - Add `_InfiniteLimitsTransform` class - Apply infinite limits transformation if any of `a` or `b` are infinite - Add test for limits where a > b - Add test for infinite limits - Add test to check that break points are correctly mapped under infinite limits transformation * DOC: add details of `points` and infinite limits to docstring - Update docstring to say that infinite limits are allowed in `a` and `b` - Add `points` argument to Parameters section - Describe the transformation used to handle infinite limits in the docstring - Add example of 2D integral with infinite limits - Add example of 1D integral with singularities avoided using `points` * TST: call `cubature` using keyword arguments in new tests * DOC: add more detail to `points` parameter * DOC: rephrase to "Jacobian determinant" rather than "Jacobian" * MAINT: pass `xp` as argument rather than calling `array_namespace` * MAINT: return results in the common dtype of input - Store nodes and weights by default using `float64` - Downcast if necessary to match the common floating dtype of user input - Add tests for this * MAINT: pass `xp` to `_apply_fixed_rule` rather than using `array_namespace` * STY: `len(...) == 0` rather than comparing to `[]` * TST: tighten tolerance on some tests Tighten tolerances from 1e-1 to 1e-8 on the following tests: - `test_pass_str` - `test_pass_array_like_not_array` - `test_zero_width_limits` - `test_limits_other_way_around` - `test_base_1d_quadratures_simple` - `test_base_1d_quadratures_error_from_difference` * DOC: correct details of transformation used for infinite limits - Correct details of transformation used in the (\infty, b_i] case - Remove details of Jacobian determinant since it is not true when the limits are (\infty, b_i] * STY: remove extra blank line * MAINT: remove unnecessary `negate_pos` in transformation - `negate_pos` wasn't having any effect since the values that were negated would be overriden below * DOC: correct details for (-\infty, b_i] * remove for loop from __init__ * still bugs to figure out * Update scipy/integrate/_cubature.py Co-authored-by: Olly Britton <ollybritton@gmail.com> * fix axis location * fix summing boleans * don't use arr[..., bool_array] * BUG: use compatible namespace in test for infinite limits and points * BUG: correctly map break points when using a transformation - Need to reshape points so that they can be mapped by `f.inv` - Add test case for 1D and 2D integrals where the points specified are removed by the transformation - Adjust double infinite transformation to prevent division by zero * MAINT: explain check for any infinite limits in `points` [lint only] --------- Co-authored-by: Jake Bowhay <jb9.bowhay@gmail.com>
- Loading branch information