diff --git a/mfem/common/array_instantiation_macro.i b/mfem/common/array_instantiation_macro.i index 4dfc0e8a..f979f64f 100644 --- a/mfem/common/array_instantiation_macro.i +++ b/mfem/common/array_instantiation_macro.i @@ -300,65 +300,6 @@ INSTANTIATE_ARRAY0(XXX, XXX, 0) }; %enddef - // tool to deffine mfem::Array returining elements using numpy Scalar - // mfem::Array(unsigned int) -> uintArray - // NP_TYPE is things like NPY_FLOAT32 -%define INSTANTIATE_ARRAY_NUMPYARRAY(XXX, YYY, NP_TYPE) -%template(##XXX##Array) mfem::Array; -%extend mfem::Array { - PyObject * __getitem__(PyObject* param) { - int len = self->Size(); - if (PySlice_Check(param)) { - long start = 0, stop = 0, step = 0, slicelength = 0; - int check; - - //%#ifdef TARGET_PY3 - check = PySlice_GetIndicesEx(param, len, &start, &stop, &step, - &slicelength); - //%#else - //check = PySlice_GetIndicesEx((PySliceObject*)param, len, &start, &stop, &step, - // &slicelength); - //%#endif - - if (check == -1) { - PyErr_SetString(PyExc_ValueError, "Slicing mfem::Array failed."); - return NULL; - } - if (step == 1) { - mfem::Array *vec; - vec = new mfem::Array(self->GetData() + start, slicelength); - return SWIG_NewPointerObj(SWIG_as_voidptr(vec), $descriptor(mfem::Array *), 1); - } else { - PyErr_SetString(PyExc_ValueError, "Slicing mfem::Array with stride>1 not supported."); - return NULL; - } - } else { - PyErr_Clear(); - long idx = PyInt_AsLong(param); - if (PyErr_Occurred()) { - PyErr_SetString(PyExc_ValueError, "Argument must be either int or slice"); - return NULL; - } - PyObject *np_val = NULL; - PyArray_Descr *descr = NULL; - if(! (descr = PyArray_DescrFromType(NP_TYPE))) { - PyErr_SetString(PyExc_TypeError, "Improper descriptor"); - return NULL; - } - - YYY *data_ptr; - if (idx >= 0){ - data_ptr = &(self->operator[](idx)); - } else { - data_ptr = &(self->operator[](idx+len)); - } - np_val = PyArray_Scalar(data_ptr, descr, NULL); - return np_val; - } - } - }; -%enddef - %define IGNORE_ARRAY_METHODS(XXX) %ignore mfem::Array::Union;