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

Do not generate subnetworks all the time but provide them dynamically #810

Merged
merged 12 commits into from
Apr 1, 2023

Conversation

FranzForstmayr
Copy link
Collaborator

Do not generate subnetworks all the time but provide them dynamically if requested.

This is an alternative approach for #807, open for discussion

@FranzForstmayr
Copy link
Collaborator Author

Subnetworks aren't shown in docs anymore...

@jhillairet
Copy link
Member

Subnetworks aren't shown in docs anymore...

and I guess neither in the autocompletion, isn't?

@FranzForstmayr
Copy link
Collaborator Author

I don't think so. I work with vscode, which hadn't autocompletion for this dynamically generated properties anyway.

@FranzForstmayr FranzForstmayr marked this pull request as draft January 9, 2023 09:02
@FranzForstmayr
Copy link
Collaborator Author

I did some research about dynamic properties and autocompletion today.

It's not possible to get static typing or type hints (as for mypy or any other typechecker) with dynamically created properties, as the type checker does not execute the code even once, that's why it's not aware of the dynamic attributes.

Interactive Sessions like jupyter or ipython have a concept which is called autosuggestion which can handle dynamic properties. The list of available properties is taken from the dir() method.

So this PR removes dynamic property setting and generates all available dynamic attributes on the fly, as the getattr() method is overloaded. Autosuggestion for interactive Sessions and Jupyter is done via the dir method.

Open for Feedback :)

If this works well, this method could be expanded to replace the code, which creates the plotting methods for a Network or NetworkSet

@FranzForstmayr
Copy link
Collaborator Author

Still have to investigate sphinx build

@jhillairet
Copy link
Member

what about what has been proposed in #828 concerning secondary properties?

@FranzForstmayr
Copy link
Collaborator Author

The secondary property generation is error prone in general and wouldn't be needed anymore.

@FranzForstmayr
Copy link
Collaborator Author

I think we can start review at this point, although I think we should not merge before 0.25 release. A follow up PR #848 will unify the plot code generation.

@FranzForstmayr FranzForstmayr marked this pull request as ready for review February 13, 2023 22:54
Copy link
Member

@jhillairet jhillairet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very nice addition, hats off!

@jhillairet
Copy link
Member

OK for merging this PR? Or shall we wait for the #848?

@FranzForstmayr
Copy link
Collaborator Author

I think this one is fine. #848 already includes this PR, but isn't finished yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants