Skip to content

Commit

Permalink
STYLE: Remove local memoryView variables from "Bridge/NumPy"
Browse files Browse the repository at this point in the history
Directly return `PyMemoryView_FromBuffer(&pyBuffer)` instead.
  • Loading branch information
N-Dekker committed Oct 10, 2024
1 parent be745e2 commit 3cdddf7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 12 deletions.
4 changes: 1 addition & 3 deletions Modules/Bridge/NumPy/include/itkPyBuffer.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ PyBuffer<TImage>::_GetArrayViewFromImage(ImageType * image)
len *= sizeof(ComponentType);

PyBuffer_FillInfo(&pyBuffer, nullptr, itkImageBuffer, len, 0, PyBUF_CONTIG);
PyObject * const memoryView = PyMemoryView_FromBuffer(&pyBuffer);

return memoryView;
return PyMemoryView_FromBuffer(&pyBuffer);
}

template <class TImage>
Expand Down
4 changes: 1 addition & 3 deletions Modules/Bridge/NumPy/include/itkPyVectorContainer.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ PyVectorContainer<TElementIdentifier, TElement>::_array_view_from_vector_contain
len *= sizeof(DataType);

PyBuffer_FillInfo(&pyBuffer, nullptr, vectorBuffer, len, 0, PyBUF_CONTIG);
PyObject * const memoryView = PyMemoryView_FromBuffer(&pyBuffer);

return memoryView;
return PyMemoryView_FromBuffer(&pyBuffer);
}

template <typename TElementIdentifier, typename TElement>
Expand Down
8 changes: 2 additions & 6 deletions Modules/Bridge/NumPy/include/itkPyVnl.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ PyVnl<TElement>::_GetArrayViewFromVnlVector(VectorType * vector)
len *= sizeof(DataType);

PyBuffer_FillInfo(&pyBuffer, nullptr, vectorBuffer, len, 0, PyBUF_CONTIG);
PyObject * const memoryView = PyMemoryView_FromBuffer(&pyBuffer);

return memoryView;
return PyMemoryView_FromBuffer(&pyBuffer);
}

template <class TElement>
Expand Down Expand Up @@ -103,9 +101,7 @@ PyVnl<TElement>::_GetArrayViewFromVnlMatrix(MatrixType * matrix)
len *= sizeof(DataType);

PyBuffer_FillInfo(&pyBuffer, nullptr, matrixBuffer, len, 0, PyBUF_CONTIG);
PyObject * const memoryView = PyMemoryView_FromBuffer(&pyBuffer);

return memoryView;
return PyMemoryView_FromBuffer(&pyBuffer);
}

template <class TElement>
Expand Down

0 comments on commit 3cdddf7

Please sign in to comment.