Skip to content

Commit 3c44fae

Browse files
authored
MAINT: Cleanup with pythoncapi-compat (#132)
* MAINT: Name submodules as per path * MAINT: Add in pythoncapi-compat as a submodule * ENH: Update scsobject.h with pythoncapi-compat Specifically python scs/pythoncapi-compat/upgrade_pythoncapi.py scs/scsobject.h * MAINT: Add in trove classifiers
1 parent 1ee7165 commit 3c44fae

File tree

4 files changed

+29
-8
lines changed

4 files changed

+29
-8
lines changed

.gitmodules

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1-
[submodule "scs"]
1+
[submodule "scs_source"]
22
path = scs_source
33
url = https://github.com/cvxgrp/scs.git
4+
[submodule "scs/pythoncapi-compat"]
5+
path = scs/pythoncapi-compat
6+
url = https://github.com/python/pythoncapi-compat

pyproject.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,21 @@ version = "3.2.7"
1111
description = 'Splitting conic solver'
1212
readme = 'README.md'
1313
requires-python = '>=3.9'
14+
classifiers = [
15+
'License :: OSI Approved :: MIT License',
16+
'Programming Language :: C',
17+
'Programming Language :: Python',
18+
'Programming Language :: Python :: 3',
19+
'Programming Language :: Python :: 3.11',
20+
'Programming Language :: Python :: 3.12',
21+
'Programming Language :: Python :: 3.13',
22+
'Programming Language :: Python :: 3 :: Only',
23+
'Programming Language :: Python :: Implementation :: CPython',
24+
'Operating System :: Microsoft :: Windows',
25+
'Operating System :: POSIX',
26+
'Operating System :: Unix',
27+
'Operating System :: MacOS',
28+
]
1429
license = {file = 'LICENSE'}
1530
authors = [
1631
{name = "Brendan O'Donoghue", email = "[email protected]"}]

scs/pythoncapi-compat

Submodule pythoncapi-compat added at fde4d34

scs/scsobject.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#include "pythoncapi-compat/pythoncapi_compat.h"
2+
13
#ifndef PY_SCSOBJECT_H
24
#define PY_SCSOBJECT_H
35

@@ -398,7 +400,7 @@ static int SCS_init(SCS *self, PyObject *args, PyObject *kwargs) {
398400
d->A = A;
399401

400402
/* set P if passed in */
401-
if ((void *)Px != Py_None && (void *)Pi != Py_None && (void *)Pp != Py_None) {
403+
if ((void *)!Py_IsNone(Px) && (void *)!Py_IsNone(Pi) && (void *)!Py_IsNone(Pp)) {
402404
if (!PyArray_ISFLOAT(Px) || PyArray_NDIM(Px) != 1) {
403405
free_py_scs_data(d, k, stgs, &ps);
404406
return finish_with_error("Px must be a numpy array of floats");
@@ -605,17 +607,17 @@ static PyObject *SCS_solve(SCS *self, PyObject *args) {
605607

606608
if (_warm_start) {
607609
/* If any of these of missing, we use the values in sol */
608-
if ((void *)warm_x != Py_None) {
610+
if ((void *)!Py_IsNone(warm_x)) {
609611
if (get_warm_start(self->sol->x, self->n, warm_x) < 0) {
610612
return none_with_error("Unable to parse x warm-start");
611613
}
612614
}
613-
if ((void *)warm_y != Py_None) {
615+
if ((void *)!Py_IsNone(warm_y)) {
614616
if (get_warm_start(self->sol->y, self->m, warm_y) < 0) {
615617
return none_with_error("Unable to parse y warm-start");
616618
}
617619
}
618-
if ((void *)warm_s != Py_None) {
620+
if ((void *)!Py_IsNone(warm_s)) {
619621
if (get_warm_start(self->sol->s, self->m, warm_s) < 0) {
620622
return none_with_error("Unable to parse s warm-start");
621623
}
@@ -727,7 +729,7 @@ PyObject *SCS_update(SCS *self, PyObject *args) {
727729
return none_with_error("Error parsing inputs");
728730
}
729731
/* set c */
730-
if ((void *)c_new != Py_None) {
732+
if ((void *)!Py_IsNone(c_new)) {
731733
if (!PyArray_ISFLOAT(c_new) || PyArray_NDIM(c_new) != 1) {
732734
return none_with_error(
733735
"c_new must be a dense numpy array with one dimension");
@@ -739,7 +741,7 @@ PyObject *SCS_update(SCS *self, PyObject *args) {
739741
c = (scs_float *)PyArray_DATA(c_new);
740742
}
741743
/* set b */
742-
if ((void *)b_new != Py_None) {
744+
if ((void *)!Py_IsNone(b_new)) {
743745
if (!PyArray_ISFLOAT(b_new) || PyArray_NDIM(b_new) != 1) {
744746
return none_with_error(
745747
"b must be a dense numpy array with one dimension");
@@ -776,7 +778,7 @@ static scs_int SCS_finish(SCS *self) {
776778
}
777779

778780
/* Del python object */
779-
PyObject_Del(self);
781+
PyObject_Free(self);
780782

781783
return 0;
782784
}

0 commit comments

Comments
 (0)