Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default options for time consuming properties #23

Open
cruizgo opened this issue Aug 19, 2022 · 0 comments
Open

Default options for time consuming properties #23

cruizgo opened this issue Aug 19, 2022 · 0 comments
Labels
clean code Violations against clean code principles.

Comments

@cruizgo
Copy link
Collaborator

cruizgo commented Aug 19, 2022

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
@cruizgo cruizgo added the clean code Violations against clean code principles. label Aug 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clean code Violations against clean code principles.
Projects
None yet
Development

No branches or pull requests

1 participant