Skip to content

Commit

Permalink
[Palisade] Deprecate key 'upper_label' and issue warning.
Browse files Browse the repository at this point in the history
  • Loading branch information
dsavoiu committed Aug 22, 2019
1 parent 2e04759 commit bc0d1ff
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,16 @@
# matplotlib keywords
'color': 'gray'
},
# upper plot label (need to escape braces with `LiteralString`)
{
'text' : LiteralString(r"upper label with math: $\phi={\left(1\pm\sqrt{5}\right)}/{2}$"),
'xy': (1, 1),
'xycoords': 'axes fraction',
'xytext': (0, 5),
'textcoords': 'offset points',
'pad': 0
}
],

# upper plot label (need to escape braces with `LiteralString`)
'upper_label' : LiteralString(r"upper label with math: $\phi={\left(1\pm\sqrt{5}\right)}/{2}$"),
}
],

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,17 @@
'fontsize': 20,
'pad': 1,
},
# upper plot label (need to escape braces with `LiteralString`)
{
'text' : LiteralString(r"upper label with math: $\phi={\left(1\pm\sqrt{5}\right)}/{2}$"),
'xy': (1, 1),
'xycoords': 'axes fraction',
'xytext': (0, 5),
'textcoords': 'offset points',
'pad': 0
}
],

# upper plot label (need to escape braces with `LiteralString`)
'upper_label' : LiteralString(r"upper label with math: $\phi={\left(1\pm\sqrt{5}\right)}/{2}$"),
}
],

Expand Down
17 changes: 13 additions & 4 deletions PostProcessing/python/Palisade/Processors/_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import math
import os
import six
import warnings
import yaml

from copy import deepcopy
Expand Down Expand Up @@ -738,12 +739,20 @@ def _plot(self, config):
# handle figure label ("upper_label")
_upper_label = config.pop('upper_label', None)
if _upper_label is not None:

# keyword is deprecated
warnings.warn(
"Keyword `upper_label` is deprecated and will be removed in "
"the future. Replace it with the following equivalent annotation under "
"`texts`: dict(text='...', xy=(1, 1), xycoords='axes fraction', xytext=(0, 5), "
"textcoords='offset points', ha='right', pad=0).", DeprecationWarning)

# place above topmost `Axes`
_ax_top = _pad_configs[0]['axes']
_ax_top.text(1.0, 1.015,
_upper_label,
_pad_configs[0]['axes'].annotate(_upper_label, xy=(1, 1),
xycoords='axes fraction',
xytext=(0, 5),
textcoords='offset points',
ha='right',
transform=_ax_top.transAxes
)


Expand Down
4 changes: 4 additions & 0 deletions PostProcessing/python/Palisade/_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import os
import re
import sys
import warnings

from contextlib import contextmanager
from tqdm import tqdm
Expand Down Expand Up @@ -216,6 +217,9 @@ def _get_cli_args_and_task(self):

def run(self):

# show deprecation warnings by default
warnings.simplefilter('default', DeprecationWarning)

if self._task_module is None:
raise NotImplemented
else:
Expand Down

0 comments on commit bc0d1ff

Please sign in to comment.