From 4c1281b4fc417e3042c501e2e0c36a25ec1fe742 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 10 Dec 2019 20:04:03 +0100 Subject: [PATCH] rename changed order in shapes dict. This resulted in wrong column names when writing to ASCII file two fixes (one would be enough): 1) keep order (build new directory) 2) write in order of labels in pandas dataframe, not in order in shapes dict --- python/damask/table.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/python/damask/table.py b/python/damask/table.py index 6181fdb1f..56af8b622 100644 --- a/python/damask/table.py +++ b/python/damask/table.py @@ -203,7 +203,7 @@ class Table(): '' if info is None else ': {}'.format(info), )) - self.shapes[label_new] = self.shapes.pop(label_old) + self.shapes = {(label if label is not label_old else label_new):self.shapes[label] for label in self.shapes} def sort_by(self,labels,ascending=True): @@ -234,8 +234,9 @@ class Table(): Filename or file for reading. """ + seen = set() labels = [] - for l in self.shapes: + for l in [x for x in self.data.columns if not (x in seen or seen.add(x))]: if(self.shapes[l] == (1,)): labels.append('{}'.format(l)) elif(len(self.shapes[l]) == 1):