Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@docstrings.get_sectionsf('check_key', sections=['Parameters', 'Returns',
'Raises'])
@dedent
def check_key(key, possible_keys, raise_error=True,
name='formatoption keyword',
msg=("See show_fmtkeys function for possible formatopion "
"keywords"),
*args, **kwargs):
"""
Checks whether the key is in a list of possible keys
This function checks whether the given `key` is in `possible_keys` and if
not looks for similar sounding keys
Parameters
----------
key: str
def _gen_examples(cls, identifier):
"""Generate examples how to axes the formatoption docs"""
return docstrings.dedents("""
Examples
--------
To explore the formatoptions and their documentations, use the
``keys``, ``summaries`` and ``docs`` methods. For example::
# show the keys corresponding to a group or multiple
# formatopions
>>> ds.psy.plot.%(id)s.keys('labels')
# show the summaries of a group of formatoptions or of a
# formatoption
>>> ds.psy.plot.%(id)s.summaries('title')
# show the full documentation
>>> ds.psy.plot.%(id)s.docs('plot')
@docstrings.dedent
def find_and_replace(self, *args, **kwargs):
"""
Like :meth:`find_all` but the given strings are replaced
This method returns a dictionary-like object that keeps weak reference
to this rcParams instance. The resulting `SubDict` instance takes the
keys from this rcParams instance but leaves away what is found in
`base_str`.
``*args`` and ``**kwargs`` are determined by the :class:`SubDict`
class, where the `base` dictionary is this one.
Parameters
----------
%(SubDict.parameters.no_base)s
def get_parser(create=True):
"""Return a parser to make that can be used to make plots or open files
from the command line
Returns
-------
psyplot.parser.FuncArgParser
The :class:`argparse.ArgumentParser` instance"""
#: The parse that is used to parse arguments from the command line
epilog = docstrings.get_sections(docstrings.dedents("""
Examples
--------
Here are some examples on how to use psyplot from the command line.
Plot the variable ``'t2m'`` in a netCDF file ``'myfile.nc'`` and save
the plot to ``'plot.pdf'``::
$ psyplot myfile.nc -n t2m -pm mapplot -o test.pdf
Create two plots for ``'t2m'`` with the first and second timestep on
the second vertical level::
$ psyplot myfile.nc -n t2m -pm mapplot -o test.pdf -d t,0,1 z,1
If you have save a project using the
--------
_format_keys"""
def base_fmtos(base):
return filter(
lambda key: isinstance(getattr(cls, key), Formatoption),
getattr(base, '_get_formatoptions', empty)(False))
def empty(*args, **kwargs):
return list()
fmtos = (attr for attr, obj in six.iteritems(cls.__dict__)
if isinstance(obj, Formatoption))
if not include_bases:
return fmtos
return unique_everseen(chain(fmtos, *map(base_fmtos, cls.__mro__)))
docstrings.keep_types('check_key.parameters', 'kwargs',
'``\*args,\*\*kwargs``')
@classmethod
@docstrings.get_sectionsf('Plotter._enhance_keys')
@docstrings.dedent
def _enhance_keys(cls, keys=None, *args, **kwargs):
"""
Enhance the given keys by groups
Parameters
----------
keys: list of str or None
If None, the all formatoptions of the given class are used. Group
names from the :attr:`psyplot.plotter.groups` mapping are replaced
by the formatoptions
@docstrings.dedent
def project(num=None, *args, **kwargs):
"""
Create a new main project
Parameters
----------
num: int
The number of the project
%(Project.parameters.no_num)s
Returns
-------
Project
The with the given `num` (if it does not already exist, it is created)
See Also
@docstrings.get_sectionsf('multiple_subplots')
@docstrings.dedent
def multiple_subplots(rows=1, cols=1, maxplots=None, n=1, delete=True,
for_maps=False, *args, **kwargs):
"""
Function to create subplots.
This function creates so many subplots on so many figures until the
specified number `n` is reached.
Parameters
----------
rows: int
The number of subplots per rows
cols: int
The number of subplots per column
maxplots: int
@docstrings
def _njobs(self):
"""%(InteractiveBase._njobs)s"""
if self.disabled:
return [0]
return [1, 1]
@docstrings.get_sectionsf('Formatoption')
@dedent
def __init__(self, key, plotter=None, index_in_list=None,
additional_children=[], additional_dependencies=[],
**kwargs):
"""
Parameters
----------
key: str
formatoption key in the `plotter`
plotter: psyplot.plotter.Plotter
Plotter instance that holds this formatoption. If None, it is
assumed that this instance serves as a descriptor.
index_in_list: int or None
The index that shall be used if the data is a
:class:`psyplot.InteractiveList`
additional_children: list or str