Skip to content

Commit

Permalink
PyArray_DIMS returns npy_intp (#1634)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevengj authored Jun 24, 2021
1 parent 6b102ff commit bcb90f3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions python/meep.i
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@ void _get_gradient(PyObject *grad, PyObject *fields_a, PyObject *fields_f, PyObj
if (!PyArray_ISCARRAY(pao_grad)) meep::abort("Numpy grad array must be C-style contiguous.");
if (PyArray_NDIM(pao_grad) !=2) {meep::abort("Numpy grad array must have 2 dimensions.");}
double *grad_c = (double *)PyArray_DATA(pao_grad);
int ng = PyArray_DIMS(pao_grad)[1]; // number of design parameters
npy_intp ng = PyArray_DIMS(pao_grad)[1]; // number of design parameters

// clean the adjoint fields array
PyArrayObject *pao_fields_a = (PyArrayObject *)fields_a;
Expand Down Expand Up @@ -844,7 +844,7 @@ void _get_gradient(PyObject *grad, PyObject *fields_a, PyObject *fields_f, PyObj
if (!PyArray_Check(pao_freqs)) meep::abort("frequencies parameter must be numpy array.");
if (!PyArray_ISCARRAY(pao_freqs)) meep::abort("Numpy fields array must be C-style contiguous.");
double *frequencies_c = (double *)PyArray_DATA(pao_freqs);
int nf = PyArray_DIMS(pao_freqs)[0];
npy_intp nf = PyArray_DIMS(pao_freqs)[0];
if (PyArray_DIMS(pao_grad)[0] != nf) meep::abort("Numpy grad array is allocated for %td frequencies; it should be allocated for %td.",PyArray_DIMS(pao_grad)[0],nf);

// prepare a geometry_tree
Expand Down

0 comments on commit bcb90f3

Please sign in to comment.