Skip to content

Fix mixed unit error between angstroms and wavenumbers in extinction_extension.py#864

Merged
karllark merged 13 commits into
BEAST-Fitting:masterfrom
galaxyumi:extinction_ext
May 26, 2026
Merged

Fix mixed unit error between angstroms and wavenumbers in extinction_extension.py#864
karllark merged 13 commits into
BEAST-Fitting:masterfrom
galaxyumi:extinction_ext

Conversation

@galaxyumi

Copy link
Copy Markdown
Contributor

The bug was caused by two main issues within the extinction_extension.py: (1) a mixed usage of angstroms and wavenumbers, and (2) inconsistent input formatting requirements, where certain steps expected raw numerical values while others required values paired with Astropy units. I am opening this PR to resolve these mismatches. This PR addresses the issue #863.

@karllark

Copy link
Copy Markdown
Member

There is an error that causes the code not to run. Needs a fix of course.

@galaxyumi

galaxyumi commented May 21, 2026

Copy link
Copy Markdown
Contributor Author

@karllark, I've tried a couple of different approaches to address the git test errors. Since I can't replicate them in my local runs, I'm out of ideas—unless I modify the testing code inside the external dust_extinction package itself, which obviously isn't a good idea. Please let me know if you have any suggestions!

Just in case, my local python version is 3.12.3, Astropy version is 7.2, and Numpy version is 2.4.6. The different dependency versions might be a culprit.

@karllark

Copy link
Copy Markdown
Member

I wonder if you have an old version of dust_extinction installed. Maybe try updating it and seeing if that changes things.

@codecov

codecov Bot commented May 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 39.48%. Comparing base (1e07df4) to head (a89614c).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #864      +/-   ##
==========================================
+ Coverage   39.44%   39.48%   +0.03%     
==========================================
  Files         110      110              
  Lines       10756    10763       +7     
==========================================
+ Hits         4243     4250       +7     
  Misses       6513     6513              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment on lines +92 to +95
if x.unit == u.micron**-1:
x_um_inv = x
elif x.unit == u.Angstrom:
x_um_inv = x.to(u.micron**-1, equivalencies=u.spectral())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be just one line. Line 95 should give both behaviors. If already in 1/micron, it will do nothing.

@karllark karllark left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. One minor comment that may reduce the number of lines of code.

Comment on lines +216 to +219
if x.unit == u.micron**-1:
x_um_inv = x
elif x.unit == u.Angstrom:
x_um_inv = x.to(u.micron**-1, equivalencies=u.spectral())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above.

@karllark karllark left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last spelling error to fix than then I'll merge.

or assumes wavelengths in wavenumbers [1/micron]

internally wavenumbers are used
internally wavenubmers in inverse micron are used

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Argh. Spelling. Should be "wavenumbers."

@karllark karllark left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

@karllark karllark merged commit 8a608e1 into BEAST-Fitting:master May 26, 2026
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants