Skip to content

Commit

Permalink
Merge branch 'master' into schema_cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
CagtayFabry authored Nov 12, 2024
2 parents 1c85c27 + 727b6a2 commit f237191
Show file tree
Hide file tree
Showing 13 changed files with 181 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_pkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
fetch-depth: 0 # Fetch all history for all tags and branches

- name: Setup Conda Environment
uses: mamba-org/setup-micromamba@v1.9.0
uses: mamba-org/setup-micromamba@v2.0.1
with:
environment-file: ./devtools/conda.recipe/build_env.yml
environment-name: build_env
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
fetch-depth: 0 # Fetch all history for all tags and branches

- name: Setup Conda Environment
uses: mamba-org/setup-micromamba@v1.9.0
uses: mamba-org/setup-micromamba@v2.0.1
with:
environment-file: ./doc/rtd_environment.yml
environment-name: rtd
Expand Down
19 changes: 11 additions & 8 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,30 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
py: ['3.9', '3.10', '3.11']
py: ['3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v4
with:
fetch-depth: '0' # Fetch all history for all tags and branches

- uses: CagtayFabry/pydeps2env@v1.2.0
- uses: marscher/pydeps2env@v999
with:
files: 'pyproject.toml'
channels: 'conda-forge defaults'
extras: 'test vis media'
build_system: 'include'

- name: Setup Conda Environment
uses: mamba-org/setup-micromamba@v1.9.0
uses: mamba-org/setup-micromamba@v2.0.1
with:
micromamba-version: "2.0.2-0"
environment-file: ./environment.yml
environment-name: weldx
init-shell: >-
bash
powershell
cache-environment: true
# persist on the same day.
cache-environment-key: environment-${{ steps.date.outputs.date }}
create-args: >-
python=${{ matrix.py }}
wheel
Expand Down Expand Up @@ -133,28 +135,29 @@ jobs:
fail-fast: false
matrix:
os: [windows-latest]
py: ['3.9']
py: ['3.10']
steps:
- uses: actions/checkout@v4
with:
fetch-depth: '0' # Fetch all history for all tags and branches

- uses: CagtayFabry/pydeps2env@v1.2.0
- uses: marscher/pydeps2env@v999
with:
files: 'pyproject.toml'
channels: 'conda-forge defaults'
extras: 'test vis media'
build_system: 'include'

- name: Setup Conda Environment
uses: mamba-org/setup-micromamba@v1.9.0
uses: mamba-org/setup-micromamba@v2.0.1
with:
environment-file: ./environment.yml
environment-name: weldx
init-shell: >-
bash
powershell
cache-environment: true
# persist on the same day.
cache-environment-key: environment-${{ steps.date.outputs.date }}
create-args: >-
python=${{ matrix.py }}
wheel
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pytest_asdf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
setup_requires: 'include'

- name: Setup Conda Environment
uses: mamba-org/setup-micromamba@v1.9.0
uses: mamba-org/setup-micromamba@v2.0.1
with:
environment-file: ./environment.yml
environment-name: weldx
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/static_analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ jobs:
key: ${{ runner.os }}-${{ hashFiles('./environment.yml') }}

- name: Setup Conda Environment
uses: mamba-org/setup-micromamba@v1.9.0
uses: mamba-org/setup-micromamba@v2.0.1
with:
environment-file: ./environment.yml
environment-name: weldx
cache-environment: true
create-args: >-
python=3.9
python=3.10
mypy
- name: activate env
run: micromamba activate weldx
Expand Down
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ exclude: '.*.weldx$|.*.wx$|.*.asdf$'
repos:
# ----- general formatting -----
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
- id: end-of-file-fixer
- id: check-yaml
exclude: devtools/conda.recipe/meta.yaml # doesn't play nice with jinja
- repo: https://github.com/executablebooks/mdformat
rev: 0.7.17
rev: 0.7.18
hooks:
- id: mdformat
additional_dependencies:
Expand All @@ -29,7 +29,7 @@ repos:
- mdformat-config
# ----- Python formatting -----
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.3
rev: v0.7.2
hooks:
# Run ruff linter.
- id: ruff
Expand All @@ -39,11 +39,11 @@ repos:
# Run ruff formatter.
- id: ruff-format
- repo: https://github.com/tox-dev/pyproject-fmt
rev: 2.2.1
rev: v2.5.0
hooks:
- id: pyproject-fmt
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.19
rev: v0.22
hooks:
- id: validate-pyproject
# ----- Jupyter Notebooks -----
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

## 0.6.9 (unreleased)

### Changes

- added support for homogeneous transformation matrices \[{pull}`949`\]:
- added `create_cs_from_homogeneous_transformation` to `CoordinateSystemManager`
- added `from_homogeneous_transformation` to `LocalCoordinateSystem`
- added `as_homogeneous_matrix` to `LocalCoordinateSystem`

### Fixes

- rename (fix typo) argument to `lcs_child_in_parent` in `CoordinateSystemManager.add_cs` \[{pull}`936`\].
Expand All @@ -12,6 +19,7 @@

- pin `weldx-widgets>=0.2.3` for viz \[{pull}`939`\].
- pin `pint>=0.21` \[{pull}`941`\].
- pin `python<3.13` \[{pull}`896`\].

## 0.6.8 (07.06.2024)

Expand Down
2 changes: 1 addition & 1 deletion doc/json_mime_render_plugin/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ name = "myst-nb-json-renderer"
version = "1"
classifiers = [
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]
entry-points."myst_nb.mime_renderers".json_mime = "myst_nb_json_render_plugin:MimeRenderPlugin"
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ authors = [
{ name = "Volker Hirthammer", email = "[email protected]" },
{ name = "Martin K. Scherer", email = "[email protected]" },
]
requires-python = ">=3.9,<3.12"
requires-python = ">=3.9,<3.13"
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Education",
Expand All @@ -34,6 +34,7 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Scientific/Engineering :: Physics", # TODO: add more topics here!
]
dynamic = [
Expand Down
16 changes: 16 additions & 0 deletions weldx/tests/transformations/test_cs_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2749,6 +2749,10 @@ def test_coordinate_system_manager_create_coordinate_system():
orientations = np.matmul(rot_mat_x, rot_mat_y)
coords = Q_([[1, 0, 0], [-1, 0, 2], [3, 5, 7], [-4, -5, -6]], "mm")

transformation_matrix = np.resize(np.identity(4), (4, 4, 4))
transformation_matrix[:, :3, :3] = orientations
transformation_matrix[:, :3, 3] = coords.m

csm = tf.CoordinateSystemManager("root")
lcs_default = tf.LocalCoordinateSystem()

Expand Down Expand Up @@ -2790,6 +2794,18 @@ def test_coordinate_system_manager_create_coordinate_system():
time=time,
)

