Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@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
Key to check
possible_keys: list of strings
@dedent
def check_data(cls, name, dims, is_unstructured):
"""
A validation method for the data shape
The default method does nothing and should be subclassed to validate
the results. If the plotter accepts a :class:`InteractiveList`, it
should accept a list for name and dims
Parameters
----------
name: str or list of str
The variable name(s) of the data
dims: list of str or list of lists of str
The dimension name(s) of the data
is_unstructured: bool or list of bool
True if the corresponding array is unstructured
@dedent
def plot(self):
"""
Plotting instance of this :class:`Project`. See the
:class:`ProjectPlotter` class for method documentations"""
return self._plot
@dedent
def remove(self):
"""
Method to remove the effects of this formatoption
This method is called when the axes is cleared due to a
formatoption with :attr:`requires_clearing` set to True. You don't
necessarily have to implement this formatoption if your plot results
are removed by the usual :meth:`matplotlib.axes.Axes.clear` method."""
pass
@dedent
def close(self, figs=True, data=False, ds=False, remove_only=False):
"""
Close this project instance
Parameters
----------
figs: bool
Close the figures
data: bool
delete the arrays from the (main) project
ds: bool
If True, close the dataset as well
remove_only: bool
If True and `figs` is True, the figures are not closed but the
plotters are removed"""
import matplotlib.pyplot as plt
@dedent
def value2pickle(self):
"""
The value that can be used when pickling the information of the project
"""
return self.value
@dedent
def safe_list(l):
"""Function to create a list
Parameters
----------
l: iterable or anything else
Parameter that shall be converted to a list.
- If string or any non-iterable, it will be put into a list
- if iterable, it will be converted to a list
Returns
-------
list
`l` put (or converted) into a list"""
if isstring(l):
@dedent
def setup_logging(default_path=None, default_level=logging.INFO,
env_key='LOG_PSYPLOT'):
"""
Setup logging configuration
Parameters
----------
default_path: str
Default path of the yaml logging configuration file. If None, it
defaults to the 'logging.yaml' file in the config directory
default_level: int
Default: :data:`logging.INFO`. Default level if default_path does not
exist
env_key: str
environment variable specifying a different logging file than
`default_path` (Default: 'LOG_CFG')
@dedent
def scp(project):
"""
Set the current project
Parameters
----------
%(Project.scp.parameters)s
See Also
--------
gcp: Returns the current project
project: Creates a new project"""
return PROJECT_CLS.scp(project)
@dedent
def gcp(main=False):
"""
Get the current project
Parameters
----------
main: bool
If True, the current main project is returned, otherwise the current
subproject is returned.
See Also
--------
scp: Sets the current project
project: Creates a new project"""
if main:
return project() if _current_project is None else _current_project
else: