Repository: BAMWelDX/weldx

Issue:
create static LCS instance with time axis
The following code creates a static `LCS` instance even though a time axis with length 2 is set. The time dependency is simply dropped.
```python
import pandas as pd
import weldx

lcs = weldx.LocalCoordinateSystem(
    coordinates=[0, 0, 1], time=pd.timedelta_range(start="0s", end="20s", periods=2)
)
lcs

>>> <LocalCoordinateSystem>
>>> Dimensions:      (c: 3, v: 3)
>>> Coordinates:
>>>   * c            (c) <U1 'x' 'y' 'z'
>>>   * v            (v) int32 0 1 2
>>> Data variables:
>>>     coordinates  (c) float64 0.0 0.0 1.0
>>>     orientation  (v, c) float64 1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0
```

I am not sure if this should be allowed or raise a warning/an exception.
What do you think @vhirtham ?

The case is also not mentioned in the documentation.

Discussion:
codecov[bot]: # [Codecov](https://codecov.io/gh/BAMWelDX/weldx/pull/285?src=pr&el=h1) Report
> Merging [#285](https://codecov.io/gh/BAMWelDX/weldx/pull/285?src=pr&el=desc) (6af7c33) into [master](https://codecov.io/gh/BAMWelDX/weldx/commit/98a2bbf6ab6c26079cc823e3f744a2435d64c692?el=desc) (98a2bbf) will **decrease** coverage by `0.02%`.
> The diff coverage is `66.66%`.

[![Impacted file tree graph](https://codecov.io/gh/BAMWelDX/weldx/pull/285/graphs/tree.svg?width=650&height=150&src=pr&token=wdof1qQTsn)](https://codecov.io/gh/BAMWelDX/weldx/pull/285?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master     #285      +/-   ##
==========================================
- Coverage   99.56%   99.54%   -0.03%     
==========================================
  Files          76       76              
  Lines        4149     4152       +3     
==========================================
+ Hits         4131     4133       +2     
- Misses         18       19       +1     
```


| [Impacted Files](https://codecov.io/gh/BAMWelDX/weldx/pull/285?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [weldx/transformations/local\_cs.py](https://codecov.io/gh/BAMWelDX/weldx/pull/285/diff?src=pr&el=tree#diff-d2VsZHgvdHJhbnNmb3JtYXRpb25zL2xvY2FsX2NzLnB5) | `98.90% <66.66%> (-0.55%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/BAMWelDX/weldx/pull/285?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/BAMWelDX/weldx/pull/285?src=pr&el=footer). Last update [98a2bbf...6af7c33](https://codecov.io/gh/BAMWelDX/weldx/pull/285?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

vhirtham: > LGTM thanks !
> I think we can just leave the warning untested for now.

Just copied an existing one and modded it. Works fine 

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 09621aa..47ac45a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,12 @@
   fix [#282](https://github.com/BAMWelDX/weldx/pull/282) [[#286]](https://github.com/BAMWelDX/weldx/pull/286)
 - add examples to schema files [[#274]](https://github.com/BAMWelDX/weldx/pull/274)
 
+### fixes
+
+- A warning is now emitted if a `LocalCoordinateSystem` drops a provided time during construction. This usually happens 
+  if the coordinates and orientation only contain a single data point. 
+  [[#285]](https://github.com/BAMWelDX/weldx/pull/285)
+
 ## 0.3.0 (12.03.2021)
 
 ### added
diff --git a/weldx/transformations/local_cs.py b/weldx/transformations/local_cs.py
index cc17b0f..1b9a867 100644
--- a/weldx/transformations/local_cs.py
+++ b/weldx/transformations/local_cs.py
@@ -2,6 +2,7 @@
 
 from __future__ import annotations
 
+import warnings
 from copy import deepcopy
 from typing import TYPE_CHECKING, List, Union
 
@@ -52,7 +53,10 @@ class LocalCoordinateSystem:
         coordinates :
             Coordinates of the origin
         time :
-            Time data for time dependent coordinate systems
+            Time data for time dependent coordinate systems. If the provided coordinates
+            and orientations contain only a single value, the coordinate system is
+            considered to be static and the provided value won't be stored. If this
+            happens, a warning will be emitted.
         time_ref :
             Reference Timestamp to use if time is Timedelta or pint.Quantity.
         construction_checks :
@@ -73,6 +77,14 @@ class LocalCoordinateSystem:
         orientation = self._build_orientation(orientation, time)
         coordinates = self._build_coordinates(coordinates, time)
 
+        if time is not None and not (
+            "time" in coordinates.coords or "time" in orientation.coords
+        ):
+            warnings.warn(
+                "Neither the coordinates nor the orientation are time dependent. "
+                "Provided time is dropped"
+            )
+
         if construction_checks:
             ut.xr_check_coords(
                 coordinates,


Test patch:
diff --git a/tests/test_transformations.py b/tests/test_transformations.py
index 7d65781..a7208f9 100644
--- a/tests/test_transformations.py
+++ b/tests/test_transformations.py
@@ -601,6 +601,35 @@ class TestLocalCoordinateSystem:
         assert np.all(lcs.datetimeindex == datetime_exp)
         assert np.all(lcs.time_quantity == quantity_exp)
 
+    # test_time_warning ----------------------------------------------------------------
+
+    @staticmethod
+    @pytest.mark.parametrize(
+        "coordinates, orientation, time, warning",
+        [
+            (np.zeros(3), np.eye(3, 3), TDI([0, 2], "s"), UserWarning),
+            (np.zeros((2, 3)), np.eye(3, 3), TDI([0, 2], "s"), None),
+            (np.zeros(3), np.eye(3, 3), None, None),
+        ],
+    )
+    def test_time_warning(coordinates, orientation, time, warning):
+        """Test that warning is emitted when time is provided to a static CS.
+
+        Parameters
+        ----------
+        coordinates :
+            Coordinates of the CS
+        orientation :
+            Orientation of the CS
+        time :
+            Provided time
+        warning :
+            Expected warning
+
+        """
+        with pytest.warns(warning):
+            LCS(coordinates=coordinates, orientation=orientation, time=time)
+
     # test_init_time_dsx ---------------------------------------------------------------
 
     @staticmethod