Skip to content

Commit 62b5fc2

Browse files
committed
Minor changes [skip ci]
1 parent 8e118f6 commit 62b5fc2

1 file changed

Lines changed: 48 additions & 44 deletions

File tree

psyplot/plotter.py

Lines changed: 48 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -698,15 +698,15 @@ def set_value(self, value, validate=True, todefault=False):
698698
if todefault:
699699
self.plotter[self.key].clear()
700700
self.plotter[self.key].update(value)
701-
702-
701+
702+
703703
class PostTiming(Formatoption):
704704
"""
705705
Determine when to run the :attr:`post` formatoption
706-
706+
707707
This formatoption determines, whether the :attr:`post` formatoption
708708
should be run never, after replot or after every update.
709-
709+
710710
Possible types
711711
--------------
712712
'never'
@@ -716,17 +716,19 @@ class PostTiming(Formatoption):
716716
'replot'
717717
Only run post processing scripts when the data changes or a replot
718718
is necessary
719-
719+
720720
See Also
721721
--------
722722
post: The post processing formatoption"""
723-
723+
724724
default = 'never'
725-
725+
726726
priority = -inf
727-
727+
728728
group = 'post_processing'
729-
729+
730+
name = 'Timing of the post processing'
731+
730732
@staticmethod
731733
def validate(value):
732734
value = six.text_type(value)
@@ -735,58 +737,58 @@ def validate(value):
735737
raise ValueError('String must be one of %s, not %r' % (
736738
possible_values, value))
737739
return value
738-
740+
739741
def update(self, value):
740742
pass
741-
742-
743+
744+
743745
class PostProcDependencies(object):
744746
"""The dependencies of this formatoption"""
745-
747+
746748
def __get__(self, instance, owner):
747-
if (instance is None or instance.plotter is None or
749+
if (instance is None or instance.plotter is None or
748750
not instance.plotter._initialized):
749751
return []
750752
elif instance.post_timing.value == 'always':
751753
return list(set(instance.plotter) - {instance.key})
752754
else:
753755
return []
754-
756+
755757
def __set__(self, instance, value):
756758
pass
757759

758760

759761
class PostProcessing(Formatoption):
760762
"""
761763
Apply your own postprocessing script
762-
764+
763765
This formatoption let's you apply your own post processing script. Just
764766
enter the script as a string and it will be executed. The formatoption
765767
will be made available via the ``self`` variable
766-
768+
767769
Possible types
768770
--------------
769771
None
770772
Don't do anything
771773
str
772774
The post processing script as string
773-
775+
774776
Note
775777
----
776-
This formatoption uses the built-in :func:`exec` function to compile the
778+
This formatoption uses the built-in :func:`exec` function to compile the
777779
script. Since this poses a security risk when loading psyplot projects,
778-
it is by default disabled through the :attr:`Plotter.enable_post`
779-
attribute. If you are sure that you can trust the script in this
780+
it is by default disabled through the :attr:`Plotter.enable_post`
781+
attribute. If you are sure that you can trust the script in this
780782
formatoption, set this attribute of the corresponding :class:`Plotter` to
781783
``True``
782-
784+
783785
Examples
784786
--------
785-
Assume, you want to manually add the mean of the data to the title of the
787+
Assume, you want to manually add the mean of the data to the title of the
786788
matplotlib axes. You can simply do this via
787-
789+
788790
.. code-block:: python
789-
791+
790792
from psyplot.plotter import Plotter
791793
from xarray import DataArray
792794
plotter = Plotter(DataArray([1, 2, 3]))
@@ -795,28 +797,30 @@ class PostProcessing(Formatoption):
795797
plotter.update(post="self.ax.set_title(str(self.data.mean()))")
796798
plotter.ax.get_title()
797799
'2.0'
798-
800+
799801
By default, the ``post`` formatoption is only ran, when it is explicitly
800-
updated. However, you can use the :attr:`post_timing` formatoption, to
801-
run it automatically. E.g. for running it after every update of the
802+
updated. However, you can use the :attr:`post_timing` formatoption, to
803+
run it automatically. E.g. for running it after every update of the
802804
plotter, you can set
803-
805+
804806
.. code-block:: python
805-
807+
806808
plotter.update(post_timing='always')
807-
809+
808810
See Also
809811
--------
810812
post_timing: Determine the timing of this formatoption"""
811-
813+
812814
children = ['post_timing']
813-
815+
814816
default = None
815-
817+
816818
priority = -inf
817-
819+
818820
group = 'post_processing'
819-
821+
822+
name = 'Custom post processing script'
823+
820824
@staticmethod
821825
def validate(value):
822826
if value is None:
@@ -825,16 +829,16 @@ def validate(value):
825829
raise ValueError("Expected a string, not %s" % (type(value), ))
826830
else:
827831
return six.text_type(value)
828-
832+
829833
@property
830834
def data_dependent(self):
831835
"""True if the corresponding :class:`post_timing <PostTiming>`
832836
formatoption is set to ``'replot'`` to run the post processing script
833837
after every change of the data"""
834838
return self.post_timing.value == 'replot'
835-
839+
836840
dependencies = PostProcDependencies()
837-
841+
838842
def update(self, value):
839843
if value is None:
840844
return
@@ -856,7 +860,7 @@ class Plotter(dict):
856860

857861
#: List of base strings in the :attr:`psyplot.rcParams` dictionary
858862
_rcparams_string = []
859-
863+
860864
post_timing = PostTiming('post_timing')
861865
post = PostProcessing('post')
862866

@@ -1012,8 +1016,8 @@ def plot_data(self, value):
10121016
#: The decoder to use for the formatoptions. If None, the decoder of the
10131017
#: raw data is used
10141018
plot_data_decoder = None
1015-
1016-
#: :class:`bool` that has to be ``True`` if the post processing script in
1019+
1020+
#: :class:`bool` that has to be ``True`` if the post processing script in
10171021
#: the :attr:`post` formatoption should be enabled
10181022
enable_post = False
10191023

@@ -1037,7 +1041,7 @@ def logger(self):
10371041
@docstrings.get_sectionsf('Plotter')
10381042
@docstrings.dedent
10391043
def __init__(self, data=None, ax=None, auto_update=None, project=None,
1040-
draw=None, make_plot=True, clear=False,
1044+
draw=None, make_plot=True, clear=False,
10411045
enable_post=False, **kwargs):
10421046
"""
10431047
Parameters
@@ -1057,7 +1061,7 @@ def __init__(self, data=None, ax=None, auto_update=None, project=None,
10571061
clear: bool
10581062
If True, the axes is cleared first
10591063
enable_post: bool
1060-
If True, the :attr:`post` formatoption is enabled and post
1064+
If True, the :attr:`post` formatoption is enabled and post
10611065
processing scripts are allowed
10621066
``**kwargs``
10631067
Any formatoption key from the :attr:`formatoptions` attribute that

0 commit comments

Comments
 (0)