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

Import Convention for TopoNetX #335

Closed
ffl096 opened this issue Feb 2, 2024 · 1 comment · Fixed by #361
Closed

Import Convention for TopoNetX #335

ffl096 opened this issue Feb 2, 2024 · 1 comment · Fixed by #361
Labels
discussion enhancement New feature or request

Comments

@ffl096
Copy link
Member

ffl096 commented Feb 2, 2024

Since #215, classes and functions are only available with explicit imports, e.g.:

from toponetx.classes import SimplicialComplex
from toponetx.transform import graph_to_clique_complex

SC1 = SimplicialComplex()
SC2 = graph_to_clique_complex(nx.erdos_renyi_graph(50, 0.3))

Following other popular libraries, a structure supporting the following code would be easier, I think:

import toponetx as tnx

SC1 = tnx.SimplicialComplex()
SC2 = tnx.graph_to_clique_complex(nx.erdos_renyi_graph(50, 0.3))

We should then embrace this convention in the documentation and examples as well.

In #214, it was argued that with this structure, from toponetx import * will clutter the global namespace. I argue that such a statement is discouraged and shouldn't be used by the user in the first place. We can further prevent this misuse by placing an appropriate __all__ variable in the root __init__.py file (see e.g. NumPy).

@ffl096 ffl096 added enhancement New feature or request discussion labels Feb 2, 2024
@ffl096
Copy link
Member Author

ffl096 commented Feb 5, 2024

Somewhat related to this, see the Scientific Python SPEC about lazy loading of submodules and functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant