optiwindnet.db ============== .. py:module:: optiwindnet.db Package Contents ---------------- .. py:function:: open_database(filepath: str, create_db: bool = False) -> pony.orm.Database Opens the sqlite database v2 file specified in `filepath`. :param filepath: path to database file :param create_db: True -> create a new file if it does not exist :returns: Database object (Pony ORM) .. py:function:: G_by_method(G: networkx.Graph, method: object, db: pony.orm.Database) -> networkx.Graph Fetch from the database a layout for `G` by `method`. `G` must be a layout solution with the necessary info in the G.graph dict. `method` is a Method. .. py:function:: G_from_routeset(routeset: object) -> networkx.Graph Translate a RouteSet database entry to a routeset graph. :param routeset: an entry from the database RouteSet table. :returns: Graph G containing the routeset. .. py:function:: Gs_from_attrs(farm: object, methods: object | collections.abc.Sequence[object], capacities: int | collections.abc.Sequence[int], db: pony.orm.Database) -> list[tuple[networkx.Graph]] Fetch from the database a list (one per capacity) of tuples (one per method) of layouts. `farm` must have the desired NodeSet name in the `name` attribute. `methods` is a (sequence of) Method instance(s). `capacities` is a (sequence of) int(s). .. py:function:: L_from_nodeset(nodeset: object, handle: str | None = None) -> networkx.Graph Translate a NodeSet database entry to a location graph. :param nodeset: an entry from the database NodeSet table. :returns: Graph L containing the positions and location metadata.