Repository navigation
Conversation
…ut correlated noise make_fake_toas(..., add_correlated_noise=True) crashed with a TypeError/AttributeError when the timing model had no correlated-noise component (no PLRedNoise, PLDMNoise, EcorrNoise, etc.), because noise_model_designmatrix/noise_model_basis_weight return None in that case and the None was dereferenced without a guard. Now it logs a warning and skips the correlated-noise term, matching how full_designmatrix already treats a None noise design matrix elsewhere in this module. Added a regression test in tests/test_fake_toas.py that exercises add_correlated_noise=True against a model with no correlated-noise component.
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
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.
pint.simulation.make_fake_toas(..., add_correlated_noise=True)crashes with aTypeError/AttributeError(object of type 'NoneType' has no len()/'NoneType' object has no attribute 'shape') when the timing model has no correlated-noise component, instead of either no-opping or raising a clear error.The cause is that
TimingModel.noise_model_designmatrixandTimingModel.noise_model_basis_weightboth returnNonewhen the model has no correlated-noise component (noPLRedNoise,PLDMNoise,EcorrNoise, etc.), andmake_fake_toasdereferences those return values without a guard.The fix adds a guard around the
Nonecase inmake_fake_toas: if either matrix isNone, it logs a warning and skips the correlated-noise term instead of crashing. This mirrors howTimingModel.full_designmatrix/full_wideband_designmatrixalready treat aNonenoise design matrix elsewhere in the same module, and follows the existinglog.warning-and-fall-back convention already used twice insimulation.pyfor other unexpected-but-non-fatal inputs.Reproducer (crashes before this fix, runs cleanly after):
Added a regression test,
test_simulate_corrnoise_no_noise_componentsintests/test_fake_toas.py, that callsmake_fake_toas_uniform(..., add_correlated_noise=True)on a model with no correlated-noise component; it fails onmasterand passes with this change.