# from homogeneous transformation ---------------------
csm.create_cs_from_homogeneous_transformation(
"lcs_homogeneous_default", "root", transformation_matrix, coords.u, time
)
check_coordinate_system(
csm.get_cs("lcs_homogeneous_default"),
orientations,
coords,
True,
time=time,
)


def test_coordinate_system_manager_transform_data():
"""Test the coordinate system managers transform_data function."""
Expand Down
48 changes: 47 additions & 1 deletion weldx/transformations/cs_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
from weldx.exceptions import WeldxDeprecationWarning, WeldxException
from weldx.geometry import SpatialData
from weldx.time import Time, types_time_like, types_timestamp_like
from weldx.types import UnitLike
from weldx.util import check_matplotlib_available, dataclass_nested_eq

from .local_cs import LocalCoordinateSystem
from .types import types_coordinates, types_orientation
from .types import types_coordinates, types_homogeneous, types_orientation

# only import heavy-weight packages on type checking
if TYPE_CHECKING: # pragma: no cover
Expand Down Expand Up @@ -830,6 +831,51 @@ def create_cs_from_axis_vectors(
coordinate_system_name, reference_system_name, lcs, lcs_child_in_parent
)

def create_cs_from_homogeneous_transformation(
self,
coordinate_system_name: str,
reference_system_name: str,
transformation_matrix: types_homogeneous,
translation_unit: UnitLike,
time: types_time_like = None,
time_ref: types_timestamp_like = None,
lcs_child_in_parent: bool = True,
):
"""Create a coordinate system from a homogeneous transformation matrix and add
it to the coordinate system manager.
This function uses the `LocalCoordinateSystem.from_homogeneous_transformation`
method of the `LocalCoordinateSystem` class.
Parameters
----------
coordinate_system_name :
Name of the new coordinate system.
reference_system_name :
Name of the parent system. This must have been already added.
transformation_matrix :
Describes the homogeneous transformation matrix that includes the rotation
and the translation (coordinates).
translation_unit :
Unit describing the value of the translation. Necessary, because the
homogeneous transformation matrix is unitless.
time :
Time data for time dependent coordinate systems.
time_ref :
Reference time for time dependent coordinate systems
lcs_child_in_parent :
If set to `True`, the passed `LocalCoordinateSystem` instance describes
the new system orientation towards is parent. If `False`, it describes
how the parent system is positioned in its new child system.
"""
lcs = LocalCoordinateSystem.from_homogeneous_transformation(
transformation_matrix, translation_unit, time, time_ref
)
self.add_cs(
coordinate_system_name, reference_system_name, lcs, lcs_child_in_parent
)

def delete_cs(self, coordinate_system_name: str, delete_children: bool = False):
"""Delete a coordinate system from the coordinate system manager.
Expand Down
Loading

0 comments on commit f237191

Please sign in to comment.