-
Notifications
You must be signed in to change notification settings - Fork 10
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
Add SourceField
and subclasses, rework Source
#405
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #405 +/- ##
==========================================
+ Coverage 75.97% 76.53% +0.56%
==========================================
Files 64 65 +1
Lines 7820 7970 +150
==========================================
+ Hits 5941 6100 +159
+ Misses 1879 1870 -9 ☔ View full report in Codecov by Sentry. |
dad621f
to
428f959
Compare
SourceField
and subclasses, rework Source
This pickle functionality wasn't used anywhere Keep it around for now in case I was mistakten. To be replaces with a YAML-based solution in the future... Early raise... No more np.all
Fix broken cube test, cube stuff and plotting Minor stuff and more units, fix failing tests
428f959
to
613454d
Compare
Could you please summarize the idea behind these changes so it is recorded somewhere? I didn't follow the full discussion at Waidhofen, so I'll trust you on that. |
Added this information as a module docstring in |
Class diagram from the module docstring, because it doesn't yet render anywhere else: classDiagram
class SourceField{+field}
class SpectrumSourceField{+spectra}
class HDUSourceField{+wcs}
SourceField <|-- SpectrumSourceField
SourceField <|-- HDUSourceField
SpectrumSourceField <|-- TableSourceField
SpectrumSourceField <|-- ImageSourceField
HDUSourceField <|-- ImageSourceField
HDUSourceField <|-- CubeSourceField
|
ScopeSim_Templates is now broken:
Could you please either make this PR (even more) backwards compatible or otherwise create a sibling-PR for ScopeSim_Templates? |
Did you verify that everything in the IRDB functions with the new SourceField classes? |
I gathered from the Waidhofen meeting that we (later) want to support more parametric sources. E.g. an 'image' that might not have a pixel array associated with it. How would that fit in this scheme? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @teutoburg! ScopeSim keeps getting better! The decoupling between field/spectra/meta was pretty painful to work with (e.g. that [{}]
assert...), now it is much better and more extensible.
Please judge for yourself how to deal with my comments. There are many, but most of them are pretty minor, and some of the larger ones might be postponed.
def _write_stream(self, stream: TextIO) -> None: | ||
raise NotImplementedError("Subclasses should implement this.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment on Source.__repr__()
. I believe _write_stream()
is not necessary.
Oh I'm being stupid, I didn't notice AstarVienna/ScopeSim_Templates#91 and I was on a branch so |
Co-authored-by: Hugo Buddelmeijer <[email protected]>
Co-authored-by: Hugo Buddelmeijer <[email protected]>
Some code (mostly in ScopeSim_Templates) relies on single-field sources exposing their field meta as the Source's meta. If there's more than one field, the metas should always be accessed through the fields to avoid ambiguity. This (hacky) solution now seems to work and is certainly better than silently always returning just the first field's meta. Also removed the setter for meta. It's a dict, so if it needs to be updated, just do that. It should never be replaced (== overwritten!) anyway.
We should really properly test cube somewhere (other than the notebooks). Running |
Ah, because that only runs the notebooks in the ScopeSim repo itself, not the IRDB ones. Is that intentional? |
Yes the ScopeSim test only runs the notebooks in ScopeSim itself, as I thought it would be best that (as a default) each project only runs their own tests/notebooks. ScopeSim_Data is the only exception, it runs all the tests and notebooks of all our projects, because it has to do so in order to fetch the files those tests and notebooks need. And ScopeSim_Data thereby doubles as a full end-to-end test. Hence my question whether everything in the IRDB still works. Ultimately it would be great if we have some (minimal) tests in ScopeSim proper, and only use the IRDB notebooks as integration tests. |
aka fix cube wcs mess that broke METIS notebooks...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll assume your latest commit fixes the IRDB notebooks. The things open are al minor, so I'll let you decide when this is ready to merge.
To also address this before finally merging: My current idea (might change as things develop) is that the |
@hugobuddel thanks for the extensive review process! I know it took me a while to react to all of it (or indeed most of it, I'm leaving the less important repr stuff for discussion at a later point, because that's more cosmetical), but it did point me to a few things that I would have missed otherwise and that would have come back to bite me later. Now, some 4 months after initially starting this refactor process, I'm happy to finally press the big green button 🚀 |
Great! I learned quite a bit about our code base too. |
Some
minormajor refactoring in vague preparation of scopesim-targets...Main changes
SourceField
and subclasses: As discussed in the Waidhofen hackathon, this family of classes will now hold the source fields as part of theSource
class. Different subclasses exist for different kinds of fields (table, image, cube). This produced a bit of a rat-tail of changes elsewhere, but should ultimately move us forward.Source.spectra
(now just a collection of allfield.spectra
) adict
. This was a rather minimal change with limited need to adapt elsewhere, but is a lot more explicit on which spectra are referenced where, instead of hoping the the indices of the previouslist
don't get mixed up when changing stuff in the source.Other changes
Source
class.Further notes
Ignore all the force pushes, which resulted from rebasing...
This needs 3.10, so waiting for that...