-
Notifications
You must be signed in to change notification settings - Fork 272
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
Refactor initialization of telescope parameters, move to own module #2190
Conversation
3d96716
to
a9481dd
Compare
ctapipe/core/telescope_component.py
Outdated
|
||
Returns | ||
------- | ||
instace |
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.
instace | |
Instance |
looked up by tel_id. This must be done before using the ``.tel[x]`` property | ||
""" | ||
self._subarray = subarray | ||
self._lookup.attach_subarray(subarray) |
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.
Does this work when in init self._lookup = None
?
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 assume this does not happen in "normal operations" but we might type-hint in __init__
anyways
default_value = self.validate(self, default_value) | ||
|
||
if "help" not in kwargs: | ||
self.help = "A TelescopeParameter" |
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.
Maybe this should raise an exception, to have everything documented?
default_value=[ | ||
("type", "*", 10.0), | ||
("type", "LST_LST_LSTCam", 100.0), | ||
("type", "*", 200.0), # should overwrite everything with 200.0 |
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.
("type", "*", 200.0), # should overwrite everything with 200.0 | |
("type", "*", 200.0), # should overwrite everything above with 200.0 |
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.
yes, this is much easier to follow. I didn't like relying on an exception to type-check
I came across code I didn't first understand in the initialization of the
TelescopeParameter
traits, trying to improve the code, I ran into a circular import problem (as the straight forward code would need to checkisinstance(trait, TelescopeParameter
andTelescopeComponent
is in a module imported byctapipe.core.traits
).So the best solution was to move the
TelescopeComponent
/TelescopeParameter
related things into their own submodulectapipe.core.telescope_component
.I think this is an improvement.
The main change (aside from moving things around) is replacing this code:
with
which is I think much clearer.
This also has the additional benefit of not silently ignoring errors that could potentially happen in
attach_subarray
.