|
| 1 | +from pathlib import Path |
1 | 2 | from typing import Callable, Any, Literal, Sequence |
2 | 3 | import json |
3 | 4 | import casadi as cas |
4 | 5 | import aerosandbox.numpy as np |
5 | 6 | from aerosandbox.tools import inspect_tools |
6 | 7 | from sortedcontainers import SortedDict |
7 | 8 | import copy |
| 9 | +from aerosandbox.numpy.typing import ArrayLike |
8 | 10 |
|
9 | 11 |
|
10 | 12 | class Opti(cas.Opti): |
@@ -71,14 +73,14 @@ def __init__( |
71 | 73 |
|
72 | 74 | def variable( |
73 | 75 | self, |
74 | | - init_guess: float | np.ndarray | None = None, |
75 | | - n_vars: int = None, |
76 | | - scale: float = None, |
| 76 | + init_guess: float | int | np.ndarray | None = None, |
| 77 | + n_vars: int | None = None, |
| 78 | + scale: float | int | np.ndarray | None = None, |
77 | 79 | freeze: bool = False, |
78 | 80 | log_transform: bool = False, |
79 | 81 | category: str = "Uncategorized", |
80 | | - lower_bound: float = None, |
81 | | - upper_bound: float = None, |
| 82 | + lower_bound: float | int | np.ndarray | None = None, |
| 83 | + upper_bound: float | int | np.ndarray | None = None, |
82 | 84 | _stacklevel: int = 1, |
83 | 85 | ) -> cas.MX | float | np.ndarray: |
84 | 86 | """ |
@@ -369,7 +371,7 @@ def subject_to( |
369 | 371 | self, |
370 | 372 | constraint: cas.MX | bool | list, # TODO add scale |
371 | 373 | _stacklevel: int = 1, |
372 | | - ) -> cas.MX | None | list[cas.MX]: |
| 374 | + ) -> cas.MX | None | list[cas.MX | None]: |
373 | 375 | """ |
374 | 376 | Initialize a new equality or inequality constraint(s). |
375 | 377 |
|
@@ -1007,7 +1009,7 @@ def derivative_of( |
1007 | 1009 | method: str = "trapezoidal", |
1008 | 1010 | explicit: bool = False, # TODO implement explicit |
1009 | 1011 | _stacklevel: int = 1, |
1010 | | - ) -> cas.MX: |
| 1012 | + ) -> cas.MX | float | np.ndarray: |
1011 | 1013 | """ |
1012 | 1014 | Returns a quantity that is either defined or constrained to be a derivative of an existing variable. |
1013 | 1015 |
|
@@ -1138,9 +1140,9 @@ def derivative_of( |
1138 | 1140 |
|
1139 | 1141 | def constrain_derivative( |
1140 | 1142 | self, |
1141 | | - derivative: cas.MX, |
1142 | | - variable: cas.MX, |
1143 | | - with_respect_to: np.ndarray | cas.MX, |
| 1143 | + derivative: ArrayLike, |
| 1144 | + variable: ArrayLike, |
| 1145 | + with_respect_to: ArrayLike, |
1144 | 1146 | method: str = "trapezoidal", |
1145 | 1147 | _stacklevel: int = 1, |
1146 | 1148 | ) -> cas.MX | None | list[cas.MX]: |
|
0 commit comments