From 9fd9208397cd9b48126d6b514a420fb051e49fd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=87a=C4=9Ftay=20Fabry?= Date: Thu, 4 Jul 2024 14:51:46 +0200 Subject: [PATCH] Renamed "lsc_child_in_parent" to "lcs_child_in_parent" (#936) * Renamed "lsc_child_in_parent" to "lcs_child_in_parent" * update CSM notebook * add deprecation warning * update changelog * pin numpy<2 * pin numpy<2 for rtd * lint --------- Co-authored-by: Michael Winkler --- CHANGELOG.md | 6 +++ doc/rtd_environment.yml | 2 +- ...mations_02_coordinate_system_manager.ipynb | 8 ++-- pyproject.toml | 2 +- weldx/tests/asdf_tests/test_asdf_core.py | 2 +- .../tests/transformations/test_cs_manager.py | 4 +- weldx/transformations/cs_manager.py | 41 +++++++++++++------ 7 files changed, 43 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 34885d40a..3fa3b5472 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Release Notes +## 0.6.9 (unreleased) + +### Fixes + +- rename (fix typo) argument to `lcs_child_in_parent` in `CoordinateSystemManager.add_cs` \[{pull}`936`\]. + ## 0.6.8 (07.06.2024) ### Changes diff --git a/doc/rtd_environment.yml b/doc/rtd_environment.yml index 295cc22de..9c6638dc8 100644 --- a/doc/rtd_environment.yml +++ b/doc/rtd_environment.yml @@ -5,7 +5,7 @@ dependencies: - python=3.10 - setuptools_scm # weldx base dependencies - - numpy>=1.18 + - numpy>=1.18,<2 - pandas>=1.0 - xarray>=0.15 - pint>=0.11 diff --git a/doc/src/tutorials/transformations_02_coordinate_system_manager.ipynb b/doc/src/tutorials/transformations_02_coordinate_system_manager.ipynb index 78d3ee4c5..8030a7943 100644 --- a/doc/src/tutorials/transformations_02_coordinate_system_manager.ipynb +++ b/doc/src/tutorials/transformations_02_coordinate_system_manager.ipynb @@ -70,7 +70,7 @@ " The position and orientation of the new coordinate system that will be passed in form of a `LocalCoordinateSystem` refer to this reference system\n", "3. A `LocalCoordinateSystem` that describes the position and orientation of the new coordinate system in its reference system.\n", "\n", - "In case you only have the inverse data, meaning the position and orientation of the reference system inside the new coordinate system, you can set the fourth parameter (`lsc_child_in_parent`) to `False` and use the corresponding data instead." + "In case you only have the inverse data, meaning the position and orientation of the reference system inside the new coordinate system, you can set the fourth parameter (`lcs_child_in_parent`) to `False` and use the corresponding data instead." ] }, { @@ -88,7 +88,7 @@ "\n", "csm.add_cs(\"specimen\", \"root\", lcs_specimen_in_root)\n", "csm.add_cs(\n", - " \"thermocouple\", \"specimen\", lcs_specimen_in_thermocouple, lsc_child_in_parent=False\n", + " \"thermocouple\", \"specimen\", lcs_specimen_in_thermocouple, lcs_child_in_parent=False\n", ")" ] }, @@ -102,7 +102,7 @@ "Similarly, there are functions for each of the `LocalCoordinateSystem`s construction methods (`from_euler`, `from_xyz`, etc.). \n", "The naming is simply `create_cs_` plus the name of the corresponding function of the `LoocalCoordinateSystem`. \n", "For example `construct_cs_from_euler` ([link tofunction documentation](https://weldx.readthedocs.io/en/latest/_autosummary/weldx.CoordinateSystemManager.create_cs_from_euler.html#weldx.CoordinateSystemManager.create_cs_from_euler)). \n", - "As with `add_cs`, the last parameter of all those methods is `lsc_child_in_parent` which can be set to `False` if the provided values represent the orientation and coordinates of the reference system in the new child system." + "As with `add_cs`, the last parameter of all those methods is `lcs_child_in_parent` which can be set to `False` if the provided values represent the orientation and coordinates of the reference system in the new child system." ] }, { @@ -218,7 +218,7 @@ "metadata": {}, "source": [ "However, note that the returned coordinate system is not necessarily identical to the one that we used during the definition.\n", - "If we were setting the `lsc_child_in_parent` during the addition of the coordinate system to `False`, we provided the inverse transformation:" + "If we were setting the `lcs_child_in_parent` during the addition of the coordinate system to `False`, we provided the inverse transformation:" ] }, { diff --git a/pyproject.toml b/pyproject.toml index 446fd1bf1..87e0ceea4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,7 +49,7 @@ dependencies = [ "ipython", "meshio", "networkx>=2.8.2", - "numpy>=1.20", + "numpy>=1.20,<2", "pandas>=1.5", "pint>=0.18", "pint-xarray>=0.3", diff --git a/weldx/tests/asdf_tests/test_asdf_core.py b/weldx/tests/asdf_tests/test_asdf_core.py index bf02d11d3..b2a07fd63 100644 --- a/weldx/tests/asdf_tests/test_asdf_core.py +++ b/weldx/tests/asdf_tests/test_asdf_core.py @@ -366,7 +366,7 @@ def get_coordinate_system_manager_with_subsystems(nested: bool): # robot head system csm_head = tf.CoordinateSystemManager("head", "Head system") csm_head.add_cs("torch tcp", "head", lcs[3]) - csm_head.add_cs("camera tcp", "head", lcs[4], lsc_child_in_parent=False) + csm_head.add_cs("camera tcp", "head", lcs[4], lcs_child_in_parent=False) csm_head.add_cs("scanner 1 tcp", "head", lcs[5]) csm_head.add_cs("scanner 2 tcp", "head", lcs[6]) diff --git a/weldx/tests/transformations/test_cs_manager.py b/weldx/tests/transformations/test_cs_manager.py index 90250e493..768e16ada 100644 --- a/weldx/tests/transformations/test_cs_manager.py +++ b/weldx/tests/transformations/test_cs_manager.py @@ -56,7 +56,7 @@ def list_of_csm_and_lcs_instances(): csm_1.add_cs("lcs4", "lcs0", lcs[4]) csm_2 = CSM("lcs5", "csm2") - csm_2.add_cs("lcs3", "lcs5", lcs[5], lsc_child_in_parent=False) + csm_2.add_cs("lcs3", "lcs5", lcs[5], lcs_child_in_parent=False) csm_2.add_cs("lcs6", "lcs5", lcs[6]) csm_3 = CSM("lcs6", "csm3") @@ -64,7 +64,7 @@ def list_of_csm_and_lcs_instances(): csm_3.add_cs("lcs8", "lcs6", lcs[8]) csm_4 = CSM("lcs9", "csm4") - csm_4.add_cs("lcs3", "lcs9", lcs[9], lsc_child_in_parent=False) + csm_4.add_cs("lcs3", "lcs9", lcs[9], lcs_child_in_parent=False) csm_5 = CSM("lcs7", "csm5") csm_5.add_cs("lcs10", "lcs7", lcs[10]) diff --git a/weldx/transformations/cs_manager.py b/weldx/transformations/cs_manager.py index c118b5790..1cb4ff002 100644 --- a/weldx/transformations/cs_manager.py +++ b/weldx/transformations/cs_manager.py @@ -14,7 +14,7 @@ from weldx import util from weldx.core import TimeSeries -from weldx.exceptions import WeldxException +from weldx.exceptions import WeldxDeprecationWarning, WeldxException from weldx.geometry import SpatialData from weldx.time import Time, types_time_like, types_timestamp_like from weldx.util import check_matplotlib_available, dataclass_nested_eq @@ -440,6 +440,7 @@ def add_cs( coordinate_system_name: str, reference_system_name: str, lcs: LocalCoordinateSystem, + lcs_child_in_parent: bool = True, lsc_child_in_parent: bool = True, ): """Add a coordinate system to the coordinate system manager. @@ -469,12 +470,26 @@ def add_cs( An instance of `LocalCoordinateSystem` that describes how the new coordinate system is oriented in its parent system. - lsc_child_in_parent + 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. + lsc_child_in_parent + DEPRECATED. Use ``lcs_child_in_parent`` instead. """ + if not lsc_child_in_parent: + warnings.warn( + ( + "Argument 'lsc_child_in_parent' is deprecated" + " and will be removed in 0.7 please use 'lcs_child_in_parent'" + ), + category=WeldxDeprecationWarning, + stacklevel=2, + ) + if lcs_child_in_parent: + lcs_child_in_parent = lsc_child_in_parent + if not isinstance(lcs, LocalCoordinateSystem): raise TypeError( "'local_coordinate_system' must be an instance of LocalCoordinateSystem" @@ -508,7 +523,7 @@ def add_cs( f'Can not update coordinate system. "{reference_system_name}" is ' f"not a neighbor of {coordinate_system_name}" ) - if lsc_child_in_parent: + if lcs_child_in_parent: self._update_local_coordinate_system( coordinate_system_name, reference_system_name, @@ -523,7 +538,7 @@ def add_cs( else: self._check_coordinate_system_exists(reference_system_name) self._add_coordinate_system_node(coordinate_system_name) - if lsc_child_in_parent: + if lcs_child_in_parent: self._add_edges( coordinate_system_name, reference_system_name, @@ -648,7 +663,7 @@ def create_cs( coordinates: types_coordinates = None, time: types_time_like = None, time_ref: types_timestamp_like = None, - lsc_child_in_parent: bool = True, + lcs_child_in_parent: bool = True, ): """Create a coordinate system and add it to the coordinate system manager. @@ -674,7 +689,7 @@ def create_cs( Time data for time dependent coordinate systems. time_ref : Reference time for time dependent coordinate systems - lsc_child_in_parent : + 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. @@ -682,7 +697,7 @@ def create_cs( """ lcs = LocalCoordinateSystem(orientation, coordinates, time, time_ref) self.add_cs( - coordinate_system_name, reference_system_name, lcs, lsc_child_in_parent + coordinate_system_name, reference_system_name, lcs, lcs_child_in_parent ) def create_cs_from_euler( @@ -695,7 +710,7 @@ def create_cs_from_euler( coordinates: types_coordinates = None, time: types_time_like = None, time_ref: types_timestamp_like = None, - lsc_child_in_parent: bool = True, + lcs_child_in_parent: bool = True, ): """Create a coordinate system and add it to the coordinate system manager. @@ -735,7 +750,7 @@ def create_cs_from_euler( Time data for time dependent coordinate systems. time_ref : Reference time for time dependent coordinate systems - lsc_child_in_parent : + 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. @@ -746,7 +761,7 @@ def create_cs_from_euler( sequence, angles, degrees, coordinates, time, time_ref ) self.add_cs( - coordinate_system_name, reference_system_name, lcs, lsc_child_in_parent + coordinate_system_name, reference_system_name, lcs, lcs_child_in_parent ) def create_cs_from_axis_vectors( @@ -759,7 +774,7 @@ def create_cs_from_axis_vectors( coordinates: types_coordinates = None, time: types_time_like = None, time_ref: types_timestamp_like = None, - lsc_child_in_parent: bool = True, + lcs_child_in_parent: bool = True, ): """Create a coordinate system and add it to the `CoordinateSystemManager`. @@ -784,7 +799,7 @@ def create_cs_from_axis_vectors( Time data for time dependent coordinate systems (Default value = None) time_ref : Optional reference timestamp if ``time`` is a time delta. - lsc_child_in_parent : + 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. @@ -812,7 +827,7 @@ def create_cs_from_axis_vectors( x, y, z, coordinates, time, time_ref ) self.add_cs( - coordinate_system_name, reference_system_name, lcs, lsc_child_in_parent + coordinate_system_name, reference_system_name, lcs, lcs_child_in_parent ) def delete_cs(self, coordinate_system_name: str, delete_children: bool = False):