Support domain inclusion in chained TrueMeasure transformations - #609
Support domain inclusion in chained TrueMeasure transformations#609Laasya-73 wants to merge 4 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #609 +/- ##
===========================================
+ Coverage 88.65% 88.71% +0.05%
===========================================
Files 104 104
Lines 8508 8530 +22
===========================================
+ Hits 7543 7567 +24
+ Misses 965 963 -2
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Generalizes chained TrueMeasure compatibility from exact range/domain equality to interval containment.
Changes:
- Adds broadcast-aware range containment checks and revised errors.
- Adds unit tests for valid and invalid chains.
- Adds a detailed demonstration notebook.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
qmcpy/true_measure/abstract_true_measure.py |
Implements containment-based compatibility. |
test/test_true_measures.py |
Tests containment and chaining behavior. |
demos/true_measure_domain_inclusion.ipynb |
Demonstrates the new semantics and mathematical context. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| lower_bounds_valid = np.all(domain[:, 0] <= transform_range[:, 0]) | ||
| upper_bounds_valid = np.all(transform_range[:, 1] <= domain[:, 1]) | ||
| return bool(lower_bounds_valid and upper_bounds_valid) |
| "import matplotlib.pyplot as plt\n", | ||
| "import numpy as np\n", | ||
| "import pandas as pd\n", | ||
| "from matplotlib.patches import Rectangle\n", | ||
| "from scipy.stats import logistic, norm\n", | ||
| "\n", | ||
| "from qmcpy import DigitalNetB2, Kumaraswamy, Uniform\n", | ||
| "from qmcpy.true_measure.abstract_true_measure import AbstractTrueMeasure\n", | ||
| "from qmcpy.util import ParameterError\n", |
|
@Laasya-73 you should add some examples in the demo notebook of integration with the chained measures. |
Co-authored-by: fjhickernell <817530+fjhickernell@users.noreply.github.com>
Sure, I will add and update the PR. |
There was a problem hiding this comment.
- Could you add the notebook to
mkdocs.yml? Thank you. - Validate input to
_range_in_domain:
>>> AbstractTrueMeasure._range_in_domain(np.empty((0, 2)),[[0, 1]])
True
>>> AbstractTrueMeasure._range_in_domain([["a", "z"]], [["a", "z"]])
True
-
In the notebook,
from qmcpy import DigitalNetB2, Kumaraswamy, Uniform from qmcpy.true_measure.abstract_true_measure import AbstractTrueMeasurecan be simplified tofrom qmcpy import AbstractTrueMeasure, DigitalNetB2, Kumaraswamy, Uniform -
In a command line window, you could run "make format" to beautify the files. Give it a try and see if it helps.
-
For the notebook sub-section title, "### One compatibility visual", do you want to make it "D."? Sections 3 and 5 have sub-section labels. Would you like to make them consistent?
Summary
This PR generalizes compatibility checking for chained
TrueMeasuretransformations.Previously, consecutive transformations were considered compatible only when the range of the preceding transformation exactly matched the domain of the next:
This is more restrictive than necessary. The updated rule accepts the chain whenever the preceding range is contained within the next domain:
This allows valid chained transformations with strict domain inclusion while continuing to reject genuinely incompatible ranges.
Changes
_range_in_domain()toAbstractTrueMeasure.(1, 2)and(d, 2)domain/range representations.demos/true_measure_domain_inclusion.ipynbdemonstrating:TrueMeasurechains;Scope
This change is intentionally limited to domains/ranges represented as one-dimensional intervals or multidimensional axis-aligned boxes.
It does not introduce arbitrary measure-transport semantics, disconnected support representations, or changes to the existing importance-sampling implementation.
Notes
This PR replaces #602 after moving the feature branch into the
QMCSoftwarerepository.