Skip to content

Commit

Permalink
Version 1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim-Salzmann committed Nov 30, 2023
1 parent 53e8340 commit 50dd18b
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
python-version: '>=3.9 <3.12'
- name: Install pypa/build
run: >-
python3 -m
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-to-test-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
python-version: '>=3.9 <3.12'
- name: Install pypa/build
run: >-
python3 -m
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
![L4CasADi CI](https://github.com/Tim-Salzmann/l4casadi/actions/workflows/ci.yaml/badge.svg)
![Downloads](https://img.shields.io/pypi/dm/l4casadi.svg)

**Due to a bug, Hessians for functions with non-scalar outputs were wrong prior to version 1.3.0*

---
# Learning 4 CasADi Framework

Expand Down
7 changes: 6 additions & 1 deletion l4casadi/l4casadi.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ def _load_built_library_as_external_cs_fun(self):

def _generate_cpp_function_template(self, rows: int, cols: int, has_jac: bool, has_hess: bool):
if self.has_batch:
rows_out = self.model(torch.zeros(1, rows).to(self.device)).shape[-1]
out_shape = self.model(torch.zeros(1, rows).to(self.device)).shape
rows_out = out_shape[-1]
cols_out = 1
else:
out_shape = self.model(torch.zeros(rows, cols).to(self.device)).shape
Expand All @@ -153,6 +154,10 @@ def _generate_cpp_function_template(self, rows: int, cols: int, has_jac: bool, h
cols_out = 1
else:
rows_out, cols_out = out_shape[-2:]
if len(out_shape) != 2:
raise ValueError(f"""L4CasADi requires the model output to be a matrix (2 dimensions) but has
{len(out_shape)} dimensions. For models which expects a batch dimension,
the output should be a matrix of [1, d].""")

model_path = (self.build_dir.absolute().as_posix()
if self._model_search_path is None
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "l4casadi"
version = "1.2.0"
version = "1.3.0"
authors = [
{ name="Tim Salzmann", email="Tim.Salzmann@tum.de" },
]
Expand Down

0 comments on commit 50dd18b

Please sign in to comment.