Is there a way to create a view for a numpy.ndarray
that will only return specific items in a specific shape?
I'm working on a project with a material stress tensor matrix. I have created an ndarray
sublcass that must maintain a 3x3 shape for its base. There is one module, however, that requires the tensor to be in Voigt notation. Unfortunately, this is not easily done by a simple reshape
function because of the order of the entities in the matrix.
I would like to be able to keep the single ndarray
subclass and just create a separate view for the calculations that require this notation.
As of now, the best I've been able to come up with is creating a function that constructs and returns a new array from the instance's data
property. It normally wouldn't be a big deal, but the calculations I need it for will need to be performed millions of times.