Skip to content

Add Options.reset_... for each option. #860

Closed

Description

@genedan

One of the new unit tests for cl.__init__ is:

def test_set_option_consistency() -> None:
    """
    When set_option changes an option value, get_option should return the new option value.

    Returns
    -------
    None

    """
    original = cl.options.ARRAY_BACKEND
    try:
        cl.options.set_option('ARRAY_BACKEND', 'sparse')
        assert cl.options.ARRAY_BACKEND == 'sparse'
        assert cl.options.get_option('ARRAY_BACKEND') == 'sparse'
    finally:
        # Reset the options to default if the test fails.
        cl.options.set_option('ARRAY_BACKEND', original)

We have a method called Options.reset_option, which resets all options, but not individually. This requires an extra line, original = cl.options.ARRAY_BACKEND, to extract ARRAY_BACKEND and then reset it after the test.

We can remove this by allowing individual options to be reset, such as:

cl.options.reset_array_backend()

or

cl.options.reset_option('ARRAY_BACKEND`)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Scope

    None yet

    Effort

    None yet

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions