TRIQS / triqs

a Toolbox for Research on Interacting Quantum Systems
https://triqs.github.io
GNU General Public License v3.0
135 stars 71 forks source link

Plotting of Legendre GFs stopped working in TRIQS 3.2 #914

Closed krivenko closed 10 months ago

krivenko commented 11 months ago

Here is the error I am getting when trying to run https://github.com/krivenko/som/blob/master/doc/examples/meshes/plot_chi_rec.py.

/home/igor/Physics/SOM/som.git/doc/examples/meshes/example.rst:20: WARNING: Exception occurred in plotting plot_chi_rec
 from /home/igor/Physics/SOM/som.git/doc/examples/meshes/plot_chi_rec.py:
Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/matplotlib/sphinxext/plot_directive.py", line 481, in _run_code
    exec(code, ns)
  File "<string>", line 3, in <module>
  File "/home/igor/Physics/TRIQS/3.2/installed/lib/python3.11/site-packages/triqs/plot/mpl_interface.py", line 44, in oplot
    __oplot_impl(plt, plt.xlabel, plt.ylabel, plt.legend, obj, plt.xticks, plt.title, *opt_list, **opt_dict)
  File "/home/igor/Physics/TRIQS/3.2/installed/lib/python3.11/site-packages/triqs/plot/mpl_interface.py", line 75, in __oplot_impl
    for curve_dict in plot_protocol_apply(obj, opt_dict, plt.xlim):
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/igor/Physics/TRIQS/3.2/installed/lib/python3.11/site-packages/triqs/plot/protocol.py", line 61, in plot_protocol_apply
    return ob._plot_(opt_dict)
           ^^^^^^^^^^^^^^^^^^^
  File "/home/igor/Physics/TRIQS/3.2/installed/lib/python3.11/site-packages/triqs/gf/gf.py", line 752, in _plot_
    return plot.dispatcher(self)(self, opt_dict)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/igor/Physics/TRIQS/3.2/installed/lib/python3.11/site-packages/triqs/gf/plot/one_var.py", line 135, in legendre
    return plot_base.plot_base( self, opt_dict,  r'$l_n$', lambda x : r'%s$(l_n)$'%x, list(self.mesh.values()))
                                                                                           ^^^^^^^^^^^^^^^^
AttributeError: 'triqs.gf.meshes.MeshLegendre' object has no attribute 'values'

Why is the values() method missing from MeshLegendre?

krivenko commented 11 months ago

A probably related issue is that the Function descriptor has stopped working for the Legendre GFs.

from triqs.gf import *
from triqs.gf.descriptors import Function

g_l = GfLegendre(beta=1.0, statistic="Fermion", n_points=5, indices=[0])

def f(v):
    print(v)
    return v

g_l << Function(f)

TRIQS 3.1 output

0
1
2
3
4

TRIQS 3.2 output

None
None
None
None
None
Wentzell commented 10 months ago

@krivenko Thank you for pointing this out. The plotting is now fixed with https://github.com/TRIQS/triqs/commit/e455cfbbe74078d8c8f186c54167ed56cf8ba7aa

A probably related issue is that the Function descriptor has stopped working for the Legendre GFs.

The meshes have been seperated into those where you can sensibly define a MeshPoint value (MeshImTime,MeshImFreq, ...) and those where the definition is not sensible (MeshLegendre, MeshDLR). The Legendre index can be directly obtained via MeshPoint.index.

This unfortunately means that the Function descriptor is no longer compatible with MeshLegendre.

krivenko commented 10 months ago

@Wentzell Thank you for the fix, I can confirm that oplot() works again. Losing the Function descriptor is not a major issue but is a bit unfortunate indeed.