simplified

This commit is contained in:
Martin Diehl 2016-06-29 11:02:49 +02:00
parent 9ea6d3afd7
commit a64388355a
1 changed files with 15 additions and 17 deletions

View File

@ -74,7 +74,7 @@ for name in filenames:
}
# ------------------------------------------ Evaluate condition ---------------------------------------
if options.condition:
if options.condition is not None:
interpolator = []
condition = options.condition # copy per file, since might be altered inline
breaker = False
@ -89,7 +89,7 @@ for name in filenames:
try:
interpolator += ['%s(table.data[%i])'%({ '':'float',
's#':'str'}[operand[1]],
table.label_index(operand[2]))] # ccould be generalized to indexrange as array lookup
table.label_index(operand[2]))] # could be generalized to indexrange as array lookup
except:
damask.util.croak('column "{}" not found.'.format(operand[2]))
breaker = True
@ -98,8 +98,6 @@ for name in filenames:
evaluator_condition = "'" + condition + "'.format(" + ','.join(interpolator) + ")"
else: condition = ''
# ------------------------------------------ build formulae ----------------------------------------
evaluator = {}
@ -168,7 +166,7 @@ for name in filenames:
Nold = max(1,len(oldIndices)) # Nold could be zero for new columns
Nnew = len(output.label_indexrange(label))
output.data_append(eval(evaluator[label]) if label in options.labels and
(condition == '' or eval(eval(evaluator_condition)))
(options.condition is None or eval(eval(evaluator_condition)))
else np.tile([table.data[i] for i in oldIndices]
if label in tabLabels
else np.nan,