Skip to content

Commit 92fba25

Browse files
committed
Fix floating point number format for Set command representation
1 parent 483b5bd commit 92fba25

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

scan/commands/set.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,13 @@ def __repr__(self):
119119
result = "Set('%s'" % self.__device
120120
if isinstance(self.__value, str):
121121
result += ", '%s'" % self.__value
122+
elif isinstance(self.__value, float):
123+
# Reproduce the default floating point number format provided by Python 2 (and 3.1)
124+
# (See: https://stackoverflow.com/questions/25898733/why-does-strfloat-return-more-digits-in-python-3-than-python-2/25899600#25899600)
125+
if self.__value.is_integer():
126+
result += ", %.12g.0" % self.__value
127+
else:
128+
result += ", %.12g" % self.__value
122129
else:
123130
result += ", %s" % str(self.__value)
124131
if self.__completion:

0 commit comments

Comments
 (0)