Skip to content

NamedTuple return values for plottable_array_and_units and others #145

Description

@ken-lauer

plottable_array_and_units returns 5 things:

    Returns
    -------
    scaled_array : np.ndarray
    factor : float
    units_str : str or None
        Display units of the scaled values.
    xmin : float
    xmax : float

This, and any other function that returns more than 2ish items, should be converted to a namedtuple.
That would mean you could access scaled_array as plottable_array_and_units()[0] as you would currently or plottable_array_and_units().scaled_array.

This is generally good practice as confusion about positional order of return values is similar to having too many positional arguments in a function. It's better to name them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions