Skip to content

Default options for time consuming properties #23

@cruizgo

Description

@cruizgo

Some Graph properties are hard to compute but not always needed, like perfect_matchings. Therefore, we initialize them with a default string which says: This property is not ready, run getPerfectMatchings.

This nooby trick, which is also used in state_catalog and norm, should be replace by this suggestion from Matthias:

class Graph:

    def __init__(self):
        self._state_catalog = None

    @property
    def state_catalog(self):
        if self._state_catalog is None:
            self._compute_state_catalog()
        return self._state_catalog

    def _compute_state_catalog(self):
        # Lengthy calculation here, setting self._state_catalog

Metadata

Metadata

Assignees

No one assigned

    Labels

    clean codeViolations against clean code principles.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions