Skip to content

Commit a408329

Browse files
committed
Added additional_children parameter for Formatoption
1 parent 6a9bb9b commit a408329

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

CHANGELOG.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ Added
2323
* Added the ``gridweights``, ``fldmean``, ``fldstd`` and ``fldpctl`` methods
2424
to the ``psy`` DataArray accessor to calculate weighted means, standard
2525
deviations and percentiles over the spatial dimensions (x- and y).
26+
* Added the ``additional_children`` and ``additional_dependencies`` parameters
27+
to the Formatoption intialization. These parameters can be used to provide
28+
additional children for a formatoption for one plotter class
2629

2730

2831
v1.0.0

psyplot/plotter.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,9 @@ def value2pickle(self):
403403

404404
@docstrings.get_sectionsf('Formatoption')
405405
@dedent
406-
def __init__(self, key, plotter=None, index_in_list=None, **kwargs):
406+
def __init__(self, key, plotter=None, index_in_list=None,
407+
additional_children=[], additional_dependencies=[],
408+
**kwargs):
407409
"""
408410
Parameters
409411
----------
@@ -415,6 +417,11 @@ def __init__(self, key, plotter=None, index_in_list=None, **kwargs):
415417
index_in_list: int or None
416418
The index that shall be used if the data is a
417419
:class:`psyplot.InteractiveList`
420+
additional_children: list or str
421+
Additional children to use (see the :attr:`children` attribute)
422+
additional_dependencies: list or str
423+
Additional dependencies to use (see the :attr:`dependencies`
424+
attribute)
418425
``**kwargs``
419426
Further keywords may be used to specify different names for
420427
children, dependencies and connection formatoptions that match the
@@ -426,6 +433,10 @@ def __init__(self, key, plotter=None, index_in_list=None, **kwargs):
426433
self.plotter = plotter
427434
self.index_in_list = index_in_list
428435
self.shared = set()
436+
self.additional_children = additional_children
437+
self.additional_dependencies = additional_dependencies
438+
self.children = self.children + additional_children
439+
self.dependencies = self.dependencies + additional_dependencies
429440
self._child_mapping = dict(zip(*tee(chain(
430441
self.children, self.dependencies, self.connections,
431442
self.parents), 2)))
@@ -455,7 +466,10 @@ def __get__(self, instance, owner):
455466
return getattr(instance, '_' + self.key)
456467
except AttributeError:
457468
fmto = self.__class__(
458-
self.key, instance, self.index_in_list, **self.init_kwargs)
469+
self.key, instance, self.index_in_list,
470+
additional_children=self.additional_children,
471+
additional_dependencies=self.additional_dependencies,
472+
**self.init_kwargs)
459473
setattr(instance, '_' + self.key, fmto)
460474
return fmto
461475

0 commit comments

Comments
 (0)