diff --git a/README.md b/README.md index 1fd80acc..cd6e7bd8 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,9 @@ All notable changes to this project will be documented in this file. The format ## [Unreleased] +### Fixed +- Fix `tovoigt()` helper for data with more or less than two trailing axes. + ## [3.1.0] - 2022-05-02 ### Added diff --git a/felupe/math/_tensor.py b/felupe/math/_tensor.py index 1d68cc7f..2c049bba 100644 --- a/felupe/math/_tensor.py +++ b/felupe/math/_tensor.py @@ -279,8 +279,8 @@ def ddot(A, B, n=2, parallel=False): def tovoigt(A): "Convert (3, 3) tensor to (6, ) voigt notation." - B = np.zeros((6, *A.shape[-2:])) + B = np.zeros((6, *A.shape[2:])) ij = [(0, 0), (1, 1), (2, 2), (0, 1), (1, 2), (0, 2)] for i6, (i, j) in enumerate(ij): - B[i6, :, :] = A[i, j, :, :] + B[i6] = A[i, j] return B