Commit a49aa116 authored by Sean Leavey's avatar Sean Leavey

Fix issue with modulator when using const as order

When a constant is used in place of the modulator order, its value gets converted to a float
and then a string, which the modulator in Pykat tries to convert to int. Converting a string
'1.0' to int throws an error. This change parses the string as a float, then checks if it is
an integer, throws an error if not, then converts it to an int. It's hacky but it works.

**It's likely other code suffers from this bug if it copied the same parse code**
parent dc607288
......@@ -1490,8 +1490,13 @@ class modulator(Component):
def order(self, value):
try:
value = int(value)
value = float(value)
if not value.is_integer():
raise pkex.BasePyKatException("modulator order must be an integer between 1 and 6 or 's' for single sideband")
value = int(value)
if value <= 1 and value > 6:
raise pkex.BasePyKatException("modulator order must be between 1 and 6 or 's' for single sideband")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment