Mantid
Loading...
Searching...
No Matches
CloneToNDArray.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2012 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
10#include <boost/python/detail/prefix.hpp>
11#include <vector>
12
13namespace Mantid {
14namespace PythonInterface {
15namespace Converters {
16namespace Impl {
17// Forward declaration of implementations. Keeps numpy header out of this header
18template <typename ElementType> PyObject *clone1D(const std::vector<ElementType> &cvector);
19template <typename ElementType> PyObject *cloneND(const ElementType *carray, const int ndims, Py_intptr_t *dims);
20} // namespace Impl
21
26struct Clone {
27 template <typename ElementType> struct apply {
34 static PyObject *create1D(const std::vector<ElementType> &cvector) { return Impl::clone1D<ElementType>(cvector); }
42 static PyObject *createFromArray(const ElementType *carray, const int ndims, Py_intptr_t *dims) {
43 return Impl::cloneND<ElementType>(carray, ndims, dims);
44 }
45 };
46};
47} // namespace Converters
48} // namespace PythonInterface
49} // namespace Mantid
PyObject * cloneND(const ElementType *carray, const int ndims, Py_intptr_t *dims)
Returns a new numpy array with the a copy of the data from array.
PyObject * clone1D(const std::vector< ElementType > &cvector)
Returns a new numpy array with the a copy of the data from 1D vector with the exception of string ele...
Helper class which provides the Collimation Length for SANS instruments.
static PyObject * createFromArray(const ElementType *carray, const int ndims, Py_intptr_t *dims)
Returns a Numpy array that has a copy of the array data.
static PyObject * create1D(const std::vector< ElementType > &cvector)
Returns a Numpy array that has a copy of the vectors data.
Clone is a policy (in the C++ sense)for converting to an ND Array.