Skip to content

Commit

Permalink
Merge pull request #7 from Renumics/performance_01
Browse files Browse the repository at this point in the history
Performance 01
  • Loading branch information
markus-stoll authored Dec 5, 2023
2 parents 43d7308 + 80eeca7 commit c862997
Show file tree
Hide file tree
Showing 14 changed files with 1,095 additions and 153 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
python-version: "3.9"
- name: check
run: |
poetry run pylint mesh2vec tests scripts docs/examples
poetry run pylint mesh2vec tests docs/examples
audit:
needs: [prepare-linux, prepare-win]
Expand Down Expand Up @@ -95,7 +95,7 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: test
run: |
poetry run sphinx-build docs/source build/documentation/ -W -b html # autodocs contain tests && poetry run sphinx-build docs/source build/documentation/ -W -b doctest
poetry run sphinx-build docs/source build/documentation/ -W -b html && poetry run sphinx-build docs/source build/documentation/ -W -b doctest
unit-tests:
needs: [prepare-linux, prepare-win]
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@
/docs/source/generated*
__pycache__
/data/tmp_*
/data/*internal*
/data/*internal*
.DS_Store
.venv/
.ipynb_checkpoints
data/data/temp_hg.joblib
32 changes: 11 additions & 21 deletions docs/examples/plot_stress.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# pylint: disable=pointless-statement
from pathlib import Path
import numpy as np
import pandas as pd
from lasso.dyna import ArrayType
from mesh2vec.mesh2vec_cae import Mesh2VecCae

Expand All @@ -19,34 +18,25 @@
Path("../../data/hat/Hatprofile.k"),
json_mesh_file=Path("../../data/hat/cached_hat_key.json"),
)
hg.add_feature_from_d3plot(


def mean_over_components_all_layers(v):
"""get mean over all components and all layers"""
return np.mean(v, axis=-1)


fature_name = hg.add_feature_from_d3plot(
ArrayType.element_shell_stress,
Path("../../data/hat/HAT.d3plot"),
timestep=1,
shell_layer=0,
timestep=-1,
shell_layer=mean_over_components_all_layers,
)


# %%
# Plot Feature locally
# ------------------------
hg.add_features_from_dataframe(
pd.DataFrame(
{
"vtx_id": hg.vtx_ids(),
"y-stress": [v[1] for v in hg.features()[ArrayType.element_shell_stress + "_1_0"]],
}
)
)
name = hg.aggregate("y-stress", 0, np.mean)
fig = hg.get_visualization_plotly(str(name))
fig.update_layout(title=name)
fig

# %%
# Aggregate Feature and plot
# ---------------------------
name = hg.aggregate("y-stress", 1, np.mean)
name = hg.aggregate(fature_name, 1, lambda x: np.mean(np.mean(x)))
fig = hg.get_visualization_plotly(str(name))
fig.update_layout(title=name)
fig
Expand Down
Loading

0 comments on commit c862997

Please sign in to comment.