From 286d4c147b0faf12a2a5e89e582fe6324d244a74 Mon Sep 17 00:00:00 2001 From: oclyke Date: Tue, 28 Nov 2023 22:31:38 -0800 Subject: [PATCH] format --- src/submodules/functional/color.c | 4 ++-- src/submodules/functional/module.c | 2 +- src/submodules/functional/operations.c | 26 +++++++++++++++----------- src/types/color_sequence/type.c | 6 +++--- tests/test_color_sequence.py | 3 +++ tests/test_compositor.py | 1 + 6 files changed, 25 insertions(+), 17 deletions(-) diff --git a/src/submodules/functional/color.c b/src/submodules/functional/color.c index d290551..352f021 100644 --- a/src/submodules/functional/color.c +++ b/src/submodules/functional/color.c @@ -1,8 +1,8 @@ #define PY_SSIZE_T_CLEAN -#include - #include "sicgl/color.h" +#include + PyObject* color_to_rgba(PyObject* self, PyObject* args) { (void)self; PyObject* obj; diff --git a/src/submodules/functional/module.c b/src/submodules/functional/module.c index 44c7196..deec576 100644 --- a/src/submodules/functional/module.c +++ b/src/submodules/functional/module.c @@ -1,8 +1,8 @@ #define PY_SSIZE_T_CLEAN #include -#include "pysicgl/submodules/functional/color_correction.h" #include "pysicgl/submodules/functional/color.h" +#include "pysicgl/submodules/functional/color_correction.h" #include "pysicgl/submodules/functional/drawing/global.h" #include "pysicgl/submodules/functional/drawing/interface.h" #include "pysicgl/submodules/functional/drawing/screen.h" diff --git a/src/submodules/functional/operations.c b/src/submodules/functional/operations.c index 692ca47..ea5fe45 100644 --- a/src/submodules/functional/operations.c +++ b/src/submodules/functional/operations.c @@ -39,13 +39,14 @@ PyObject* scalar_field(PyObject* self_in, PyObject* args, PyObject* kwds) { ColorSequenceInterpolatorObject* interpolator_obj; double offset = 0.0; char* keywords[] = { - "interface", "field", "scalars", "color_sequence", "interpolator", "offset", NULL, + "interface", "field", "scalars", "color_sequence", + "interpolator", "offset", NULL, }; if (!PyArg_ParseTupleAndKeywords( - args, kwds, "O!O!O!O!O!|d", keywords, &InterfaceType, &interface_obj, &ScreenType, &field_obj, - &ScalarFieldType, &scalar_field_obj, &ColorSequenceType, - &color_sequence_obj, &ColorSequenceInterpolatorType, - &interpolator_obj, &offset)) { + args, kwds, "O!O!O!O!O!|d", keywords, &InterfaceType, &interface_obj, + &ScreenType, &field_obj, &ScalarFieldType, &scalar_field_obj, + &ColorSequenceType, &color_sequence_obj, + &ColorSequenceInterpolatorType, &interpolator_obj, &offset)) { return NULL; } @@ -68,8 +69,8 @@ PyObject* scalar_field(PyObject* self_in, PyObject* args, PyObject* kwds) { } ret = sicgl_scalar_field( - &interface_obj->interface, field_obj->screen, scalar_field_obj->scalars, offset, - &color_sequence_obj->_sequence, interpolator_obj->fn); + &interface_obj->interface, field_obj->screen, scalar_field_obj->scalars, + offset, &color_sequence_obj->_sequence, interpolator_obj->fn); if (0 != ret) { PyErr_SetNone(PyExc_OSError); return NULL; @@ -90,8 +91,8 @@ PyObject* compose(PyObject* self_in, PyObject* args) { Py_buffer sprite; CompositorObject* compositor; if (!PyArg_ParseTuple( - args, "O!O!y*O!", &InterfaceType, &interface_obj, &ScreenType, &screen, &sprite, &CompositorType, - &compositor)) { + args, "O!O!y*O!", &InterfaceType, &interface_obj, &ScreenType, + &screen, &sprite, &CompositorType, &compositor)) { return NULL; } @@ -112,7 +113,9 @@ PyObject* blit(PyObject* self_in, PyObject* args) { InterfaceObject* interface_obj; ScreenObject* screen; Py_buffer sprite; - if (!PyArg_ParseTuple(args, "O!O!y*", &InterfaceType, &interface_obj, &ScreenType, &screen, &sprite)) { + if (!PyArg_ParseTuple( + args, "O!O!y*", &InterfaceType, &interface_obj, &ScreenType, &screen, + &sprite)) { return NULL; } @@ -133,7 +136,8 @@ PyObject* scale(PyObject* self_in, PyObject* args) { (void)self_in; InterfaceObject* interface_obj; double fraction; - if (!PyArg_ParseTuple(args, "O!d", &InterfaceType, &interface_obj, &fraction)) { + if (!PyArg_ParseTuple( + args, "O!d", &InterfaceType, &interface_obj, &fraction)) { return NULL; } color_t* memory = interface_obj->interface.memory; diff --git a/src/types/color_sequence/type.c b/src/types/color_sequence/type.c index 8446ede..d1d5376 100644 --- a/src/types/color_sequence/type.c +++ b/src/types/color_sequence/type.c @@ -187,7 +187,8 @@ static PyObject* tp_iter(PyObject* self_in) { static PyObject* tp_iternext(PyObject* self_in) { ColorSequenceObject* self = (ColorSequenceObject*)self_in; if (self->iterator_index < self->_sequence.length) { - PyObject* item = PyLong_FromLong(self->_sequence.colors[self->iterator_index]); + PyObject* item = + PyLong_FromLong(self->_sequence.colors[self->iterator_index]); self->iterator_index++; return item; } else { @@ -241,8 +242,7 @@ static int tp_init(PyObject* self_in, PyObject* args, PyObject* kwds) { } static PyMethodDef tp_methods[] = { - {"interpolate", (PyCFunction)interpolate, - METH_VARARGS | METH_KEYWORDS, + {"interpolate", (PyCFunction)interpolate, METH_VARARGS | METH_KEYWORDS, "interpolate the color sequence at one or more points using the given " "interpolation type"}, {NULL}, diff --git a/tests/test_color_sequence.py b/tests/test_color_sequence.py index 973aeaa..2cf5d8d 100644 --- a/tests/test_color_sequence.py +++ b/tests/test_color_sequence.py @@ -19,11 +19,13 @@ def test_len(): sequence = pysicgl.ColorSequence(DEFAULT_COLORS) assert len(sequence) == len(DEFAULT_COLORS) + def test_subscr(): sequence = pysicgl.ColorSequence(DEFAULT_COLORS) for idx in range(len(DEFAULT_COLORS)): assert sequence[idx] == DEFAULT_COLORS[idx] + @pytest.mark.skip(reason="Not implemented") def test_length(): sequence = pysicgl.ColorSequence(DEFAULT_COLORS) @@ -35,6 +37,7 @@ def test_length(): sequence.colors = ((0, 0, 0, 0), (0, 0, 0, 0)) assert len(sequence) == 2 + def test_iterator(): sequence = pysicgl.ColorSequence(DEFAULT_COLORS) assert hasattr(sequence, "__iter__") diff --git a/tests/test_compositor.py b/tests/test_compositor.py index f111fa3..20b2eb5 100644 --- a/tests/test_compositor.py +++ b/tests/test_compositor.py @@ -1,5 +1,6 @@ import pysicgl + def test_builtin_compositors(): expected_compositors = ( "DIRECT_SET",