TopoNetX icon indicating copy to clipboard operation
TopoNetX copied to clipboard

Import Convention for TopoNetX

Open ffl096 opened this issue 2 years ago • 1 comments

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 avatar Feb 02 '24 12:02 ffl096

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

ffl096 avatar Feb 05 '24 07:02 ffl096