Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
oclyke committed Nov 29, 2023
1 parent 30bfa83 commit 286d4c1
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/submodules/functional/color.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#define PY_SSIZE_T_CLEAN
#include <Python.h>

#include "sicgl/color.h"

#include <Python.h>

PyObject* color_to_rgba(PyObject* self, PyObject* args) {
(void)self;
PyObject* obj;
Expand Down
2 changes: 1 addition & 1 deletion src/submodules/functional/module.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#define PY_SSIZE_T_CLEAN
#include <Python.h>

#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"
Expand Down
26 changes: 15 additions & 11 deletions src/submodules/functional/operations.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
Expand All @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/types/color_sequence/type.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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},
Expand Down
3 changes: 3 additions & 0 deletions tests/test_color_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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__")
Expand Down
1 change: 1 addition & 0 deletions tests/test_compositor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pysicgl


def test_builtin_compositors():
expected_compositors = (
"DIRECT_SET",
Expand Down

0 comments on commit 286d4c1

Please sign in to comment.