aiida-core
aiida-core copied to clipboard
show_mpl Bands plot failure
When plotting BandsData, the distance computation does not take into account when all the high symmetry points have a label in self.labels, https://github.com/aiidateam/aiida-core/blob/bab1ad6cfc8e4ff041bce268f9270c613663cb35/aiida/orm/nodes/data/array/bands.py#L477-L481 which leads to a situation where, if you label all the high symmetry points, then all the distances are set to zero, and the x coordinates now are all set to zero https://github.com/aiidateam/aiida-core/blob/bab1ad6cfc8e4ff041bce268f9270c613663cb35/aiida/orm/nodes/data/array/bands.py#L482 Here is some info:
In [34]: bs.get_kpoints()
Out[34]:
array([[0. , 0. , 0. ],
[0. , 0.5, 0. ],
[0.5, 0.5, 0. ],
[0. , 0. , 0. ],
[0.5, 0.5, 0.5],
[0. , 0.5, 0. ],
[0.5, 0.5, 0.5],
[0.5, 0.5, 0. ]])
In [35]: bs.labels= [(0, 'GAMMA'), (1,'X'), (2,'M'),(3,'GAMMA'),(4,'R'),(5,'X'),(6,'R'),(7,'M')]
In [36]: bs._get_bandplot_data(cartesian=True, prettify_format=None, join_symbol=None, get_segments=False)
Out[36]:
{'x': [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], ## ******************ALL THIS*************************
'y': array([[-31.70204001, -31.64247329, -31.64247308, ..., 57.5809345 ,
58.10566081, 59.20231692],
[-31.68186564, -31.66189384, -31.64213932, ..., 58.28154109,
58.62465083, 58.62469309],
[-31.66192103, -31.66170643, -31.66170595, ..., 56.1907462 ,
56.68984233, 56.72449097],
...,
and when there is no labels:
In [37]: bs.labels= []
In [38]: bs._get_bandplot_data(cartesian=True, prettify_format=None, join_symbol=None, get_segments=False)
Out[38]:
{'x': [0.0, # *******************ALL THIS************************
0.5000000021868258,
1.0000000043736517,
1.707106788652838,
2.57313219622497,
3.280238980504156,
3.987345764783342,
4.487345766970168],
'y': array([[-31.70204001, -31.64247329, -31.64247308, ..., 57.5809345 ,
58.10566081, 59.20231692],
[-31.68186564, -31.66189384, -31.64213932, ..., 58.28154109,
58.62465083, 58.62469309],
[-31.66192103, -31.66170643, -31.66170595, ..., 56.1907462 ,
56.68984233, 56.72449097],
...,
This of course means that the plotting fails.