Skip to content

Commit

Permalink
Merge pull request #219 from adtzlr/fix-tovoigt
Browse files Browse the repository at this point in the history
Fix `tovoigt()` helper
  • Loading branch information
adtzlr authored May 3, 2022
2 parents 053c44e + d4a127b commit 7c632b7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions felupe/math/_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 7c632b7

Please sign in to comment.