-
Notifications
You must be signed in to change notification settings - Fork 42
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
Added function to create std::variant
for multiple array views.
#220
Added function to create std::variant
for multiple array views.
#220
Conversation
Hi @odlomax I think this is a great idea. |
Hi @wdeconinck, Thanks for the feedback! I'm on leave at the moment, but this is oddly recreational between baby's naps. I'll arrange a catch up when I'm back after next week. 🙂 |
Hi @wdeconinck. I believe I've incorporated all of your suggestions. It's ready for a look when you have the time. Cheers! |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #220 +/- ##
===========================================
+ Coverage 79.95% 80.02% +0.06%
===========================================
Files 792 794 +2
Lines 62309 62491 +182
===========================================
+ Hits 49822 50011 +189
+ Misses 12487 12480 -7 ☔ View full report in Codecov by Sentry. |
@wdeconinck Apologies for the last minute push. There were relatively important EXPECT statements that needed to be added to lines 139 and 164 of the test. I also removed some extraneous whitespace at the end of an otherwise untouched file. |
Okay, I won't touch this until it's reviewed. I promise! |
Hi @wdeconinck, When attempting to using this in anger (see PR #226), I found that it was worth refactoring the |
Hi @wdeconinck @sbrdar, I've refactored the introspection helpers as we discussed on Slack. I've also added an additional helper to distinguish between Cheers! |
@wdeconinck the latest push has your suggested signature for the introspection helpers. Thanks for the suggestion, it's a lot tidier. |
Basic GHA is passing now! https://github.com/JCSDA-internal/atlas/actions/runs/11157940876 |
MacOS tests! Nooo! |
https://github.com/ecmwf/atlas/actions/runs/11157941275/job/31068813417?pr=220 should not be the problem of this PR, but about the CI infrastructure. I passed on this problem. |
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.
This looks great now! Thanks!
During PR #218, I found myself writing two nested switch statements in order to create an
ArrayView
from anArray
. I've found myself writing this same pattern multiple times throughout Atlas, and indeed other external applications which use atlas.This PR adds provides an alternative to the nested switch statement. The method
util::make_array_view_variant<Values<types...>, Ranks<ints...>>(Array& array)
creates anstd::variant
ofArrayView
types, and then assigns the view that matchesarray
(so long as the value-type and rank can be found within theValues
andRanks
arguments respectively. TheArrayView
can then be accessed rather succinctly usingstd::visit
.