Skip to content

Commit 483b5bd

Browse files
committed
Use OrderedDict instead of set to ensure ordered result on Python3
1 parent 2e858c3 commit 483b5bd

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

scan/ndim.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
"""
44
# @author Kay Kasemir
5-
5+
from collections import OrderedDict
66
from scan.util import SettingsBasedLoop
77
from scan.commands.command import Command
88
from scan.commands.log import Log
@@ -47,7 +47,7 @@ def createNDimScan(*parameters):
4747
args = list(parameters)
4848

4949
# Assemble the commands
50-
return __decodeScan(set(), args)
50+
return __decodeScan(OrderedDict(), args)
5151

5252
def __decodeLoop(parms):
5353
"""Decode loop parameters
@@ -74,19 +74,19 @@ def __decodeScan(to_log, args):
7474
# Log what needs to be logged. May be nothing.
7575
if len(to_log) <= 0:
7676
return []
77-
return [ Log(list(to_log)) ]
77+
return [ Log(list(to_log.keys())) ]
7878

7979
# Analyze next argument
8080
arg = args.pop(0)
8181
if isinstance(arg, str):
8282
# Remember device to log
83-
to_log.add(arg)
83+
to_log.update({ arg: None })
8484
return __decodeScan(to_log, args)
8585
elif isinstance(arg, tuple):
8686
# Loop specification
8787
scan = __decodeLoop(arg)
8888
# Remember loop variable for log
89-
to_log.add(scan[0])
89+
to_log.update({ scan[0]: None })
9090
# Create loop with remaining arguments as body
9191
return [ SettingsBasedLoop(scan[0], scan[1], scan[2], scan[3],
9292
__decodeScan(to_log, args))

0 commit comments

Comments
 (0)