Skip to content
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

DM-45010: Change RuntimeError to AlgorithmError #379

Merged
merged 1 commit into from
Sep 11, 2024
Merged

Conversation

cmsaunders
Copy link
Contributor

No description provided.

Copy link
Contributor

@parejkoj parejkoj left a comment

Choose a reason for hiding this comment

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

Please add a test to trigger this raising in test_normalizedCalibrationFlux.py. You should be able to make it fail by configuring the star selector to be excessively strict.

Comment on lines 47 to 50
msg = "There are no valid stars to compute normalized calibration fluxes."
msg += (f" Of {initNSources} initially selected sources, {nCalibFluxFlag} have good raw calibration "
f"fluxes and {nRefFluxFlag} have good reference fluxes.")
Copy link
Contributor

Choose a reason for hiding this comment

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

My only concern is that this doesn't seem like it contains quite the information one needs to reconstruct the failure conditions. n_sel==0 is the failure condition, but I don't quite know how the two "good" numbers you give in the error relate to that. Maybe that's ok, I'm just not sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The idea is to tell you which of the selection cuts is causing there to be no sources. My logic is that this is the first thing you would want to know if you encountered this error.

Comment on lines 298 to 300
n_sel = sel.sum()

if n_sel == 0:
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be a walrus:

Suggested change
n_sel = sel.sum()
if n_sel == 0:
if (n_sel := sel.sum()) == 0:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice, I need to build my walrus confidence.


Parameters
----------
initNSources : `int`
Copy link
Contributor

Choose a reason for hiding this comment

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

Does init here mean initial? Maybe spell that out explicitly, since these names go into the metadata that is written to disk. initialNSources or nInitialSources (or n_initial_sources, since it seems like we're more fully trying to move to snake_case these days?).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I went with n_initial_sources and also changed the other variables to snake_case because I realized this file is pretty much all snake case already.

"""
def __init__(self, *, initNSources, nCalibFluxFlag, nRefFluxFlag):
msg = "There are no valid stars to compute normalized calibration fluxes."
msg += (f" Of {initNSources} initially selected sources, {nCalibFluxFlag} have good raw calibration "
Copy link
Contributor

Choose a reason for hiding this comment

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

"raw"? Do you mean "original"? I'm not sure what "raw" means in this context.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the language that is used elsewhere in NormalizedCalibrationFlux. The config that does this selection is called raw_calibflux_name. Do you think it would be more clear to write "good raw_calibflux_name fluxes" or something like that?


@property
def metadata(self):
metadata = {"nInitSources": self.initNSources,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's worth being consistent about the variable name and the metadata.

Comment on lines 135 to 136
NormalizedCalibrationFluxError if there are not enough sources to
calculate normalization.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
NormalizedCalibrationFluxError if there are not enough sources to
calculate normalization.
NormalizedCalibrationFluxError
Raised If there are not enough sources to calculate normalization.

@cmsaunders cmsaunders merged commit d3ec6bc into main Sep 11, 2024
2 checks passed
@cmsaunders cmsaunders deleted the tickets/DM-45010 branch September 11, 2024 15:57
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.

2 participants