Skip to content

Commit

Permalink
more generic way to handle identical conversions written as rational …
Browse files Browse the repository at this point in the history
…conversions
  • Loading branch information
danielhrisca committed Oct 18, 2023
1 parent efdbc8e commit 6f53bbf
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 32 deletions.
17 changes: 7 additions & 10 deletions src/asammdf/blocks/v2_v3_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1565,16 +1565,13 @@ def convert(self, values, as_object=False, as_bytes=False, ignore_value2text_con
P6 = self.P6

X = values
if (P1, P4, P5, P6) == (0, 0, 0, 1):
if (P2, P3) != (1, 0):
values = values * P2
if P3:
values += P3
elif (P3, P4, P5, P6) == (0, 0, 1, 0):
if (P1, P2) != (1, 0):
values = values * P1
if P2:
values += P2
if (P1, P3, P4, P5) == (0, 0, 0, 0):
if P2 != P6:
values = values * (P2 / P6)

elif (P2, P3, P4, P6) == (0, 0, 0, 0):
if P1 != P5:
values = values * (P1 / P5)
else:
try:
values = evaluate(v23c.RAT_CONV_TEXT)
Expand Down
35 changes: 14 additions & 21 deletions src/asammdf/blocks/v4_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3154,17 +3154,13 @@ def convert(self, values, as_object=False, as_bytes=False, ignore_value2text_con
if names:
name = names[0]
vals = values[name]
if (P1, P4, P5, P6) == (0, 0, 0, 1):
if (P2, P3) != (1, 0):
vals = values[name] * P2
if P3:
vals = vals + P3

elif (P3, P4, P5, P6) == (0, 0, 1, 0):
if (P1, P2) != (1, 0):
vals = values[name] * P1
if P2:
vals = vals + P2
if (P1, P3, P4, P5) == (0, 0, 0, 0):
if P2 != P6:
vals = vals * (P2 / P6)

elif (P2, P3, P4, P6) == (0, 0, 0, 0):
if P1 != P5:
vals = vals * (P1 / P5)

else:
X = vals
Expand All @@ -3181,16 +3177,13 @@ def convert(self, values, as_object=False, as_bytes=False, ignore_value2text_con

else:
X = values
if (P1, P4, P5, P6) == (0, 0, 0, 1):
if (P2, P3) != (1, 0):
values = values * P2
if P3:
values = values + P3
elif (P3, P4, P5, P6) == (0, 0, 1, 0):
if (P1, P2) != (1, 0):
values = values * P1
if P2:
values += P2
if (P1, P3, P4, P5) == (0, 0, 0, 0):
if P2 != P6:
values = values * (P2 / P6)

elif (P2, P3, P4, P6) == (0, 0, 0, 0):
if P1 != P5:
values = values * (P1 / P5)
else:
try:
values = evaluate(v4c.CONV_RAT_TEXT)
Expand Down
2 changes: 1 addition & 1 deletion src/asammdf/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
""" asammdf version module """

__version__ = "7.3.15.dev17"
__version__ = "7.3.15.dev18"

0 comments on commit 6f53bbf

Please sign in to comment.