Skip to content

Commit

Permalink
scripts: plot.py/plotmpl.py: Stop dropping unlabeled datasets
Browse files Browse the repository at this point in the history
That was confusing.

The -L/--label flag is already tricky enough to get right. Allowing
-L/--label to filter datasets is counter-intuitive and just makes it
harder to debug things.
  • Loading branch information
geky committed Feb 7, 2025
1 parent 79c7cc9 commit 53af8b7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
12 changes: 9 additions & 3 deletions scripts/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,12 +543,16 @@ def fold(results, by=None, x=None, y=None, defines=[], labels=None):
key_ += (y_,)
datasets[key_] = dataset

# filter/order by labels
# order by labels
if labels:
datasets_ = co.OrderedDict()
for _, key in labels:
if key in datasets:
datasets_[key] = datasets[key]
# include unlabeled data to help with debugging
for key, dataset in datasets.items():
if key not in datasets_:
datasets_[key] = datasets[key]
datasets = datasets_

return datasets
Expand Down Expand Up @@ -1030,7 +1034,9 @@ def writeln(s=''):
if all_labels:
all_labels_ = {key: l for l, key in all_labels}
for i, name in enumerate(datasets_.keys()):
if all_labels and not all_labels_[name]:
if (all_labels
and name in all_labels_
and not all_labels_[name]):
continue
label = '%s%s' % (
'%s ' % datachars_[name]
Expand All @@ -1039,7 +1045,7 @@ def writeln(s=''):
if line_chars is not None
else '',
all_labels_[name]
if all_labels
if all_labels and name in all_labels_
else ','.join(name))

if label:
Expand Down
8 changes: 6 additions & 2 deletions scripts/plotmpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,16 @@ def fold(results, by=None, x=None, y=None, defines=[], labels=None):
key_ += (y_,)
datasets[key_] = dataset

# filter/order by labels
# order by labels
if labels:
datasets_ = co.OrderedDict()
for _, key in labels:
if key in datasets:
datasets_[key] = datasets[key]
# include unlabeled data to help with debugging
for key, dataset in datasets.items():
if key not in datasets_:
datasets_[key] = datasets[key]
datasets = datasets_

return datasets
Expand Down Expand Up @@ -947,7 +951,7 @@ def subplots_get(k, *, subplots=[], **args):
for name in datasets_.keys():
name_ = ','.join(name)
if name_ in legend:
if all_labels:
if all_labels and name in all_labels_:
if all_labels_[name]:
legend_.append((all_labels_[name], legend[name_]))
else:
Expand Down

0 comments on commit 53af8b7

Please # to comment.