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
9#include <boost/python/detail/prefix.hpp>
10#include <vector>
11
12namespace Mantid {
13namespace PythonInterface {
14namespace Converters {
15namespace Impl {
16// Forward declaration of implementations. Keeps numpy header out of this header
17template <typename ElementType> PyObject *clone1D(const std::vector<ElementType> &cvector);
18template <typename ElementType> PyObject *cloneND(const ElementType *carray, const int ndims, Py_intptr_t *dims);
19} // namespace Impl
20
25struct Clone {
26 template <typename ElementType> struct apply {
33 static PyObject *create1D(const std::vector<ElementType> &cvector) { return Impl::clone1D<ElementType>(cvector); }
41 static PyObject *createFromArray(const ElementType *carray, const int ndims, Py_intptr_t *dims) {
42 return Impl::cloneND<ElementType>(carray, ndims, dims);
43 }
44 };
45};
46} // namespace Converters
47} // namespace PythonInterface
48} // 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.