-
Notifications
You must be signed in to change notification settings - Fork 31
[WIP] - Add gravitational lensing effect model for redback #317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
nikhil-sarin
wants to merge
13
commits into
master
Choose a base branch
from
claude/implement-effect-01SWuR29pQSE7C3bpRL16NYF
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
[WIP] - Add gravitational lensing effect model for redback #317
nikhil-sarin
wants to merge
13
commits into
master
from
claude/implement-effect-01SWuR29pQSE7C3bpRL16NYF
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Implement lensing as a pluggable effect similar to extinction, allowing any base model to be modified with time delays and magnifications from multiple lensed images. Supports all transient types including supernovae, kilonovae, afterglows, TDEs, and more.
- Add unit tests for core lensing functions (_perform_lensing, _evaluate_lensing_model) - Add integration tests for all lensing wrapper functions (supernova, kilonova, TDE, etc.) - Add tests for multiple image configurations (2, 3, 4 images) - Add tests for both flux_density and magnitude output formats - Add get_lensing_priors() function for programmatic prior generation - Add prior files for 2, 3, and 4 image lensing configurations - Add tests for prior file loading and sampling
- Fix negative time handling by only evaluating base model for positive times - Update test parameters to use appropriate time values larger than delays - Fix _get_correct_function to handle callable base models properly - Simplify spectra output to apply magnification only (no time delays in spectra mode) - Use 'bessellb' band instead of 'ztfg' to avoid remote data fetching
The existing TestModels tests iterate over all .prior files in the main priors directory and expect matching model functions. Since lensing priors are effect parameters (like extinction), they belong in non_default_priors.
Add comprehensive tests for previously untested code paths: - Spectra output mode with magnification sum - Special base_model names (thin_shell_supernova, homologous_expansion_supernova) - Additional wrapper functions (stellar_interaction, general_synchrotron, afterglow) - Edge cases: empty arrays, large image counts, zero magnification, boundary conditions - Model library verification and parameter handling tests Increases test count from 34 to 52 tests in lensing_test.py (63 total with priors)
New tests cover: - Error paths for invalid base_model types (non-string, non-callable) - Integrated flux afterglow model type verification - 5-image lensing systems (Einstein Cross + central image) - Flux output format (not just flux_density) - Core loop edge cases: nimages=0, simultaneous arrivals - Staggered arrival patterns with multiple delayed images - Module structure verification (functions exist, correct types) Total tests increased to 78 (67 lensing_test + 11 priors)
New tests added: - Direct _evaluate_lensing_model() testing with callable models - Parameter removal verification (dt_i, mu_i stripped from base kwargs) - Spectra output mode code path coverage (lines 187-227) - Citation wrapper verification - Complete base model list content checks - Numerical precision tests (very small/large magnifications) Total: 94 tests (83 lensing + 11 priors) - comprehensive coverage
The lensing_test.py and lensing_priors_test.py were not included in the CI test matrix, so they weren't contributing to Coveralls coverage reports. Added both test files to Group 4 (lighter tests) in the workflow.
Replace mock spectra tests that threw exceptions with real model tests that execute the complete spectra code path (lines 187-227): - Test 3-image spectra mode with supernova - Test kilonova flux output through spectra path - Test TDE magnitude output through spectra path These tests ensure full execution of the magnification summation loop and sed.get_correct_output_format_from_spectra() integration.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implement lensing as a pluggable effect similar to extinction, allowing any base model to be modified with time delays and magnifications from multiple lensed images. Supports all transient types including supernovae, kilonovae, afterglows, TDEs, and more.