Mantid
Loading...
Searching...
No Matches
CArrayToNDArray.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 "MantidPythonInterface/core/Converters/WrapWithNumpy.h"
10
11namespace Mantid {
12namespace PythonInterface {
13namespace Converters {
14//-----------------------------------------------------------------------
15// Converter implementation
16//-----------------------------------------------------------------------
24template <typename ElementType, typename ConversionPolicy> struct CArrayToNDArray {
25 inline PyObject *operator()(const ElementType *carray, const int ndims, Py_intptr_t *dims) const {
26 // Round about way of calling the wrapNDArray template function that is
27 // defined
28 // in the cpp file
29 using policy = typename ConversionPolicy::template apply<ElementType>;
30 return policy::createFromArray(carray, ndims, dims);
31 }
32};
33} // namespace Converters
34} // namespace PythonInterface
35} // namespace Mantid
Helper class which provides the Collimation Length for SANS instruments.
Converter that takes a c array and its size then converts/wraps it into a numpy array.
PyObject * operator()(const ElementType *carray, const int ndims, Py_intptr_t *dims) const