Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def config(value):
- cols, voltage = divmod(value, 1)
- voltage = round(voltage, 3) * 1000
- for discrete_voltage in range(12, 300, 12):
- if discrete_voltage - 1 <= voltage <= discrete_voltage + 1:
- voltage = discrete_voltage
- break
- else:
- voltage = int(voltage)
- return int(cols), voltage
- def test_config():
- values = [2.012, 2.0129, 2.024, 2.0249, 2.0489, 2.0479]
- for val in values:
- print(config(val))
- test_config()
- # (2, 12)
- # (2, 12)
- # (2, 24)
- # (2, 24)
- # (2, 48)
- # (2, 48)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement