-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pickling is only supported for SX symbolic variables Unfortunately, it requires a minor "hack" of the struct_SX class from the casadi.tools package. There is a bug which hopefully gets resolved in the future. Pickling is included in unit testing.
- Loading branch information
Felix-Mac
committed
Aug 19, 2022
1 parent
250605d
commit 1195360
Showing
6 changed files
with
140 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from casadi import * | ||
from casadi.tools import * | ||
|
||
class _struct_SX(struct_SX): | ||
"""Updated structure class for CasADi structures (SX). This class fixes a bug that prevents unpickeling of the structure.""" | ||
def __init__(self, *args, **kwargs): | ||
kwargs.pop('order', None) | ||
super().__init__(*args, **kwargs) | ||
|
||
class _struct_MX(struct_MX): | ||
def __init__(self, *args, **kwargs): | ||
kwargs.pop('order', None) | ||
super().__init__(*args, **kwargs) | ||
|
||
class _SymVar: | ||
def __init__(self, symvar_type): | ||
assert symvar_type in ['SX', 'MX'], 'symvar_type must be either SX or MX, you have: {}'.format(symvar_type) | ||
|
||
if symvar_type == 'MX': | ||
self.sym = MX.sym | ||
self.struct = _struct_MX | ||
self.sym_struct = struct_symMX | ||
self.dtype = MX | ||
if symvar_type == 'SX': | ||
self.sym = SX.sym | ||
self.struct = _struct_SX | ||
self.sym_struct = struct_symSX | ||
self.dtype = SX |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters