Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

little adjustments for dependency management #11

Merged
merged 4 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions corneto/backend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,12 @@ def available_backends():
_picos_mip_solvers = ["gurobi", "cplex", "scip", "glpk"]


DEFAULT_BACKEND: Backend = (
available_backends()[0] if len(available_backends()) > 0 else NoBackend()
)
DEFAULT_BACKEND, = available_backends()[:1] or (NoBackend(),)
DEFAULT_SOLVER = None

if not DEFAULT_BACKEND:
s.LOGGER.warn(
"None of the supported backends found. You can install the default backend with `pip install cvxpy`."
)
s.LOGGER.warn(DEFAULT_BACKEND._error)

else:
if isinstance(DEFAULT_BACKEND, CvxpyBackend):
from cvxpy import installed_solvers
Expand Down
8 changes: 7 additions & 1 deletion corneto/backend/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1335,7 +1335,13 @@ def hstack(self, arg_list: Iterable[CExpression]) -> CExpression:

class NoBackend(Backend):
def __init__(self) -> None:
self._error = "No backend available. Please install on of the supported backends, e.g. `pip install cvxpy`."
self._error = (
"No backend found. You can install one of the "
"supported backend by `pip install cvxpy` or `pip install picos`."
)

def __bool__(self) -> bool:
return False

def _load(self):
return None
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ python = ">=3.9"
numpy = ">=1.25"
cvxpy-base = {version = "^1.5.0", optional = true}
scipy = {version = ">=1.11.0", optional = true}
picos = {version = "^2.4.1", optional = true}

[tool.poetry.group.dev.dependencies]
scipy = "^1.11.0"
Expand Down Expand Up @@ -59,6 +60,7 @@ pydocstyle = "^6.3.0"

[tool.poetry.extras]
highs = ["cvxpy-base"]
picos = ["picos"]
os = ["cvxpy-base", "scipy", "pyscipopt"]

[tool.ruff]
Expand Down