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

Allow for empty "properties" subdict #32

Merged
merged 1 commit into from
Feb 16, 2024
Merged

Allow for empty "properties" subdict #32

merged 1 commit into from
Feb 16, 2024

Conversation

teutoburg
Copy link
Collaborator

@teutoburg teutoburg commented Feb 15, 2024

Fixes a long-ignored bug where some keys could "get lost" in the __currsys__ if an "alias" but no "properties" is present in a yaml dict. This occurs e.g. in MICADO's default.yaml in the SCAO and MCAO modes, that don't (and probably don't need to) define any "properties". But then NestedMapping.update() defaults to simply updating key-value-wise.

Devil's Advocaat

The alternative would be to introduce an empty "properties" in each of the yamls. But then people will forget that somewhere and we're back at the bug, so that's fragile. Also would probably require an update to multiple IRDB packages, which is annoying.

Rant

I'm generally not a fan of this "abusive" overloading of the .update() method. I think that method should only do what you'd expect from a standard dict (in fact, by inheriting from collections.abc.MutableMapping, we wouldn't even need to define such a "standard" .update() method here...). The "special sauce" that's added here is also rather ScopeSim-specific and thus shouldn't really be in astar-utils to begin with. Perhaps an extra method (.update_alias()??) would be fine though. Same thing actually goes for UserCommands.update() over in ScopeSim, although I started to mitigate that in the (as of writing this un-PR'd) fh/chainmap branch...

@teutoburg teutoburg self-assigned this Feb 15, 2024
Copy link

codecov bot commented Feb 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (445264f) 99.04% compared to head (ce08c1e) 99.05%.
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #32   +/-   ##
=======================================
  Coverage   99.04%   99.05%           
=======================================
  Files           5        5           
  Lines         315      316    +1     
=======================================
+ Hits          312      313    +1     
  Misses          3        3           

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

@teutoburg teutoburg marked this pull request as ready for review February 15, 2024 00:59
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! Sorry for taking so long to review.

It seems reasonable to have this alias and properties stuff somewhere if that is useful to ScopeSim, since that is the main reason we have these classes right?

@teutoburg teutoburg merged commit 3905bde into main Feb 16, 2024
21 checks passed
@teutoburg teutoburg deleted the fh/propdict branch February 16, 2024 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants