Skip to content

Commit

Permalink
handle all old units
Browse files Browse the repository at this point in the history
  • Loading branch information
marscher committed Mar 6, 2024
1 parent 47c7861 commit 18626b0
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions weldx/tags/time/timedeltaindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@

__all__ = ["TimedeltaIndexConverter"]

PANDAS_OLD_UNIT_SUFFIXES = dict(H="h", T="min", S="s", L="ms", U="us", N="ns")


def _handle_converted_pd_tdi_units(node: TaggedDict):
"""Convert changed units in Pandas.Datetimeindex to valid values."""
# TODO: extend this to other changed units, eventually only seconds
# are relevant to weldx right now, as it was used in the previous schema version.
if "S" in node["freq"]:
node["freq"] = node["freq"][:-1] + "s"
# todo: would it be safer to use a regex here to avoid ambiguity with modern units?
unit = node["freq"][-1]
if unit in PANDAS_OLD_UNIT_SUFFIXES.keys():
node["freq"] = node["freq"][:-1] + PANDAS_OLD_UNIT_SUFFIXES[unit]


class TimedeltaIndexConverter(WeldxConverter):
Expand Down

0 comments on commit 18626b0

Please sign in to comment.