From 9ced79f2c05cf3e6e1e79b2a9b827f69ff43e880 Mon Sep 17 00:00:00 2001 From: dance858 Date: Wed, 7 Oct 2026 15:54:35 +0200 Subject: [PATCH 1/2] Add make_atan binding for the engine's new atan atom Mirrors sin.h. Requires SparseDifferentiation/SparseDiffEngine#131, so the engine submodule pointer must be bumped once that lands on engine main. Co-Authored-By: Claude Fable 5.1 --- sparsediffpy/_bindings/atoms/atan.h | 31 +++++++++++++++++++++++++++++ sparsediffpy/_bindings/bindings.c | 2 ++ 2 files changed, 33 insertions(+) create mode 100644 sparsediffpy/_bindings/atoms/atan.h diff --git a/sparsediffpy/_bindings/atoms/atan.h b/sparsediffpy/_bindings/atoms/atan.h new file mode 100644 index 0000000..534acb2 --- /dev/null +++ b/sparsediffpy/_bindings/atoms/atan.h @@ -0,0 +1,31 @@ +#ifndef ATOM_ATAN_H +#define ATOM_ATAN_H + +#include "common.h" +#include "elementwise_full_dom.h" + +static PyObject *py_make_atan(PyObject *self, PyObject *args) +{ + PyObject *child_capsule; + if (!PyArg_ParseTuple(args, "O", &child_capsule)) + { + return NULL; + } + expr *child = (expr *) PyCapsule_GetPointer(child_capsule, EXPR_CAPSULE_NAME); + if (!child) + { + PyErr_SetString(PyExc_ValueError, "invalid child capsule"); + return NULL; + } + + expr *node = new_atan(child); + if (!node) + { + PyErr_SetString(PyExc_RuntimeError, "failed to create atan node"); + return NULL; + } + expr_retain(node); /* Capsule owns a reference */ + return PyCapsule_New(node, EXPR_CAPSULE_NAME, expr_capsule_destructor); +} + +#endif /* ATOM_ATAN_H */ diff --git a/sparsediffpy/_bindings/bindings.c b/sparsediffpy/_bindings/bindings.c index 4011d1c..3244d33 100644 --- a/sparsediffpy/_bindings/bindings.c +++ b/sparsediffpy/_bindings/bindings.c @@ -5,6 +5,7 @@ /* Include atom bindings */ #include "atoms/add.h" #include "atoms/asinh.h" +#include "atoms/atan.h" #include "atoms/atanh.h" #include "atoms/broadcast.h" #include "atoms/convolve.h" @@ -119,6 +120,7 @@ static PyMethodDef DNLPMethods[] = { {"make_sinh", py_make_sinh, METH_VARARGS, "Create sinh node"}, {"make_tanh", py_make_tanh, METH_VARARGS, "Create tanh node"}, {"make_asinh", py_make_asinh, METH_VARARGS, "Create asinh node"}, + {"make_atan", py_make_atan, METH_VARARGS, "Create atan node"}, {"make_atanh", py_make_atanh, METH_VARARGS, "Create atanh node"}, {"make_upper_tri", py_make_upper_tri, METH_VARARGS, "Create upper_tri node"}, {"make_broadcast", py_make_broadcast, METH_VARARGS, "Create broadcast node"}, From c7ed89106620c95ff55e796ea2f190a81798499f Mon Sep 17 00:00:00 2001 From: dance858 Date: Wed, 7 Oct 2026 16:20:32 +0200 Subject: [PATCH 2/2] Bump SparseDiffEngine to 1334e80 (atan atom, #131) Co-Authored-By: Claude Fable 5.1 --- SparseDiffEngine | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SparseDiffEngine b/SparseDiffEngine index 9ec1164..1334e80 160000 --- a/SparseDiffEngine +++ b/SparseDiffEngine @@ -1 +1 @@ -Subproject commit 9ec1164079db7abecc1051513d84ca4da65e87be +Subproject commit 1334e802a899f9e795aedc01cbf188810382b50c