Skip to content

Fix extra labels slicing when cuts are given

Emanuele Roberto Nocera requested to merge cutsinfoextralabels into master

Created by: Zaharid

plot_smpdf can break with some mismatch error like

  File "/home/zah/nngit/nnpdf/validphys2/src/validphys/dataplots.py", line 869, in plot_smpdf
    table = kitable(dataset, info)
  File "/home/zah/nngit/nnpdf/validphys2/src/validphys/plotoptions/core.py", line 328, in kitable
    table[label] = value
  File "/home/zah/anaconda3/envs/nnpdfdev/lib/python3.9/site-packages/pandas/core/frame.py", line 3978, in __setitem__
    self._set_item(key, value)
  File "/home/zah/anaconda3/envs/nnpdfdev/lib/python3.9/site-packages/pandas/core/frame.py", line 4172, in _set_item
    value = self._sanitize_column(value)
  File "/home/zah/anaconda3/envs/nnpdfdev/lib/python3.9/site-packages/pandas/core/frame.py", line 4912, in _sanitize_column
    com.require_length_match(value, self.index)
  File "/home/zah/anaconda3/envs/nnpdfdev/lib/python3.9/site-packages/pandas/core/common.py", line 561, in require_length_match
    raise ValueError(
ValueError: Length of values (34) does not match length of index (30)

----

This is caused by cuts not being used anywhere when calling PlotInfo.from_commondata, specifically not to being used to filter the extra_labels.

I am a bit unsure why this was noticed before, but part of the answer is that plot_fancy use the plotting information without cuts and applies them later itself.

Fix that by filtering the extra labels.

Merge request reports

Loading