Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d90a141

Browse files
committedNov 9, 2024·
Tries to add 3.12 support
1 parent 60d54c5 commit d90a141

File tree

3 files changed

+14
-29
lines changed

3 files changed

+14
-29
lines changed
 

‎diffcp/cone_program.py

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@
22
import warnings
33
from multiprocessing.pool import ThreadPool
44

5-
import ecos
6-
import clarabel
75
import numpy as np
86
import scipy.sparse as sparse
9-
import scs
107
from distutils.version import StrictVersion
118
from threadpoolctl import threadpool_limits
129

@@ -319,25 +316,17 @@ def solve_internal(A, b, c, cone_dict, solve_method=None,
319316
solve_method = "ECOS"
320317

321318
if solve_method == "SCS":
319+
import scs
322320

323-
# SCS versions SCS 2.*
324-
if StrictVersion(scs.__version__) < StrictVersion('3.0.0'):
325-
if "eps_abs" in kwargs or "eps_rel" in kwargs:
326-
# Take the min of eps_rel and eps_abs to be eps
327-
kwargs["eps"] = min(kwargs.get("eps_abs", 1),
328-
kwargs.get("eps_rel", 1))
329-
330-
# SCS version 3.*
331-
else:
332-
if "eps" in kwargs: # eps replaced by eps_abs, eps_rel
333-
kwargs["eps_abs"] = kwargs["eps"]
334-
kwargs["eps_rel"] = kwargs["eps"]
335-
del kwargs["eps"]
321+
if "eps" in kwargs: # eps replaced by eps_abs, eps_rel
322+
kwargs["eps_abs"] = kwargs["eps"]
323+
kwargs["eps_rel"] = kwargs["eps"]
324+
del kwargs["eps"]
336325

337326
data = {
338327
"A": A,
339328
"b": b,
340-
"c": c
329+
"c": c,
341330
}
342331

343332
if warm_start is not None:
@@ -367,6 +356,8 @@ def solve_internal(A, b, c, cone_dict, solve_method=None,
367356
return result
368357

369358
elif solve_method == "ECOS":
359+
import ecos
360+
370361
if warm_start is not None:
371362
raise ValueError('ECOS does not support warmstart.')
372363
if ('s' in cone_dict) and (cone_dict['s'] != []):
@@ -448,6 +439,7 @@ def solve_internal(A, b, c, cone_dict, solve_method=None,
448439
'iter': solution['info']['iter'],
449440
'pobj': solution['info']['pcost']}
450441
elif solve_method == "Clarabel":
442+
import clarabel
451443
# for now set P to 0
452444
P = sparse.csc_matrix((c.size, c.size))
453445

‎diffcp/cones.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
11
import numpy as np
22
import scipy.sparse as sparse
33
from _diffcp import project_exp_cone, Cone, ConeType
4-
from distutils.version import StrictVersion
5-
import scs
64

7-
if StrictVersion(scs.__version__) >= StrictVersion('3.0.0'):
8-
EQ_DIM = "z"
9-
else:
10-
EQ_DIM = "f"
11-
12-
ZERO = EQ_DIM
5+
ZERO = "z"
136
POS = "l"
147
SOC = "q"
158
PSD = "s"
@@ -21,7 +14,7 @@
2114

2215
# Map from Python cones to CPP format
2316
CONE_MAP = {
24-
EQ_DIM: ConeType.ZERO,
17+
"z": ConeType.ZERO,
2518
"l": ConeType.POS,
2619
"q": ConeType.SOC,
2720
"s": ConeType.PSD,

‎pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ requires-python = ">= 3.10"
77

88
readme = "README.md"
99

10-
requires = [
11-
"threadpoolctl >= 1.1"
10+
dependencies = [
11+
"threadpoolctl >= 1.1",
1212
]
1313
urls = {Homepage = "https://github.com/cvxgrp/diffcp/"}
1414
license = {text = "Apache License, Version 2.0"}
@@ -30,7 +30,7 @@ build-backend = "scikit_build_core.build"
3030
test = [
3131
"clarabel >= 0.5.1",
3232
"ecos >= 2.0.10",
33-
"scs >= 2.0.2",
33+
"scs >= 3.0.0",
3434
]
3535

3636
[tool.scikit-build]

0 commit comments

Comments
 (0)
Please sign in to comment.