def save_intervals(
    intervals,
    filepath,
    profiling_title="Different ways of doing a task",
    solution_title="Solution A",
):
    """Save intervals in custom .json format.

    Works by saving the given intervals (a list of floats)
    in a given path as a .json file, within a nested
    dictionary where the top level stores data within
    a named group and the bottom level stores the given
    intervals using the dataset name as the key.

    Parameters
    ==========
    intervals (list of floats)
        list of time intervals to be saved; the type of the
        items depend on the function used to obtain the
        current time, but this kind of function usually
        returns time in seconds as a float.
    filepath (string)
        represents location of file wherein to save the
        intervals.
    profiling_title (string)
        name used to group different sets of time
        intervals; it is used as a key in a dictionary
        wherein we store different lists of time intervals
        belonging to this group.
    solution_title (string)
        name to identify the specific set of time intervals
        to be stored; it is used as a key in a dictionary
        wherein the intervals are stored; these time
        intervals represent the performance of a specific
        solution.
    """
    ### try loading the json data from the given path
    try:
        data = load_pyl(filepath)

    ### create it if it doesn't exist
    except FileNotFoundError:
        data = {}

    ### store the given data

    ## try retrieving the dictionary where the group data is
    ## stored
    try:
        group_data = data[profiling_title]

    ## create it if it doesn't exist
    except KeyError:
        group_data = data[profiling_title] = {}

    ## store the intervals in the group data using the
    ## provided key
    group_data[solution_title] = intervals

    ### finally save the json data in the given path
    save_pyl(data, filepath)
Save intervals in custom .json format.

    Works by saving the given intervals (a list of floats)
    in a given path as a .json file, within a nested
    dictionary where the top level stores data within
    a named group and the bottom level stores the given
    intervals using the dataset name as the key.

    Parameters
    ==========
    intervals (list of floats)
        list of time intervals to be saved; the type of the
        items depend on the function used to obtain the
        current time, but this kind of function usually
        returns time in seconds as a float.
    filepath (string)
        represents location of file wherein to save the
        intervals.
    profiling_title (string)
        name used to group different sets of time
        intervals; it is used as a key in a dictionary
        wherein we store different lists of time intervals
        belonging to this group.
    solution_title (string)
        name to identify the specific set of time intervals
        to be stored; it is used as a key in a dictionary
        wherein the intervals are stored; these time
        intervals represent the performance of a specific
        solution.
    
nodezator/ourstdlibs/profileutils.py