Skip to content

Commit 83a1448

Browse files
authored
Tries to add 3.12 support (#68)
* Tries to add 3.12 support * Fixes some imports
1 parent 60d54c5 commit 83a1448

File tree

3 files changed

+14
-30
lines changed

3 files changed

+14
-30
lines changed

diffcp/cone_program.py

+9-18
Original file line numberDiff line numberDiff line change
@@ -2,12 +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
10-
from distutils.version import StrictVersion
117
from threadpoolctl import threadpool_limits
128

139
import _diffcp
@@ -319,25 +315,17 @@ def solve_internal(A, b, c, cone_dict, solve_method=None,
319315
solve_method = "ECOS"
320316

321317
if solve_method == "SCS":
318+
import scs
322319

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"]
320+
if "eps" in kwargs: # eps replaced by eps_abs, eps_rel
321+
kwargs["eps_abs"] = kwargs["eps"]
322+
kwargs["eps_rel"] = kwargs["eps"]
323+
del kwargs["eps"]
336324

337325
data = {
338326
"A": A,
339327
"b": b,
340-
"c": c
328+
"c": c,
341329
}
342330

343331
if warm_start is not None:
@@ -367,6 +355,8 @@ def solve_internal(A, b, c, cone_dict, solve_method=None,
367355
return result
368356

369357
elif solve_method == "ECOS":
358+
import ecos
359+
370360
if warm_start is not None:
371361
raise ValueError('ECOS does not support warmstart.')
372362
if ('s' in cone_dict) and (cone_dict['s'] != []):
@@ -448,6 +438,7 @@ def solve_internal(A, b, c, cone_dict, solve_method=None,
448438
'iter': solution['info']['iter'],
449439
'pobj': solution['info']['pcost']}
450440
elif solve_method == "Clarabel":
441+
import clarabel
451442
# for now set P to 0
452443
P = sparse.csc_matrix((c.size, c.size))
453444

diffcp/cones.py

+2-9
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

+3-3
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)