Change args of create_topology to NDArray - #4369
Open
schnellerhase wants to merge 6 commits into
Open
Conversation
schnellerhase
commented
Aug 6, 2026
Comment on lines
+343
to
+354
| auto to_vec_of_spans | ||
| = []<typename T>( | ||
| const std::vector<nb::ndarray<T, nb::ndim<1>, nb::c_contig>>& | ||
| vec) | ||
| { | ||
| std::vector<std::span<T>> vec_span; | ||
| vec_span.reserve(vec.size()); | ||
| std::ranges::transform( | ||
| vec, std::back_inserter(vec_span), | ||
| [](auto& nd) { return std::span<T>(nd.data(), nd.size()); }); | ||
| return vec_span; | ||
| }; |
Contributor
Author
There was a problem hiding this comment.
Shall this be moved to a shared implementation in array.h? Other exports (mostly mixed topology related) have similar code paths.
Member
There was a problem hiding this comment.
It is also in a few other wrapper places:
https://github.com/search?q=repo%3AFEniCS%2Fdolfinx+std%3A%3Avector%3Cstd%3A%3Aspan+path%3A%2F%5Epython%5C%2Fdolfinx%5C%2Fwrappers%5C%2F%2F&type=code
schnellerhase
requested review from
chrisrichardson,
garth-wells,
jorgensd and
michalhabera
August 6, 2026 07:41
jorgensd
reviewed
Aug 6, 2026
Co-authored-by: Jørgen Schartum Dokken <dokken92@gmail.com>
jorgensd
reviewed
Aug 6, 2026
jorgensd
reviewed
Aug 6, 2026
jorgensd
reviewed
Aug 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Caught by
mypycheck on downstream usage ofcreate_topology, while possible due to implicit conversions, we should stick to theNDArrayin the interface.Previously this implied the (non numpy compatible signature):
now