From 4dd301739cc7cdc9610f00f985be26884ec85f4a Mon Sep 17 00:00:00 2001 From: Aidavdw <39270007+Aidavdw@users.noreply.github.com> Date: Thu, 26 Jun 2025 15:36:25 +0200 Subject: [PATCH 1/3] Add first part of .pyi file for XDSM.py --- pyxdsm/XDSM.pyi | 92 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 pyxdsm/XDSM.pyi diff --git a/pyxdsm/XDSM.pyi b/pyxdsm/XDSM.pyi new file mode 100644 index 0000000..534bbad --- /dev/null +++ b/pyxdsm/XDSM.pyi @@ -0,0 +1,92 @@ +from typing import Iterator, NamedTuple, Literal + +OPT: str +SUBOPT: str +SOLVER: str +DOE: str +IFUNC: str +FUNC: str +GROUP: str +IGROUP: str +METAMODEL: str +LEFT: str +RIGHT: str + +tikzpicture_template: str +tex_template: str + +def chunk_label(label: str, n_chunks: int) -> Iterator[str]: ... +def _parse_label( + label: str | list[str] | tuple[str, ...], label_width: int | None = ... +) -> str: ... +def _label_to_spec(label: str | list[str], spec: set[str]) -> None: ... + +class System(NamedTuple): + node_name: str + style: str + label: str | list[str] + stack: bool + faded: bool + label_width: int | None + spec_name: str + +class Input(NamedTuple): + node_name: str + label: str | list[str] + label_width: int | None + style: str + stack: bool + faded: bool + +class Output(NamedTuple): + node_name: str + label: str | list[str] + label_width: int | None + style: str + stack: bool + faded: bool + side: Literal["left", "right"] + +class Connection(NamedTuple): + src: str + target: str + label: str | list[str] + label_width: int | None + style: str + stack: bool + faded: bool + src_faded: bool + target_faded: bool + +class Process(NamedTuple): + systems: list[str] + arrow: str + faded: bool + +class XDSM: + systems: list[System] + connections: list[Connection] + left_outs: dict[str, Output] + right_outs: dict[str, Output] + ins: dict[str, Input] + processes: list[Process] + use_sfmath: bool + optional_packages: list[str] + auto_fade: dict[str, str] + + def __init__( + self, + use_sfmath: bool = ..., + optional_latex_packages: str | list[str] | None = ..., + auto_fade: dict[str, str] | None = ..., + ) -> None: ... + def add_system( + self, + node_name: str, + style: str, + label: str | list[str] | tuple[str, ...], + stack: bool = ..., + faded: bool = ..., + label_width: int | None = ..., + spec_name: str | None = ..., + ) -> None: ... From 6bf0254640d1e1d2988e918f4c42c8de149fe11e Mon Sep 17 00:00:00 2001 From: Aidavdw <39270007+Aidavdw@users.noreply.github.com> Date: Thu, 26 Jun 2025 15:44:50 +0200 Subject: [PATCH 2/3] Add rest of XDSM.py to .pyi Left out internal functions deliberately. --- pyxdsm/XDSM.pyi | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/pyxdsm/XDSM.pyi b/pyxdsm/XDSM.pyi index 534bbad..4142cbd 100644 --- a/pyxdsm/XDSM.pyi +++ b/pyxdsm/XDSM.pyi @@ -1,4 +1,4 @@ -from typing import Iterator, NamedTuple, Literal +from typing import Iterator, NamedTuple, Literal, Sequence OPT: str SUBOPT: str @@ -90,3 +90,35 @@ class XDSM: label_width: int | None = ..., spec_name: str | None = ..., ) -> None: ... + def connect( + self, + src: str, + target: str, + label: str | list[str] | tuple[str, ...], + label_width: int | None = None, + style: str = "DataInter", + stack: bool = False, + faded: bool = False, + ) -> None: ... + def add_process( + self, + systems: Sequence[str], + arrow: bool = True, + faded: bool = False, + ) -> None: ... + # def _build_node_grid(self) -> str: ... + # def _build_edges(self) -> str: ... + # def _build_process_chain(self) -> str: ... + # def _compose_optional_package_list(self) -> str: ... + def write( + self, + file_name: str, + build: bool = True, + cleanup: bool = True, + quiet: bool = False, + outdir: str = ".", + ) -> None: ... + def write_sys_specs( + self, + folder_name: str, + ) -> None: ... From d19cb1343306fffea9eeb6af668717c966c940c2 Mon Sep 17 00:00:00 2001 From: Aidavdw <39270007+Aidavdw@users.noreply.github.com> Date: Thu, 26 Jun 2025 15:52:50 +0200 Subject: [PATCH 3/3] Add XDSM.add_input and XDSM.add_output to .pyi --- pyxdsm/XDSM.pyi | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pyxdsm/XDSM.pyi b/pyxdsm/XDSM.pyi index 4142cbd..c15c6a5 100644 --- a/pyxdsm/XDSM.pyi +++ b/pyxdsm/XDSM.pyi @@ -90,6 +90,25 @@ class XDSM: label_width: int | None = ..., spec_name: str | None = ..., ) -> None: ... + def add_input( + self, + name: str, + label: str | list[str] | tuple[str, ...], + label_width: int | None = None, + style: str = "DataIO", + stack: bool = False, + faded: bool = False, + ) -> None: ... + def add_output( + self, + name: str, + label: str | list[str] | tuple[str, ...], + label_width: int | None = None, + style: str = "DataIO", + stack: bool = False, + faded: bool = False, + side: Literal["left", "right"] = "left", + ) -> None: ... def connect( self, src: str,