Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a998c1d

Browse files
committed
BUG: shape determined from pulse programs with string variables
1 parent cad2293 commit a998c1d

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

nmrglue/fileio/bruker.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,12 +541,12 @@ def guess_shape(dic):
541541
# if there in no pulse program parameters in dictionary return currect
542542
# shape after removing zeros
543543
if "pprog" not in dic or "loop" not in dic["pprog"]:
544-
return tuple([int(i) for i in shape if i >= 1]), cplex
544+
return tuple([int(i) for i in shape if i > 1]), cplex
545545

546546
# if pulseprogram dictionary is missing loop or incr return current shape
547547
pprog = dic["pprog"]
548548
if "loop" not in pprog or "incr" not in pprog:
549-
return tuple([int(i) for i in shape if i >= 1]), cplex
549+
return tuple([int(i) for i in shape if i > 1]), cplex
550550

551551
# determine indirect dimension sizes from pulseprogram parameters
552552
loop = pprog["loop"]
@@ -559,6 +559,13 @@ def guess_shape(dic):
559559
if v in rep.keys():
560560
loop[i] = rep[v]
561561

562+
# if the loop variables contains strings, return current shape
563+
# these variables could be resolved from the var key in the pprog dict
564+
# but this would require executing unknown code to perform the
565+
# arithmetic present in the string.
566+
if str in [type(e) for e in loop]:
567+
return tuple([int(i) for i in shape if i > 1]), cplex
568+
562569
# size of indirect dimensions based on number of loops in pulse program
563570
# there are two kinds of loops, active and passive.
564571
# active loops are from indirect dimension increments, the corresponding

0 commit comments

Comments
 (0)