@@ -75,7 +75,7 @@ void G3Vector<int64_t>::save(A &ar, const unsigned v) const
7575 }
7676}
7777
78- template <typename V , typename T= typename V::value_type >
78+ template <typename T , typename V >
7979auto vector_from_python (const py::array_t <T> &buf, bool contiguous=true ) {
8080 if (buf.ndim () != 1 )
8181 throw py::type_error (" Only valid 1D buffers can be copied to a vector" );
@@ -91,11 +91,6 @@ auto vector_from_python(const py::array_t<T> &buf, bool contiguous=true) {
9191 return vec;
9292}
9393
94- template <typename V>
95- auto time_vector_from_python (const py::array &buf) {
96- return vector_from_python<V, G3TimeStamp>(buf, false );
97- }
98-
9994template <typename V>
10095auto vector_buffer_info (V &v) {
10196 using T = typename V::value_type;
@@ -123,7 +118,9 @@ template <typename V, typename C, typename... Args>
123118struct vector_buffer <G3Time, V, C, Args...> {
124119 static void impl (C &cls) {
125120 cls.def_buffer (&time_vector_buffer_info<V>);
126- cls.def (py::init (&time_vector_from_python<V>));
121+ cls.def (py::init ([](const py::array &v) {
122+ return vector_from_python<G3TimeStamp, V>(v, false );
123+ }), " Copy constructor from numpy array" );
127124 py::implicitly_convertible<py::buffer, V>();
128125 }
129126};
@@ -133,7 +130,8 @@ template <typename V, typename C, typename... Args> \
133130struct vector_buffer <T, V, C, Args...> { \
134131 static void impl (C &cls) { \
135132 cls.def_buffer (&vector_buffer_info<V>); \
136- cls.def (py::init (&vector_from_python<V>)); \
133+ cls.def (py::init ([](const py::array &v) { \
134+ return vector_from_python<T, V>(v, true ); })); \
137135 py::implicitly_convertible<py::buffer, V>(); \
138136 } \
139137}
0 commit comments