fixed bug for only blacklisting.
This commit is contained in:
parent
9d5ca8b631
commit
54746c85d3
|
@ -60,17 +60,16 @@ for name in filenames:
|
||||||
labels.append(label) # remember name...
|
labels.append(label) # remember name...
|
||||||
positions.append(position) # ...and position
|
positions.append(position) # ...and position
|
||||||
|
|
||||||
order = []
|
if options.whitelist != None and options.blacklist == None: # check whether reordering is possible
|
||||||
for label in labels: # check each selected label
|
position = np.zeros(len(labels))
|
||||||
match = [fnmatch.fnmatch(label,needle) for needle in options.whitelist] # which whitelist items do match it
|
for i,label in enumerate(labels): # check each selected label
|
||||||
order.append(match.index(True) if np.sum(match) == 1 else -1) # unique match --> store which
|
match = [fnmatch.fnmatch(label,needle) for needle in options.whitelist] # which whitelist items do match it
|
||||||
|
position[i] = match.index(True) if np.sum(match) == 1 else -1 # unique match --> store which
|
||||||
|
|
||||||
if options.blacklist != None or np.any(order < 0): # have blacklist or non-unique matching?
|
sorted = np.argsort(position)
|
||||||
order = range(len(order)) # skip reordering
|
order = range(len(labels)) if sorted[0] < 0 else sorted # skip reordering if non-unique, i.e. first sorted is "-1"
|
||||||
|
else:
|
||||||
reorder = np.zeros(len(order),dtype=int)
|
order = range(len(labels)) # maintain original order of labels
|
||||||
for i in xrange(len(order)):
|
|
||||||
reorder[order[i]] = i
|
|
||||||
|
|
||||||
interpolator = []
|
interpolator = []
|
||||||
condition = options.condition # copy per file, might be altered
|
condition = options.condition # copy per file, might be altered
|
||||||
|
@ -91,11 +90,11 @@ for name in filenames:
|
||||||
evaluator = "'" + condition + "'.format(" + ','.join(interpolator) + ")"
|
evaluator = "'" + condition + "'.format(" + ','.join(interpolator) + ")"
|
||||||
|
|
||||||
# ------------------------------------------ assemble header ---------------------------------------
|
# ------------------------------------------ assemble header ---------------------------------------
|
||||||
table.labels = np.array(labels)[reorder] # update with new label set
|
table.labels = np.array(labels)[order] # update with new label set
|
||||||
table.head_write()
|
table.head_write()
|
||||||
|
|
||||||
# ------------------------------------------ process data ------------------------------------------
|
# ------------------------------------------ process data ------------------------------------------
|
||||||
positions = np.array(positions)[reorder]
|
positions = np.array(positions)[order]
|
||||||
outputAlive = True
|
outputAlive = True
|
||||||
while outputAlive and table.data_read(): # read next data line of ASCII table
|
while outputAlive and table.data_read(): # read next data line of ASCII table
|
||||||
specials['_row_'] += 1 # count row
|
specials['_row_'] += 1 # count row
|
||||||
|
|
Loading…
Reference in New Issue