diff --git a/pytriqs/gf/local/_gf_common.py b/pytriqs/gf/local/_gf_common.py index 3d3e34f3..497af4b1 100644 --- a/pytriqs/gf/local/_gf_common.py +++ b/pytriqs/gf/local/_gf_common.py @@ -125,15 +125,16 @@ def invert(self): #--------------------------------------------------- -def transpose(self): - """Transposes the GF Bloc: return a new transposed view""" - ### WARNING: this depends on the C++ layering .... - return self.__class__( - indices = list(self.indices), - mesh = self.mesh, - data = self.data.transpose( (0, 2, 1) ), - tail = self.tail.transpose(), - name = self.name+'(t)') +# FIXME NEVER USED CLEAN UP +#def transpose(self): +# """Transposes the GF Bloc: return a new transposed view""" +# ### WARNING: this depends on the C++ layering .... +# return self.__class__( +# indices = list(self.indices), +# mesh = self.mesh, +# data = self.data.transpose( (0, 2, 1) ), +# tail = self.tail.transpose(), +# name = self.name+'(t)') #--------------------------------------------------- diff --git a/test/pytriqs/base/CMakeLists.txt b/test/pytriqs/base/CMakeLists.txt index 3d074d33..57b8fc73 100644 --- a/test/pytriqs/base/CMakeLists.txt +++ b/test/pytriqs/base/CMakeLists.txt @@ -21,3 +21,5 @@ add_triqs_test_hdf(pade " -d 1.e-6") # Bug fix #112 add_triqs_test_txt(gf_inplace_112) +# Bug fix #134 +add_triqs_test_txt(gf_transpose) diff --git a/test/pytriqs/base/gf_transpose.output b/test/pytriqs/base/gf_transpose.output new file mode 100644 index 00000000..e1503fb3 --- /dev/null +++ b/test/pytriqs/base/gf_transpose.output @@ -0,0 +1,4 @@ +Old data shape = (1000, 3, 5) +Old tail shape = (10, 3, 5) +New data shape = (1000, 5, 3) +New tail shape = (10, 5, 3) diff --git a/test/pytriqs/base/gf_transpose.py b/test/pytriqs/base/gf_transpose.py new file mode 100644 index 00000000..29bbf8ef --- /dev/null +++ b/test/pytriqs/base/gf_transpose.py @@ -0,0 +1,9 @@ +from pytriqs.gf.local import * + +g = GfImFreq(indicesR = range(5), indicesL = range(3), beta = 40, n_points = 1000) +gt = g.transpose() + +print "Old data shape = ", g.data.shape +print "Old tail shape = ", g.tail.data.shape +print "New data shape = ", gt.data.shape +print "New tail shape = ", gt.tail.data.shape diff --git a/triqs/gfs/tools.hpp b/triqs/gfs/tools.hpp index 0a831c9a..b29f9121 100644 --- a/triqs/gfs/tools.hpp +++ b/triqs/gfs/tools.hpp @@ -162,13 +162,7 @@ namespace gfs { } inline indices_2 transpose(indices_2 const &x) { - auto ind2 = x.ind; - if (x.ind.size() > 0) { - int im = x.ind.size(), jm = x.ind[0].size(); - for (int i = 0; i < im; ++i) - for (int j = 0; j < jm; ++j) ind2[i][j] = x.ind[j][i]; - } - return indices_2(std::move(ind2)); + return std::vector> {x.ind[1],x.ind[0]}; } //------------------------------------------------------