| 81 | |
| 82 | template<typename T> |
| 83 | T PyArray_SafeSet(PyArrayObject* aobj, const npy_intp* indaux, const T& value) |
| 84 | { |
| 85 | // HORROR. |
| 86 | npy_intp* ind = const_cast<npy_intp*>(indaux); |
| 87 | void* ptr = PyArray_GetPtr(aobj, ind); |
| 88 | switch(PyArray_TYPE(aobj)) |
| 89 | { |
| 90 | case NPY_BOOL: |
| 91 | *reinterpret_cast<bool*>(ptr) = static_cast<bool>(value); |
| 92 | break; |
| 93 | case NPY_BYTE: |
| 94 | *reinterpret_cast<char*>(ptr) = static_cast<char>(value); |
| 95 | break; |
| 96 | case NPY_SHORT: |
| 97 | *reinterpret_cast<short*>(ptr) = static_cast<short>(value); |
| 98 | break; |
| 99 | case NPY_INT: |
| 100 | *reinterpret_cast<int*>(ptr) = static_cast<int>(value); |
| 101 | break; |
| 102 | case NPY_LONG: |
| 103 | *reinterpret_cast<long*>(ptr) = static_cast<long>(value); |
| 104 | break; |
| 105 | case NPY_LONGLONG: |
| 106 | *reinterpret_cast<long long*>(ptr) = static_cast<long long>(value); |
| 107 | break; |
| 108 | case NPY_UBYTE: |
| 109 | *reinterpret_cast<unsigned char*>(ptr) = static_cast<unsigned char>(value); |
| 110 | break; |
| 111 | case NPY_USHORT: |
| 112 | *reinterpret_cast<unsigned short*>(ptr) = static_cast<unsigned short>(value); |
| 113 | break; |
| 114 | case NPY_UINT: |
| 115 | *reinterpret_cast<unsigned int*>(ptr) = static_cast<unsigned int>(value); |
| 116 | break; |
| 117 | case NPY_ULONG: |
| 118 | *reinterpret_cast<unsigned long*>(ptr) = static_cast<unsigned long>(value); |
| 119 | break; |
| 120 | case NPY_ULONGLONG: |
| 121 | *reinterpret_cast<unsigned long long*>(ptr) = static_cast<unsigned long long>(value); |
| 122 | break; |
| 123 | case NPY_FLOAT: |
| 124 | *reinterpret_cast<float*>(ptr) = static_cast<float>(value); |
| 125 | break; |
| 126 | case NPY_DOUBLE: |
| 127 | *reinterpret_cast<double*>(ptr) = static_cast<double>(value); |
| 128 | break; |
| 129 | case NPY_LONGDOUBLE: |
| 130 | *reinterpret_cast<long double*>(ptr) = static_cast<long double>(value); |
| 131 | break; |
| 132 | default: |
| 133 | throw std::runtime_error("data type not supported"); |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | #endif |
nothing calls this directly
no outgoing calls
no test coverage detected