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

Make required_keys always a set #383

Merged
merged 7 commits into from
Mar 2, 2024
Merged

Make required_keys always a set #383

merged 7 commits into from
Mar 2, 2024

Conversation

teutoburg
Copy link
Contributor

@teutoburg teutoburg commented Mar 2, 2024

Harmonize the required_keys of all effects to be a class attribute (as it will never change across instances) and a set (as that makes it simpler and more efficient to compare against the supplied keys in a dict using set methods). In the future, I'll probably move this check to the Effect base class and run it as part of the super().__init__() call in each effect (i.e. required_keys is an empty set in the base class, and overridden in the effect subclasses that need it).

Note: Yes, this is more dev wåñk. I did these changes a while ago, but never pushed and PR'd...

@teutoburg teutoburg self-assigned this Mar 2, 2024
@teutoburg teutoburg added the refactor Implementation improvement label Mar 2, 2024
Copy link

codecov bot commented Mar 2, 2024

Codecov Report

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

Project coverage is 74.94%. Comparing base (2d57b6f) to head (192a588).

Files Patch % Lines
scopesim/utils.py 80.00% 2 Missing ⚠️
scopesim/effects/apertures.py 75.00% 1 Missing ⚠️
scopesim/effects/electronic.py 93.75% 1 Missing ⚠️
scopesim/effects/rotation.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff               @@
##           dev_master     #383      +/-   ##
==============================================
+ Coverage       74.92%   74.94%   +0.02%     
==============================================
  Files              56       56              
  Lines            7768     7772       +4     
==============================================
+ Hits             5820     5825       +5     
+ Misses           1948     1947       -1     

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

@teutoburg teutoburg changed the title Fh/reqkeys Make required_keys always a set Mar 2, 2024
@teutoburg teutoburg marked this pull request as ready for review March 2, 2024 16:39
Copy link
Collaborator

@hugobuddel hugobuddel left a comment

Choose a reason for hiding this comment

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

Good, a bit more clear.

I think there should be a required_keys = set() in the top level Effect class, but you did not change that file so I can't make a suggestion.

scopesim/utils.py Show resolved Hide resolved
scopesim/utils.py Outdated Show resolved Hide resolved
@teutoburg
Copy link
Contributor Author

I think there should be a required_keys = set() in the top level Effect class, but you did not change that file so I can't make a suggestion.

Yeah, I'm planning to do that eventually, when moving the required keys check there (well, then I'll have to do it anyway, or get an AttributeError for some subclasses). But the corresponding utils function is used not only in the effects, but also in an optics submodule somewhere, so probably end up pointing back there from the Effect class. But it's still better than keeping it in the subclasses...

@teutoburg
Copy link
Contributor Author

I think there should be a required_keys = set() in the top level Effect class, but you did not change that file so I can't make a suggestion.

Yeah, I'm planning to do that eventually, when moving the required keys check there (well, then I'll have to do it anyway, or get an AttributeError for some subclasses). But the corresponding utils function is used not only in the effects, but also in an optics submodule somewhere, so probably end up pointing back there from the Effect class. But it's still better than keeping it in the subclasses...

Ok I now included that already anyway, cause why not.

@teutoburg teutoburg merged commit 9b49398 into dev_master Mar 2, 2024
25 checks passed
@teutoburg teutoburg deleted the fh/reqkeys branch March 2, 2024 23:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Implementation improvement
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

2 participants