-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add type stubs for IDE autocomplete and type checking #13
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,272 @@ | ||||||
| """Type stubs for cfd_python C extension module.""" | ||||||
|
|
||||||
| from typing import Any | ||||||
|
|
||||||
| __version__: str | ||||||
| __all__: list[str] | ||||||
|
|
||||||
| # Output type constants | ||||||
| OUTPUT_PRESSURE: int | ||||||
| OUTPUT_VELOCITY: int | ||||||
| OUTPUT_FULL_FIELD: int | ||||||
| OUTPUT_CSV_TIMESERIES: int | ||||||
| OUTPUT_CSV_CENTERLINE: int | ||||||
| OUTPUT_CSV_STATISTICS: int | ||||||
|
|
||||||
| # Dynamic solver constants (generated from C library registry) | ||||||
| # Common solvers - actual availability depends on library build | ||||||
| SOLVER_EXPLICIT_EULER: str | ||||||
| SOLVER_EXPLICIT_EULER_OPTIMIZED: str | ||||||
| SOLVER_PROJECTION: str | ||||||
| SOLVER_PROJECTION_OPTIMIZED: str | ||||||
| SOLVER_EXPLICIT_EULER_GPU: str | ||||||
| SOLVER_PROJECTION_JACOBI_GPU: str | ||||||
|
|
||||||
| # Simulation functions | ||||||
| def run_simulation( | ||||||
| nx: int, | ||||||
| ny: int, | ||||||
| steps: int = 100, | ||||||
| xmin: float = 0.0, | ||||||
| xmax: float = 1.0, | ||||||
| ymin: float = 0.0, | ||||||
| ymax: float = 1.0, | ||||||
| solver_type: str | None = None, | ||||||
| output_file: str | None = None, | ||||||
| ) -> list[float]: | ||||||
| """Run a complete simulation with default parameters. | ||||||
|
|
||||||
| Args: | ||||||
| nx: Grid dimension in x direction | ||||||
| ny: Grid dimension in y direction | ||||||
| steps: Number of time steps (default: 100) | ||||||
| xmin: Minimum x coordinate (default: 0.0) | ||||||
| xmax: Maximum x coordinate (default: 1.0) | ||||||
| ymin: Minimum y coordinate (default: 0.0) | ||||||
| ymax: Maximum y coordinate (default: 1.0) | ||||||
| solver_type: Solver name string (optional, uses library default) | ||||||
| output_file: VTK output file path (optional) | ||||||
|
|
||||||
| Returns: | ||||||
| List of velocity magnitude values (size nx*ny) | ||||||
| """ | ||||||
| ... | ||||||
|
|
||||||
| def run_simulation_with_params( | ||||||
| nx: int, | ||||||
| ny: int, | ||||||
| xmin: float, | ||||||
| xmax: float, | ||||||
| ymin: float, | ||||||
| ymax: float, | ||||||
| steps: int = 1, | ||||||
| dt: float = 0.001, | ||||||
| cfl: float = 0.2, | ||||||
| solver_type: str | None = None, | ||||||
| output_file: str | None = None, | ||||||
| ) -> dict[str, Any]: | ||||||
| """Run simulation with custom parameters and solver selection. | ||||||
|
|
||||||
| Args: | ||||||
| nx: Grid dimension in x direction | ||||||
| ny: Grid dimension in y direction | ||||||
| xmin: Minimum x coordinate | ||||||
| xmax: Maximum x coordinate | ||||||
| ymin: Minimum y coordinate | ||||||
| ymax: Maximum y coordinate | ||||||
| steps: Number of time steps (default: 1) | ||||||
| dt: Time step size (default: 0.001) | ||||||
| cfl: CFL number (default: 0.2) | ||||||
| solver_type: Solver name string (optional, uses library default) | ||||||
| output_file: VTK output file path (optional) | ||||||
|
|
||||||
| Returns: | ||||||
| Dictionary with keys: | ||||||
| - velocity_magnitude: list[float] | ||||||
| - nx: int | ||||||
| - ny: int | ||||||
| - steps: int | ||||||
| - solver_name: str | ||||||
| - solver_description: str | ||||||
| - stats: dict[str, Any] | ||||||
| """ | ||||||
| ... | ||||||
|
|
||||||
| def create_grid( | ||||||
| nx: int, | ||||||
| ny: int, | ||||||
| xmin: float, | ||||||
| xmax: float, | ||||||
| ymin: float, | ||||||
| ymax: float, | ||||||
| ) -> dict[str, Any]: | ||||||
| """Create a computational grid. | ||||||
|
|
||||||
| Args: | ||||||
| nx: Grid dimension in x direction | ||||||
| ny: Grid dimension in y direction | ||||||
| xmin: Minimum x coordinate | ||||||
| xmax: Maximum x coordinate | ||||||
| ymin: Minimum y coordinate | ||||||
| ymax: Maximum y coordinate | ||||||
|
|
||||||
| Returns: | ||||||
| Dictionary with keys: | ||||||
| - nx: int | ||||||
| - ny: int | ||||||
| - xmin: float | ||||||
| - xmax: float | ||||||
| - ymin: float | ||||||
| - ymax: float | ||||||
| - x_coords: list[float] | ||||||
| - y_coords: list[float] | ||||||
| """ | ||||||
| ... | ||||||
|
|
||||||
| def get_default_solver_params() -> dict[str, float]: | ||||||
|
||||||
| def get_default_solver_params() -> dict[str, float]: | |
| def get_default_solver_params() -> dict[str, float | int]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docstring for
run_simulation_with_paramsis incomplete. It's missing two keys that are included in the returned dictionary:output_file(str): Added when theoutput_fileparameter is provided (see src/cfd_python.c:497-501 and tests/test_simulation.py:162)elapsed_time_ms(float): Always included in thestatssubdictionary (see src/cfd_python.c:481)The docstring should document these additional return values to provide accurate type information.