def _parse_plot(self, lineno, linesplit_space): """ @plot expr {mpl_prop} """ cmd = linesplit_space[0] if len(linesplit_space) == 1: # @plot raise ParseException(lineno, f"Invalid {cmd} command.") expr0, mpl_prop = ParseUtil.get_ending_dict(linesplit_space[1]) if mpl_prop is None: mpl_prop = dict() expr = expr0 all_stimulus_elements = self.parameters.get(kw.STIMULUS_ELEMENTS) all_behaviors = self.parameters.get(kw.BEHAVIORS) err = None if cmd == kw.VPLOT: expr, err = ParseUtil.parse_element_behavior( expr0, all_stimulus_elements, all_behaviors) elif cmd == kw.VSSPLOT: expr, err = ParseUtil.parse_element_element( expr0, all_stimulus_elements) elif cmd == kw.PPLOT: stimulus, behavior, err = ParseUtil.parse_stimulus_behavior( expr0, all_stimulus_elements, all_behaviors, self.variables) expr = (stimulus, behavior) elif cmd == kw.NPLOT: expr, err = ParseUtil.parse_chain(expr0, all_stimulus_elements, all_behaviors) if err: raise ParseException(lineno, err) return expr, mpl_prop, expr0
def _parse_figure(self, lineno, linesplit_space): """ @figure @figure title @figure {mpl_prop} @figure title {mpl_prop} """ title = self.parameters.get(kw.TITLE) if len(linesplit_space) == 1: # @figure mpl_prop = dict() elif len(linesplit_space) == 2: # @figure args title, mpl_prop = ParseUtil.get_ending_dict(linesplit_space[1]) if mpl_prop is None: mpl_prop = dict() return title, mpl_prop
def _parse_subplot(self, lineno, linesplit_space): """ @subplot @subplot subplotspec @subplot subplotspec title @subplot subplotspec {mpl_prop} @subplot subplotspec title {mpl_prop} """ title_param = self.parameters.get(kw.SUBPLOTTITLE) if len(linesplit_space) == 1: # @subplot subplotspec = '111' title = title_param mpl_prop = dict() elif len(linesplit_space) == 2: # @subplot ... args, mpl_prop = ParseUtil.get_ending_dict(linesplit_space[1]) if mpl_prop is None: mpl_prop = dict() subplotspec, title_line = ParseUtil.split1_strip(args) if title_line is None: # @subplot subplotspec title = title_param else: title = title_line return subplotspec, title, mpl_prop