Skip to content

Conversation

@astronomyk
Copy link
Collaborator

@astronomyk astronomyk commented Feb 22, 2024

As above, added cmds to all the from_currsys calls that I somehow missed last time.
I have not touched the tests that use from_currsys

Arguably the next step is to simply remove all the currsys calls from objects that contain a self.cmds property following the scheme var = self.cmds["!some.thing"] instead of from_currsys("!some.thing", self.cmds)
But this is for next weeks train ride home at 22:00 ...

@astronomyk astronomyk changed the title additions of cmds to all remaining currsys calls (excluding test functions Added missing cmds to currsys calls in scopesim codebase Feb 22, 2024
@codecov
Copy link

codecov bot commented Feb 22, 2024

Codecov Report

Attention: Patch coverage is 76.47059% with 8 lines in your changes are missing coverage. Please review.

Project coverage is 74.28%. Comparing base (d48bd03) to head (06362e4).

Files Patch % Lines
scopesim/effects/metis_lms_trace_list.py 14.28% 6 Missing ⚠️
scopesim/effects/rotation.py 0.00% 1 Missing ⚠️
scopesim/optics/fov_utils.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff               @@
##           dev_master     #372      +/-   ##
==============================================
+ Coverage       74.26%   74.28%   +0.01%     
==============================================
  Files              56       56              
  Lines            7811     7815       +4     
==============================================
+ Hits             5801     5805       +4     
  Misses           2010     2010              

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

@astronomyk
Copy link
Collaborator Author

I'll go ahead and merge this. Locally everything is green in ScopeSim and IRDB - except for the 3 logging test. I'll leave these up to @teutoburg to fix ;)

@astronomyk astronomyk merged commit d32dd06 into dev_master Feb 23, 2024
@astronomyk astronomyk deleted the kl/fix_currsys_surface_list branch February 23, 2024 10:14
@hugobuddel
Copy link
Collaborator

Links to previous PR's: #364, #368, #369

@hugobuddel
Copy link
Collaborator

hugobuddel commented Feb 23, 2024

As above, added cmds to all the from_currsys calls that I somehow missed last time. I have not touched the tests that use from_currsys

It seems like you missed some.

Using the same ripgrep command as in #368, manually removing tests and comments:

$ rg "from_currsys\([^,]*\)"

scopesim/utils.py
517:    if from_currsys("!SIM.file.error_on_missing_file"):
880:                item = from_currsys(item)

scopesim/optics/fov.py
566:        wave_unit = u.Unit(from_currsys("!SIM.spectral.wave_unit"), self.cmds)
569:            from_currsys("!SIM.spectral.spectral_bin_width"), self.cmds) * wave_unit

scopesim/optics/optical_train.py
326:            wave_unit = u.Unit(from_currsys("!SIM.spectral.wave_unit"), self.cmds)

scopesim/reports/rst_utils.py
309:        path = from_currsys(rc.__config__["!SIM.reports.latex_path"])
348:        path = from_currsys(rc.__config__["!SIM.reports.rst_path"])

scopesim/effects/ter_curves.py
875:        transmission = from_currsys(transmission)
918:        for name in from_currsys(self.meta["adc_names"]):
940:        curradc = from_currsys(self.meta["current_adc"])

scopesim/effects/ter_curves_utils.py
55:        filter_name = from_currsys(filter_name)

scopesim/effects/psf_utils.py
114:        spline_order = utils.from_currsys("!SIM.computing.spline_order")

@hugobuddel
Copy link
Collaborator

Note that some of these seem to indicate bigger problems, because they appear to indicate that you added self.cmds as an argument to the from_currsys function, but instead added them to another function.

I take it that you did run the full irdb suite, including notebooks to test these changes before merging them.

This code is now obviously broken, but apparently it is not used anywhere?

Comment on lines +474 to +475
def __init__(self, **kwargs):
super().__init__(**kwargs)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why did you undo these changes? It is better to make the cmds argument explicit and limit the use of kwargs to arguments you don't expect.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep. I get that. But this ends in a bigger oroject of making sure every effect object has the explicit argument cmds in the init call

fname = str(path).format(name)
self.trace_lists[name] = SpectralTraceList(filename=fname,
name=name,
cmds=self.cmds,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Idem, it is better to be explicit, why did you remove this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was removed because cmds was also found in the kwargs. So to avoid doubling up on passing arguments, I left everything in kwargs

fov_waveset = np.arange(
self.meta["wave_min"].value, self.meta["wave_max"].value,
from_currsys("!SIM.spectral.spectral_bin_width")) * wave_unit
from_currsys("!SIM.spectral.spectral_bin_width"), self.cmds) * wave_unit
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is broken.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks. Curious.

# 1. Make waveset and canvas cube (area, bin_width are applied at end)
# TODO: Why is this not self.waveset? What's different?
wave_unit = u.Unit(from_currsys("!SIM.spectral.wave_unit"))
wave_unit = u.Unit(from_currsys("!SIM.spectral.wave_unit"), self.cmds)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also broken.

@astronomyk
Copy link
Collaborator Author

Indeed I ran all the scopesim and IRDB tests, but didn't check the notebooks. Everything was green locally and on github actions, except for the logging tests.
I'll teopen this can of worms tonight ...
Thanks again for the review!

@hugobuddel
Copy link
Collaborator

Indeed I ran all the scopesim and IRDB tests, but didn't check the notebooks. Everything was green locally and on github actions, except for the logging tests. I'll teopen this can of worms tonight ... Thanks again for the review!

I did not run all the notebooks either. I think they might all work. The now-broken code is in the LMS parts, in make_cube_hdu() and in the cube part of prepare_source(). So the bigger problem is that we do not test that code properly.

@teutoburg teutoburg added the no release notes Do not include this PR in the release notes label Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no release notes Do not include this PR in the release notes

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants