nextsimhub / nextsimdg

neXtSIM_DG : next generation sea-ice model with DG
https://nextsim-dg.readthedocs.io/en/latest/?badge=latest
Apache License 2.0
10 stars 13 forks source link

ModelArraySlice and slicing infrastructure #736

Open timspainNERSC opened 3 days ago

timspainNERSC commented 3 days ago

ModelArraySlice and slicing infrastructure

Fixes #735

Change Description

Adds a class to allow slicing ModelArrays in order to use part of the data within. Also includes the ArraySlicer::Slice class that provides the slicing syntax and an iterator class for accessing data.


Test Description

Several test cases that check that the slicing syntax is correctly interpreted and that making reasonable slices produces expected results. To fully test the slice syntax, a comprehensive suite of cases is defined. As far as possible, the class is designed to behave like the numpy Python library.


Documentation Impact

A section will need to be added to the eventual ModelArray developer documentation. As this does not yet exist, there is nothing to add as part of this PR.

TomMelt commented 3 days ago

just mentioning for future reference... If we move to c++23 we may wish to consider using mdspans. This would allow us to easily switch between 1D and N-D array views.