Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional kwargs in math.transpose(**kwargs) #865

Merged
merged 2 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file. The format
- Add the hessian of the element shape functions for a quadratic quad element `QuadraticQuad.hessian()`.
- Add the `order`-argument to `FieldContainer.extract(order="C")` as well as for `Field`, `FieldAxisymmetric`, `FieldPlaneStrain` to return C-contiguous arrays by default.
- Add an optional multiplier to `Laplace(multiplier=1.0)`.
- Add optional keyword-arguments to `math.transpose(**kwargs)` to support optional `out` and `order`-keywords.

### Changed
- Change default `np.einsum(..., order="K")` to `np.einsum(..., order="C")` in the methods of `Field`, `FieldAxisymmetric`, `FieldPlaneStrain` and `FieldContainer`.
Expand Down
6 changes: 3 additions & 3 deletions src/felupe/math/_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -819,12 +819,12 @@ def eigvalsh(A, shear=False):
return eigvals(A, shear=shear, eigvals=np.linalg.eigvalsh)


def transpose(A, mode=1):
def transpose(A, mode=1, **kwargs):
"Transpose (mode=1) or major-transpose (mode=2) of matrix A."
if mode == 1:
return np.einsum("ij...->ji...", A)
return np.einsum("ij...->ji...", A, **kwargs)
elif mode == 2:
return np.einsum("ijkl...->klij...", A)
return np.einsum("ijkl...->klij...", A, **kwargs)
else:
raise ValueError("Unknown value of mode.")

Expand Down
2 changes: 1 addition & 1 deletion src/felupe/mesh/_dual.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def dual(
Examples
--------
.. pyvista-plot::

>>> import felupe as fem
>>>
>>> mesh = fem.Rectangle(n=5).add_midpoints_edges()
Expand Down
6 changes: 3 additions & 3 deletions src/felupe/mesh/_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Point(Mesh):
Examples
--------
.. pyvista-plot::

>>> import felupe as fem
>>>
>>> mesh = fem.Point(a=-2.1)
Expand All @@ -44,10 +44,10 @@ class Point(Mesh):
Number of points: 1
Number of cells:
vertex: 1

>>> mesh.points
array([[-2.1]])

>>> mesh.cells
array([[0]])
"""
Expand Down
Loading