Create a view of an array in a different data type. This function may fundamentally reinterpret the data in the array. It is the responsibility of the caller to ensure that this is safe. Only supports the `dtype` argument, the `type` argument is omitted, to be added as needed.
| 1083 | /// Only supports the `dtype` argument, the `type` argument is omitted, |
| 1084 | /// to be added as needed. |
| 1085 | array view(const std::string &dtype) { |
| 1086 | auto &api = detail::npy_api::get(); |
| 1087 | auto new_view = reinterpret_steal<array>(api.PyArray_View_( |
| 1088 | m_ptr, dtype::from_args(pybind11::str(dtype)).release().ptr(), nullptr)); |
| 1089 | if (!new_view) { |
| 1090 | throw error_already_set(); |
| 1091 | } |
| 1092 | return new_view; |
| 1093 | } |
| 1094 | |
| 1095 | /// Ensure that the argument is a NumPy array |
| 1096 | /// In case of an error, nullptr is returned and the Python error is cleared. |
no test coverage detected