Repository navigation
Fix unit handling in Halo.fake_image - #55
Open
mandarmulherkar wants to merge 2 commits into
Open
mandarmulherkar wants to merge 2 commits into
mandarmulherkar wants to merge 2 commits into
Conversation
fake_image raised AttributeError on every call: it branched on self.lam_unit, an attribute removed in 949a0b6 when Halo migrated to astropy Quantities. Two further errors were masked behind it: self.lam was multiplied by u.angstrom despite already carrying a unit, and lmin/lmax were compared against unitless floats. self.lam carries its own unit, so the unit-string branching is unnecessary. Convert explicitly with the spectral equivalency instead, which handles any input unit rather than just two. Adds the first test coverage for fake_image.
This branch has not been deployed
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.
What is broken
AttributeErroron every call; two further errors were masked behind it.Fix
lamcarries its own unit, so the unit-string branching is unnecessary. One.to(u.keV, equivalencies=u.spectral())handles any input unit.lmin/lmaxget lam's unit before comparison.Tests
fake_image; each fails without its corresponding fix.Follow-ups (not addressed here)
fake_variable_imageingalhalo.pyhas the samelam_unitpattern, plus an undefinedvar_profilecaused by commit fe4c562 ("remaking docstrings") deleting the line that computes it, andtime_delayraisesUnitConversionErrorfor all inputs becaused_cmis a bare float. Happy to follow up in a separate PR.iend = max(...)looks like it drops the bin atlmax; noted but deliberately left alone.Co-authored by Claude: Claude explained the physics and checked my work; I added tests and code fixes.