switch_model/tools/graph/main.py
def graph(
        name,
        title=None,
        supports_multi_scenario=False,
        requires_multi_scenario=False,
        is_long=False,
        note=None
):
    """
    This function should be used as a decorator to register a graphing function.
    Graphing functions are functions that are run by 'switch graph' or 'switch compare'.
    Graphing functions take one argument, an instance of GraphTools.

    @param name: name of the graph created by the decorated function.
                    This is used as the filename for the output.png file.
    @param title: The title to be put on the graph.
    @param supports_multi_scenario: If true, the function is responsible for graphing data from multiple scenarios.
    @param requires_multi_scenario: If true, the graphing function will only be run when comparing multiple scenarios
    @param is_long: If true, the --skip-long CLI flag will skip this function
    @param note: Note to add to the bottom of the graph
    """

    def decorator(func):
        @functools.wraps(func)
        @catch_exceptions("Failed to run a graphing function.", should_catch=CATCH_EXCEPTIONS)
        def wrapper(tools: GraphTools):
            if tools.skip_long and is_long:
                return

            if tools.num_scenarios < 2 and requires_multi_scenario:
                return

            func(tools)

        wrapper.name = name
        wrapper.multi_scenario = supports_multi_scenario or requires_multi_scenario
        wrapper.title = title
        wrapper.note = note

        if name in registered_graphs:
            raise Exception(f"Graph '{name}' already exists. Make sure to pick a unique name.")

        registered_graphs[name] = wrapper
        return wrapper

    return decorator

    This function should be used as a decorator to register a graphing function.
    Graphing functions are functions that are run by 'switch graph' or 'switch compare'.
    Graphing functions take one argument, an instance of GraphTools.

    @param name: name of the graph created by the decorated function.
                    This is used as the filename for the output.png file.
    @param title: The title to be put on the graph.
    @param supports_multi_scenario: If true, the function is responsible for graphing data from multiple scenarios.
    @param requires_multi_scenario: If true, the graphing function will only be run when comparing multiple scenarios
    @param is_long: If true, the --skip-long CLI flag will skip this function
    @param note: Note to add to the bottom of the graph
    
This function should be used as a decorator to register a graphing function.
Graphing functions are functions that are run by 'switch graph' or 'switch compare'.
Graphing functions take one argument, an instance of GraphTools.
This function should be used as a decorator to register a graphing function . Graphing functions are functions that are run by ' switch graph ' or ' switch compare ' . Graphing functions take one argument an instance of GraphTools .
def graph(
        name,
        title=None,
        supports_multi_scenario=False,
        requires_multi_scenario=False,
        is_long=False,
        note=None
):
    def decorator(func):
        @functools.wraps(func)
        @catch_exceptions("Failed to run a graphing function.", should_catch=CATCH_EXCEPTIONS)
        def wrapper(tools: GraphTools):
            if tools.skip_long and is_long:
                return
            if tools.num_scenarios < 2 and requires_multi_scenario:
                return
            func(tools)
        wrapper.name = name
        wrapper.multi_scenario = supports_multi_scenario or requires_multi_scenario
        wrapper.title = title
        wrapper.note = note
        if name in registered_graphs:
            raise Exception(f"Graph '{name}' already exists. Make sure to pick a unique name.")
        registered_graphs[name] = wrapper
        return wrapper
    return decorator
def graph ( name , title = None , supports_multi_scenario = False , requires_multi_scenario = False , is_long = False , note = None ) : def decorator ( func ) : @ functools . wraps ( func ) @ catch_exceptions ( "Failed to run a graphing function." , should_catch = CATCH_EXCEPTIONS ) def wrapper ( tools : GraphTools ) : if tools . skip_long and is_long : return if tools . num_scenarios < 2 and requires_multi_scenario : return func ( tools ) wrapper . name = name wrapper . multi_scenario = supports_multi_scenario or requires_multi_scenario wrapper . title = title wrapper . note = note if name in registered_graphs : raise Exception ( f"Graph '{name}' already exists. Make sure to pick a unique name." ) registered_graphs [ name ] = wrapper return wrapper return decorator
This function should be used as a decorator to register a graphing function.
This function should be used as a decorator to register a graphing function .
"""
    This function should be used as a decorator to register a graphing function.
    Graphing functions are functions that are run by 'switch graph' or 'switch compare'.
    Graphing functions take one argument, an instance of GraphTools.

    @param name: name of the graph created by the decorated function.
                    This is used as the filename for the output.png file.
    @param title: The title to be put on the graph.
    @param supports_multi_scenario: If true, the function is responsible for graphing data from multiple scenarios.
    @param requires_multi_scenario: If true, the graphing function will only be run when comparing multiple scenarios
    @param is_long: If true, the --skip-long CLI flag will skip this function
    @param note: Note to add to the bottom of the graph
    """
name
name of the graph created by the decorated function.
This is used as the filename for the output.png file.
name of the graph created by the decorated function . This is used as the filename for the output . png file .
title
The title to be put on the graph.
The title to be put on the graph .
supports_multi_scenario
If true, the function is responsible for graphing data from multiple scenarios.
If true the function is responsible for graphing data from multiple scenarios .
requires_multi_scenario
If true, the graphing function will only be run when comparing multiple scenarios
If true the graphing function will only be run when comparing multiple scenarios
is_long
If true, the --skip-long CLI flag will skip this function
If true the -- skip - long CLI flag will skip this function
note
Note to add to the bottom of the graph
Note to add to the bottom of the graph