Skip to content

Commit

Permalink
Test ipopt with tcc manually
Browse files Browse the repository at this point in the history
  • Loading branch information
metab0t committed Nov 23, 2024
1 parent 0932875 commit 25752da
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/linux-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ jobs:
- name: Test
run: |
python -m pytest tests -v
python tests/test_nlp.py
python tests/test_nlp_rocket.py
python tests/test_nlp_multiple_run.py
- name: Upload artifact
uses: actions/upload-artifact@v4
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/macos-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ jobs:
python -c "import pyoptinterface as poi; print(dir(poi))"
python -m pip wheel -w dist --no-build-isolation .
- name: Test
run: |
python -m pytest tests -k "highs or ipopt" -v
python tests/test_nlp.py
python tests/test_nlp_rocket.py
python tests/test_nlp_multiple_run.py
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
Expand Down
16 changes: 11 additions & 5 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest
import platform

model_interface_dict = {}

Expand Down Expand Up @@ -36,14 +37,19 @@ def model_interface(request):

if ipopt.is_library_loaded():

def f():
def llvm():
return ipopt.Model(jit="LLVM")

def c():
return ipopt.Model(jit="C")

def g():
return ipopt.Model(jit="LLVM")
ipopt_model_dict["ipopt_llvm"] = llvm

system = platform.system()

ipopt_model_dict["ipopt_c"] = f
ipopt_model_dict["ipopt_llvm"] = g
# pytest with tcc jit does not work on Linux and mac
if system == "Windows":
ipopt_model_dict["ipopt_c"] = c


@pytest.fixture(params=ipopt_model_dict.keys())
Expand Down
9 changes: 9 additions & 0 deletions tests/test_nlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,17 @@ def con(vars):


if __name__ == "__main__":

def c():
return ipopt.Model(jit="C")

test_ipopt(c)
test_nlp_param(c)
test_nlfunc_ifelse(c)

def llvm():
return ipopt.Model(jit="LLVM")

test_ipopt(llvm)
test_nlp_param(llvm)
test_nlfunc_ifelse(llvm)
13 changes: 13 additions & 0 deletions tests/test_nlp_multiple_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,16 @@ def con2(vars):
model.optimize()

assert model.get_value(z) == pytest.approx(4.0)


if __name__ == "__main__":

def c():
return ipopt.Model(jit="C")

test_nlp_reopt(c)

def llvm():
return ipopt.Model(jit="LLVM")

test_nlp_reopt(llvm)
11 changes: 10 additions & 1 deletion tests/test_nlp_rocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,13 @@ def test_rocket(ipopt_model_ctor):


if __name__ == "__main__":
test_rocket(ipopt.Model)

def c():
return ipopt.Model(jit="C")

test_rocket(c)

def llvm():
return ipopt.Model(jit="LLVM")

test_rocket(llvm)

0 comments on commit 25752da

Please sign in to comment.