Skip to content

Make struct immutable#35

Merged
icweaver merged 1 commit into
mainfrom
mutability
Nov 5, 2025
Merged

Make struct immutable#35
icweaver merged 1 commit into
mainfrom
mutability

Conversation

@icweaver

@icweaver icweaver commented Nov 5, 2025

Copy link
Copy Markdown
Member

Closes #34

@codecov

codecov Bot commented Nov 5, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.28%. Comparing base (7ccd42d) to head (99e1e03).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #35   +/-   ##
=======================================
  Coverage   74.28%   74.28%           
=======================================
  Files           8        8           
  Lines         140      140           
=======================================
  Hits          104      104           
  Misses         36       36           

☔ 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.

@cgarling

cgarling commented Nov 5, 2025

Copy link
Copy Markdown
Member

Great, thanks!

@icweaver

icweaver commented Nov 5, 2025

Copy link
Copy Markdown
Member Author

I might have spoken too soon 😅. 1 test is currently breaking in our resampling PR. Will take a quick look

@icweaver

icweaver commented Nov 5, 2025

Copy link
Copy Markdown
Member Author

Ahhh, ok. This line, for example, tries to replace a mutable field with another one, which fails as expected when spec is made immutable

https://github.com/JuliaAstro/Spectra.jl/blob/46dfee47702c5b896dd05648e8e6fffd1b55e769/test/transforms/resample.jl#L22

I think sprinkling in a dot, e.g., spec.flux .= Spectra.flux(spec_new) , won't really save us here since we can't guarantee that the new array will be the same size.

Would it make sense to just return a new immutable struct instead?

@cgarling

cgarling commented Nov 5, 2025

Copy link
Copy Markdown
Member

Thanks for checking, sounds like there's an issue in the test code, not in the package code?

I think for resampling as per #26 we want to return a new instance rather than mutating an existing one. I'm not sure the resample! methods as defined in the test file make sense here

@icweaver

icweaver commented Nov 5, 2025

Copy link
Copy Markdown
Member Author

sgtm! Dropped in the other PR and will go ahead and merge here

@icweaver icweaver merged commit b52dd62 into main Nov 5, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mutable Spectrum?

2 participants