Skip to content

get_numpy_from_vector_*#56

Merged
DavidLapous merged 1 commit intoDavidLapous:mainfrom
hschreiber:vector_to_numpy
Mar 9, 2026
Merged

get_numpy_from_vector_*#56
DavidLapous merged 1 commit intoDavidLapous:mainfrom
hschreiber:vector_to_numpy

Conversation

@hschreiber
Copy link
Contributor

While I am flattening the outputs of Summand and Module, I added a method to move a cython vector[] to a numpy array without copying and with something equivalent to ownership transfer, i.e. the result is the same than res = numpy.asarray(<dtype[:a, :b]>(vec.data())) but such that res will remain valid after vec is destroyed and vec looses access to the data to avoid accidents.

I tested it for the plottings and it seems to work. As I won't be working on this for at least 3 weeks, I thought I should make a PR out of it before finishing with Summand and Module such that, in the mean time, @DavidLapous can play with it on other class/methods if he wants.

@DavidLapous DavidLapous merged commit 32a6b75 into DavidLapous:main Mar 9, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants