PlasmaCalcs.plotting.plot_settings.SharedPlotSetting
- class PlasmaCalcs.plotting.plot_settings.SharedPlotSetting(*args_super, docs_key, shared_keys, **kw_super)
Bases:
PlotSettingPlotSetting which is shared amongst multiple kwargs.E.g., in DEFAULT_PLOT_SETTINGS:‘kw_subplots_adjust’: [(‘hspace’, ‘wspace’, ‘bottom’, ‘top’, ‘left’, ‘right’),(None, “None or number (probably between 0 and 1)”,“””corresponding value that will be used during plt.subplots_adjust(…).None –> use rcParams[“figure.subplot.*”].”””),],corresponds to 6 kwargs, all with the same default value and docstring.No need to repeat the docstring multiple times.self.docs_dict() will contain the value from super(),in addition to {docs_key: “{’, ‘.join(self.subkeys)}: {docstring}”}.E.g. when doing PlotSettings.format_docstring(),formatted func could either contain individual keys, like:hspace: {hspace} wspace: {wspace}
…OR, just contain the docs_key, like:{kw_subplots_adjust}- __init__(*args_super, docs_key, shared_keys, **kw_super)
Methods
__init__(*args_super, docs_key, shared_keys, ...)docs_dict([ntab])docstring([ntab])get([provided])validate(value)- defaults_keystring_formatting()
- returns dict which will be used to .format the docstring.If self.defaults_keystring is provided:{‘default_value’: self.defaults_keystring_value(),‘default_key’: self.defaults_keystring,‘default’: f’{self.defaults_keystring} (default: {self.defaults_keystring_value()})’}Also, if self.defaults_keystring_dict is provided, include something similar for each key in dict,adding ‘defaults_dict_{key}_value’, ‘defaults_dict_{key}_key’, and ‘defaults_dict_{key}’.E.g. if defaults_keystring=(‘DEFAULTS.PLOT.ROBUST’, {True: ‘DEFAULTS.PLOT.ROBUST_PERCENTILE’}),when DEFAULTS.PLOT.ROBUST = True and DEFAULTS.PLOT.ROBUST_PERCENTILE = 2.0:{‘default_value’: True‘default_key’: ‘DEFAULTS.PLOT.ROBUST’,‘default’: ‘DEFAULTS.PLOT.ROBUST (default: True)’,‘defaults_dict_True_value’: 2.0,‘defaults_dict_True_key’: ‘DEFAULTS.PLOT.ROBUST_PERCENTILE’,‘defaults_dict_True’: ‘DEFAULTS.PLOT.ROBUST_PERCENTILE (default: 2.0)’}
- defaults_keystring_value()
- get the value from DEFAULTS.
- docs_dict(ntab=UNSET)
- returns super().docs_di
- docstring(ntab=UNSET)
- return the docstring for this setting, in format:{self.typestr} (default: {self.default}){self.doc}the typestr line will not be indented at all;the docstring line(s) will be indented by self.tab * ntab.self.doc will be hit by .format(**self.defaults_keystring_formatting()).(If self.defaults_keystring is None, this shouldn’t change the result.)
- get(provided=UNSET)
- get the value from self. return provided if not UNSET, else return self.get_default()
- get_default()
- get the default value: self.default if defaults_keystring is None else value from DEFAULTS.
- validate(value)
- ensures that value is valid for this setting. Raise InputError if it is not.return (if no InputError is raised) depends on self.validation:None –> return Noneiterable –> return True if valid in self.validationcallable –> return self.validation(value)