File: arrvec.h

package info (click to toggle)
gemmi 0.6.5%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 5,836 kB
  • sloc: cpp: 54,719; python: 4,743; ansic: 3,972; sh: 384; makefile: 73; f90: 42; javascript: 12
file content (9 lines) | stat: -rw-r--r-- 327 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
#pragma once
#include <pybind11/numpy.h>

template<typename T>
pybind11::array_t<T> py_array_from_vector(std::vector<T>&& original_vec) {
  auto v = new std::vector<T>(std::move(original_vec));
  pybind11::capsule cap(v, [](void* p) { delete (std::vector<T>*) p; });
  return pybind11::array_t<T>(v->size(), v->data(), cap);
}