Skip to content

Commit 643fd2a

Browse files
committed
run formatting and add venv to gitignore
1 parent dad7950 commit 643fd2a

7 files changed

Lines changed: 33 additions & 23 deletions

File tree

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,7 @@ out/
7272
*.swp
7373
*.swo
7474
*~
75-
.DS_Store
75+
.DS_Store
76+
77+
.venv/
78+
__pycache__/

python/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

python/atoms/constant.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ static PyObject *py_make_constant(PyObject *self, PyObject *args)
1212
return NULL;
1313
}
1414

15-
PyArrayObject *values_array =
16-
(PyArrayObject *) PyArray_FROM_OTF(values_obj, NPY_DOUBLE, NPY_ARRAY_IN_ARRAY);
15+
PyArrayObject *values_array = (PyArrayObject *) PyArray_FROM_OTF(
16+
values_obj, NPY_DOUBLE, NPY_ARRAY_IN_ARRAY);
1717
if (!values_array)
1818
{
1919
return NULL;

python/atoms/linear.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ static PyObject *py_make_linear(PyObject *self, PyObject *args)
2323

2424
PyArrayObject *data_array =
2525
(PyArrayObject *) PyArray_FROM_OTF(data_obj, NPY_DOUBLE, NPY_ARRAY_IN_ARRAY);
26-
PyArrayObject *indices_array =
27-
(PyArrayObject *) PyArray_FROM_OTF(indices_obj, NPY_INT32, NPY_ARRAY_IN_ARRAY);
28-
PyArrayObject *indptr_array =
29-
(PyArrayObject *) PyArray_FROM_OTF(indptr_obj, NPY_INT32, NPY_ARRAY_IN_ARRAY);
26+
PyArrayObject *indices_array = (PyArrayObject *) PyArray_FROM_OTF(
27+
indices_obj, NPY_INT32, NPY_ARRAY_IN_ARRAY);
28+
PyArrayObject *indptr_array = (PyArrayObject *) PyArray_FROM_OTF(
29+
indptr_obj, NPY_INT32, NPY_ARRAY_IN_ARRAY);
3030

3131
if (!data_array || !indices_array || !indptr_array)
3232
{

python/bindings.c

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,23 @@
33
#include <numpy/arrayobject.h>
44

55
/* Include atom bindings */
6-
#include "atoms/variable.h"
6+
#include "atoms/add.h"
77
#include "atoms/constant.h"
8+
#include "atoms/exp.h"
89
#include "atoms/linear.h"
910
#include "atoms/log.h"
10-
#include "atoms/exp.h"
11-
#include "atoms/add.h"
12-
#include "atoms/sum.h"
1311
#include "atoms/neg.h"
1412
#include "atoms/promote.h"
13+
#include "atoms/sum.h"
14+
#include "atoms/variable.h"
1515

1616
/* Include problem bindings */
17-
#include "problem/make_problem.h"
18-
#include "problem/init_derivatives.h"
19-
#include "problem/objective_forward.h"
2017
#include "problem/constraint_forward.h"
2118
#include "problem/gradient.h"
19+
#include "problem/init_derivatives.h"
2220
#include "problem/jacobian.h"
21+
#include "problem/make_problem.h"
22+
#include "problem/objective_forward.h"
2323

2424
static int numpy_initialized = 0;
2525

@@ -41,12 +41,18 @@ static PyMethodDef DNLPMethods[] = {
4141
{"make_sum", py_make_sum, METH_VARARGS, "Create sum node"},
4242
{"make_neg", py_make_neg, METH_VARARGS, "Create neg node"},
4343
{"make_promote", py_make_promote, METH_VARARGS, "Create promote node"},
44-
{"make_problem", py_make_problem, METH_VARARGS, "Create problem from objective and constraints"},
45-
{"problem_init_derivatives", py_problem_init_derivatives, METH_VARARGS, "Initialize derivative structures"},
46-
{"problem_objective_forward", py_problem_objective_forward, METH_VARARGS, "Evaluate objective only"},
47-
{"problem_constraint_forward", py_problem_constraint_forward, METH_VARARGS, "Evaluate constraints only"},
48-
{"problem_gradient", py_problem_gradient, METH_VARARGS, "Compute objective gradient"},
49-
{"problem_jacobian", py_problem_jacobian, METH_VARARGS, "Compute constraint jacobian"},
44+
{"make_problem", py_make_problem, METH_VARARGS,
45+
"Create problem from objective and constraints"},
46+
{"problem_init_derivatives", py_problem_init_derivatives, METH_VARARGS,
47+
"Initialize derivative structures"},
48+
{"problem_objective_forward", py_problem_objective_forward, METH_VARARGS,
49+
"Evaluate objective only"},
50+
{"problem_constraint_forward", py_problem_constraint_forward, METH_VARARGS,
51+
"Evaluate constraints only"},
52+
{"problem_gradient", py_problem_gradient, METH_VARARGS,
53+
"Compute objective gradient"},
54+
{"problem_jacobian", py_problem_jacobian, METH_VARARGS,
55+
"Compute constraint jacobian"},
5056
{NULL, NULL, 0, NULL}};
5157

5258
static struct PyModuleDef dnlp_module = {PyModuleDef_HEAD_INIT, "DNLP_diff_engine",

python/problem/gradient.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ static PyObject *py_problem_gradient(PyObject *self, PyObject *args)
2727
{
2828
return NULL;
2929
}
30-
memcpy(PyArray_DATA((PyArrayObject *) out), prob->gradient_values, size * sizeof(double));
30+
memcpy(PyArray_DATA((PyArrayObject *) out), prob->gradient_values,
31+
size * sizeof(double));
3132

3233
return out;
3334
}

python/problem/objective_forward.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ static PyObject *py_problem_objective_forward(PyObject *self, PyObject *args)
2727
return NULL;
2828
}
2929

30-
double obj_val = problem_objective_forward(prob, (const double *) PyArray_DATA(u_array));
30+
double obj_val =
31+
problem_objective_forward(prob, (const double *) PyArray_DATA(u_array));
3132

3233
Py_DECREF(u_array);
3334
return Py_BuildValue("d", obj_val);

0 commit comments

Comments
 (0)