Skip to content

Commit

Permalink
Improve error message formatting in CasadiLike class and clean up whi…
Browse files Browse the repository at this point in the history
…tespace
  • Loading branch information
GiulioRomualdi committed Jan 9, 2025
1 parent 9ea1952 commit c024770
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/adam/casadi/casadi_like.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,13 @@ def reshape(self, *args) -> "CasadiLike":
"""
args = tuple(filter(None, args))
if len(args) > 2:
raise ValueError(f"Only 1D and 2D arrays are supported, The shape is {args}")
raise ValueError(
f"Only 1D and 2D arrays are supported, The shape is {args}"
)

# For 1D reshape, just call CasADi reshape directly
if len(args) == 1:
new_array = cs.reshape(self.array, args[0], 1)
new_array = cs.reshape(self.array, args[0], 1)
else:
# For 2D reshape, transpose before and after to mimic row-major behavior
new_array = cs.reshape(self.array.T, args[1], args[0]).T
Expand Down

0 comments on commit c024770

Please sign in to comment.