DecoratingPlotters
- class PlasmaCalcs.plotting.plotter_manager.DecoratingPlotters(known=None)
Bases:
objectDecorating functions to put plotters into a dict (self.known)
- known: None or dict
- will be a dict of {(name, person): Plotter} pairs.person will be None if it nobody was specified via
who.
self.unique will be a dict of {id(plotter): plotter} for all unique plotters.self.known_names will be a set of all names appearing in any plotter in self.known.self.known_kinds will be a set of all kinds appearing in any plotter in self.known.self.known_who will be a set of all people appearing in any plotter in self.known.Example: known_plotter = DecoratingPlotters(storage_dict)@known_plotterdef plot_name1(…):…@known_plotter(who=’sam’, kinds=[‘movie’, ‘density’])def plot_name2(…):…# at this point, we have:# known_plotter.known == {‘name1’: Plotter(‘plot_name1’),# ‘name2’: Plotter(‘plot_name2’, who=’sam’, kinds=[‘movie’, ‘density’])}Methods
__call__([f, who, kind, kinds, ani, ...])if f is provided, return self.decorator(**kw)(f).
decorator(*[, who, kind, kinds, ani, ...])returns decorator for plot manager's f(self, *args, **kw), which returns f, unchanged...
track_f(f, *[, who, kind, kinds, ani, ...])add f to self.known as a Plotter.
_get_keys(name, who, aliases)get keys for where to store the plotter with this name, in self.known.
Attributes
set of all kinds appearing in any plotter in self
set of all names appearing in any plotter in self
set of all people appearing in any plotter in self.
- __call__(f=None, *, who=[], kind=UNSET, kinds=UNSET, ani=UNSET, savename=None, cost=20, aliases=[], **kw_decorator)
if f is provided, return self.decorator(**kw)(f). Otherwise, return self.decorator(**kw).
This enables instances to be used as decorators directly, i.e. “@self”,or used as decorators after providing kwargs, e.g. “@self(who=’sam’, kind=’movie’)”.See help(type(self)) for examples.See help(self.decorator) for parameter descriptions.
- _get_keys(name, who, aliases)
get keys for where to store the plotter with this name, in self.known.
- decorator(*, who=[], kind=UNSET, kinds=UNSET, ani=UNSET, savename=None, cost=20, aliases=[])
returns decorator for plot manager’s f(self, *args, **kw), which returns f, unchanged…
but also sets self.known[name] = Plotter(f.__name__, …).(requires f.__name__ looks like ‘plot_name’)- who: str or list of str
- “person” or people associated with this plotter. Arbitrary strings.E.g. to only make plots for ‘sam’ person, use PlotterManager.standard_plots(…, who=’sam’).
- kind: UNSET, str, or list of str
- “kind” or kinds associated with this plotter. Arbitrary strings.E.g. to only make plots for ‘movie’ kind, use PlotterManager.standard_plots(…, kind=’movie’).Internally, stored at Plotter.kinds (plural).
- kinds: UNSET, str, or list of str
- alias for kwarg
kind. Can providekindsorkindbut not both. - ani: UNSET or bool
- whether the plotter is for an animated plot.(commands to save/show an animated plot are different than those to save/show a static plot.)if UNSET, infer from kinds. True if kinds includes any of these (case insensitive):[‘movie’, ‘gif’, ‘ani’, ‘animation’, ‘animated’]
- savename: None or str
- default filename when doing plotter.save() for this plot.None –> use plotter.name, which is fname after removing ‘plot_’ prefix.
- cost: number
- some guess about the cost to make this plot. Default=20.when making multiple plots, go in cost order.Can also set cost thresholds and skip ones that are too expensive.
- aliases: list of str
- self.known[(person, alias)] = self.known[(person, name)] for each alias provided.
- property known_kinds
set of all kinds appearing in any plotter in self
- property known_names
set of all names appearing in any plotter in self
- property known_who
set of all people appearing in any plotter in self.
- track_f(f, *, who=[], kind=UNSET, kinds=UNSET, ani=UNSET, savename=None, cost=20, aliases=[])
add f to self.known as a Plotter.
f must look like ‘plot_name’ where name can be any string;will make self.known[(name, person)] = Plotter(f, …)- who: str or list of str
- “person” or people associated with this plotter. Arbitrary strings.E.g. to only make plots for ‘sam’ person, use PlotterManager.standard_plots(…, who=’sam’).
- kind: UNSET, str, or list of str
- “kind” or kinds associated with this plotter. Arbitrary strings.E.g. to only make plots for ‘movie’ kind, use PlotterManager.standard_plots(…, kind=’movie’).Internally, stored at Plotter.kinds (plural).
- kinds: UNSET, str, or list of str
- alias for kwarg
kind. Can providekindsorkindbut not both. - ani: UNSET or bool
- whether the plotter is for an animated plot.(commands to save/show an animated plot are different than those to save/show a static plot.)if UNSET, infer from kinds. True if kinds includes any of these (case insensitive):[‘movie’, ‘gif’, ‘ani’, ‘animation’, ‘animated’]
- savename: None or str
- default filename when doing plotter.save() for this plot.None –> use plotter.name, which is fname after removing ‘plot_’ prefix.
- cost: number
- some guess about the cost to make this plot. Default=20.when making multiple plots, go in cost order.Can also set cost thresholds and skip ones that are too expensive.
- aliases: list of str
- self.known[(person, alias)] = self.known[(person, name)] for each alias provided.