Commit c681f94
* Refactor _VarArray initialization and type checks
Simplifies and clarifies the logic for initializing _VarArray by restructuring type checks and error handling. Now uses f-strings for error messages and ensures consistent handling of empty lists and invalid types.
* Refactor _VarArray to support MatrixVariable input
Updated the _VarArray class constructor to handle MatrixVariable inputs in addition to Variable, list, and tuple. Refactored pointer allocation logic into a helper function for improved code clarity and maintainability.
* Add test for indicator constraint with matrix binary var
Introduces a new test to verify that addConsIndicator works correctly when the binary variable is a matrix variable, addressing issue #1043.
* Update CHANGELOG.md
* Declare ptr variable in create_ptr function
To fix "Storing unsafe C derivative of temporary Python reference"
* Refactor create_ptr to remove redundant size argument
The create_ptr function in _VarArray.__cinit__ no longer takes a separate size argument and instead uses len(vars) directly. This simplifies the function signature and reduces redundancy.
* Refactor _VarArray initialization logic
Inlined the pointer creation logic in _VarArray's __cinit__ method, removing the inner create_ptr function. This simplifies the code and improves readability while maintaining the same functionality.
* Update CHANGELOG
* Update test for addConsIndicator with activeone flag
The test now checks addConsIndicator with both activeone=True and activeone=False, and updates the objective to use binvar.sum().
* ENH: flatten list
* BUG: use `np.ravel` avoid to run out of vars range
* test binvar with (1, 1, 1) matrix
* test binvar with (2, 3) matrix
* test binvar with (2, 1) list of lists
* correct index
* Add TypeError test for addConsIndicator with binvar
* Only requiring a 1D array
* TST: raise an error while get not 1D array
* MAINT: Update error message
* TST: update error type
* Update CHANGELOG.md
* Fix _VarArray initialization for empty input
Ensures _VarArray initializes ptr and size to NULL and 0, respectively, before processing input. Prevents allocation and assignment errors when an empty or invalid input is provided.
* Remove _VarArray changing from changelog
* TST: update the comparing method
Co-authored-by: DominikKamp <130753997+DominikKamp@users.noreply.github.com>
---------
Co-authored-by: João Dionísio <57299939+Joao-Dionisio@users.noreply.github.com>
Co-authored-by: DominikKamp <130753997+DominikKamp@users.noreply.github.com>
1 parent a3c2a48 commit c681f94
2 files changed
+46
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2498 | 2498 | | |
2499 | 2499 | | |
2500 | 2500 | | |
| 2501 | + | |
| 2502 | + | |
| 2503 | + | |
2501 | 2504 | | |
2502 | | - | |
2503 | | - | |
2504 | | - | |
| 2505 | + | |
| 2506 | + | |
| 2507 | + | |
| 2508 | + | |
2505 | 2509 | | |
2506 | | - | |
2507 | | - | |
| 2510 | + | |
| 2511 | + | |
| 2512 | + | |
2508 | 2513 | | |
2509 | | - | |
2510 | | - | |
2511 | | - | |
2512 | | - | |
2513 | | - | |
2514 | | - | |
2515 | | - | |
2516 | | - | |
| 2514 | + | |
| 2515 | + | |
| 2516 | + | |
| 2517 | + | |
| 2518 | + | |
2517 | 2519 | | |
2518 | 2520 | | |
2519 | 2521 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
179 | 179 | | |
180 | 180 | | |
181 | 181 | | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
182 | 213 | | |
183 | 214 | | |
184 | 215 | | |
| |||
0 commit comments