diff --git a/include/pysicgl/submodules/color.h b/include/pysicgl/submodules/color.h index a497e33..cfd5caf 100644 --- a/include/pysicgl/submodules/color.h +++ b/include/pysicgl/submodules/color.h @@ -2,5 +2,6 @@ #define PY_SSIZE_T_CLEAN #include +// python includes first (clang-format) PyMODINIT_FUNC PyInit_color(void); diff --git a/include/pysicgl/submodules/composition.h b/include/pysicgl/submodules/composition.h index 0d06231..d39c908 100644 --- a/include/pysicgl/submodules/composition.h +++ b/include/pysicgl/submodules/composition.h @@ -2,5 +2,6 @@ #define PY_SSIZE_T_CLEAN #include +// python includes first (clang-format) PyMODINIT_FUNC PyInit_composition(void); diff --git a/include/pysicgl/submodules/functional.h b/include/pysicgl/submodules/functional.h index decfae8..2827734 100644 --- a/include/pysicgl/submodules/functional.h +++ b/include/pysicgl/submodules/functional.h @@ -2,5 +2,6 @@ #define PY_SSIZE_T_CLEAN #include +// python includes first (clang-format) PyMODINIT_FUNC PyInit_functional(void); diff --git a/include/pysicgl/submodules/functional/color.h b/include/pysicgl/submodules/functional/color.h index fc58a08..bb91214 100644 --- a/include/pysicgl/submodules/functional/color.h +++ b/include/pysicgl/submodules/functional/color.h @@ -1,5 +1,8 @@ #define PY_SSIZE_T_CLEAN #include +// python includes first (clang-format) PyObject* color_from_rgba(PyObject* self, PyObject* args); PyObject* color_to_rgba(PyObject* self, PyObject* args); +PyObject* interpolate_color_sequence( + PyObject* self_in, PyObject* args, PyObject* kwds); diff --git a/include/pysicgl/submodules/functional/color_correction.h b/include/pysicgl/submodules/functional/color_correction.h index 9cf374a..318c15c 100644 --- a/include/pysicgl/submodules/functional/color_correction.h +++ b/include/pysicgl/submodules/functional/color_correction.h @@ -1,4 +1,5 @@ #define PY_SSIZE_T_CLEAN #include +// python includes first (clang-format) PyObject* gamma_correct(PyObject* self, PyObject* args); diff --git a/include/pysicgl/submodules/functional/drawing/global.h b/include/pysicgl/submodules/functional/drawing/global.h index 0875093..b6d2285 100644 --- a/include/pysicgl/submodules/functional/drawing/global.h +++ b/include/pysicgl/submodules/functional/drawing/global.h @@ -2,6 +2,7 @@ #define PY_SSIZE_T_CLEAN #include +// python includes first (clang-format) PyObject* global_pixel(PyObject* self_in, PyObject* args); PyObject* global_line(PyObject* self_in, PyObject* args); diff --git a/include/pysicgl/submodules/functional/drawing/interface.h b/include/pysicgl/submodules/functional/drawing/interface.h index b5b2e7f..9168531 100644 --- a/include/pysicgl/submodules/functional/drawing/interface.h +++ b/include/pysicgl/submodules/functional/drawing/interface.h @@ -2,6 +2,7 @@ #define PY_SSIZE_T_CLEAN #include +// python includes first (clang-format) PyObject* interface_compose(PyObject* self_in, PyObject* args); PyObject* interface_blit(PyObject* self_in, PyObject* args); diff --git a/include/pysicgl/submodules/functional/drawing/screen.h b/include/pysicgl/submodules/functional/drawing/screen.h index 500b155..478b205 100644 --- a/include/pysicgl/submodules/functional/drawing/screen.h +++ b/include/pysicgl/submodules/functional/drawing/screen.h @@ -2,6 +2,7 @@ #define PY_SSIZE_T_CLEAN #include +// python includes first (clang-format) PyObject* screen_fill(PyObject* self_in, PyObject* args); PyObject* screen_pixel(PyObject* self_in, PyObject* args); diff --git a/include/pysicgl/submodules/functional/operations.h b/include/pysicgl/submodules/functional/operations.h index 53cacd6..e3dbd08 100644 --- a/include/pysicgl/submodules/functional/operations.h +++ b/include/pysicgl/submodules/functional/operations.h @@ -1,5 +1,6 @@ #define PY_SSIZE_T_CLEAN #include +// python includes first (clang-format) PyObject* scalar_field(PyObject* self_in, PyObject* args, PyObject* kwds); PyObject* compose(PyObject* self_in, PyObject* args); diff --git a/include/pysicgl/submodules/interpolation.h b/include/pysicgl/submodules/interpolation.h index 8da3c88..330a1f7 100644 --- a/include/pysicgl/submodules/interpolation.h +++ b/include/pysicgl/submodules/interpolation.h @@ -2,5 +2,6 @@ #define PY_SSIZE_T_CLEAN #include +// python includes first (clang-format) PyMODINIT_FUNC PyInit_interpolation(void); diff --git a/include/pysicgl/types/color_sequence.h b/include/pysicgl/types/color_sequence.h index 8a116ba..b7adfad 100644 --- a/include/pysicgl/types/color_sequence.h +++ b/include/pysicgl/types/color_sequence.h @@ -2,7 +2,9 @@ #define PY_SSIZE_T_CLEAN #include +// python includes first (clang-format) +#include "pysicgl/types/color_sequence_interpolator.h" #include "sicgl/color_sequence.h" // declare the type @@ -10,6 +12,7 @@ extern PyTypeObject ColorSequenceType; typedef struct { PyObject_HEAD color_sequence_t sequence; + ColorSequenceInterpolatorObject* interpolator; // iterator state // protected by the GIL diff --git a/include/pysicgl/types/color_sequence_interpolator.h b/include/pysicgl/types/color_sequence_interpolator.h index 9bd270c..9f578a4 100644 --- a/include/pysicgl/types/color_sequence_interpolator.h +++ b/include/pysicgl/types/color_sequence_interpolator.h @@ -2,7 +2,7 @@ #define PY_SSIZE_T_CLEAN #include -// python includes must come first +// python includes first (clang-format) #include "sicgl/color_sequence.h" diff --git a/include/pysicgl/types/compositor.h b/include/pysicgl/types/compositor.h index 1052d77..37e0a31 100644 --- a/include/pysicgl/types/compositor.h +++ b/include/pysicgl/types/compositor.h @@ -2,7 +2,7 @@ #define PY_SSIZE_T_CLEAN #include -// python includes must come first +// python includes first (clang-format) #include diff --git a/include/pysicgl/types/interface.h b/include/pysicgl/types/interface.h index 54a17c1..f08abb7 100644 --- a/include/pysicgl/types/interface.h +++ b/include/pysicgl/types/interface.h @@ -2,7 +2,7 @@ #define PY_SSIZE_T_CLEAN #include -// python includes must come first +// python includes first (clang-format) #include "pysicgl/types/screen.h" #include "sicgl/interface.h" diff --git a/include/pysicgl/types/scalar_field.h b/include/pysicgl/types/scalar_field.h index e85154c..b8467da 100644 --- a/include/pysicgl/types/scalar_field.h +++ b/include/pysicgl/types/scalar_field.h @@ -2,7 +2,7 @@ #define PY_SSIZE_T_CLEAN #include -// python includes must come first +// python includes first (clang-format) #include "sicgl/field.h" diff --git a/include/pysicgl/types/screen.h b/include/pysicgl/types/screen.h index dde3d47..af02cc4 100644 --- a/include/pysicgl/types/screen.h +++ b/include/pysicgl/types/screen.h @@ -2,7 +2,7 @@ #define PY_SSIZE_T_CLEAN #include -// python includes must come first +// python includes first (clang-format) #include diff --git a/src/module.c b/src/module.c index d1067eb..5d274b6 100644 --- a/src/module.c +++ b/src/module.c @@ -1,6 +1,6 @@ #define PY_SSIZE_T_CLEAN #include -// python includes must come first +// python includes first (clang-format) #include "pysicgl/submodules/color.h" #include "pysicgl/submodules/composition.h" diff --git a/src/submodules/composition/module.c b/src/submodules/composition/module.c index cc96ba7..5975422 100644 --- a/src/submodules/composition/module.c +++ b/src/submodules/composition/module.c @@ -1,6 +1,6 @@ #define PY_SSIZE_T_CLEAN #include -// python includes must come first +// python includes first (clang-format) #include "pysicgl/types/compositor.h" #include "sicgl/compositors.h" diff --git a/src/submodules/functional/color.c b/src/submodules/functional/color.c index 352f021..d61183a 100644 --- a/src/submodules/functional/color.c +++ b/src/submodules/functional/color.c @@ -1,7 +1,9 @@ #define PY_SSIZE_T_CLEAN -#include "sicgl/color.h" - #include +// python includes first (clang-format) + +#include "pysicgl/types/color_sequence.h" +#include "sicgl/color.h" PyObject* color_to_rgba(PyObject* self, PyObject* args) { (void)self; @@ -31,3 +33,96 @@ PyObject* color_from_rgba(PyObject* self, PyObject* args) { PyLong_AsLong(PyTuple_GetItem(obj, 2)), PyLong_AsLong(PyTuple_GetItem(obj, 3)))); } + +PyObject* interpolate_color_sequence( + PyObject* self_in, PyObject* args, PyObject* kwds) { + (void)self_in; + int ret = 0; + ColorSequenceObject* color_sequence_obj; + PyObject* samples_obj; + char* keywords[] = { + "color_sequence", + "samples", + NULL, + }; + if (!PyArg_ParseTupleAndKeywords( + args, kwds, "O!O", keywords, &ColorSequenceType, &color_sequence_obj, + &samples_obj)) { + return NULL; + } + + // determine the interpolation function + sequence_map_fn interp_fn = color_sequence_obj->interpolator->fn; + + // use this sequences' interpolation method to handle the input + if (PyLong_Check(samples_obj)) { + // input is a single sample, return the interpolated color directly + color_t color; + ret = interp_fn( + &color_sequence_obj->sequence, (double)PyLong_AsLong(samples_obj), + &color); + if (0 != ret) { + PyErr_SetNone(PyExc_OSError); + return NULL; + } + return PyLong_FromLong(color); + + } else if (PyFloat_Check(samples_obj)) { + // input is a single sample, return the interpolated color directly + color_t color; + ret = interp_fn( + &color_sequence_obj->sequence, PyFloat_AsDouble(samples_obj), &color); + if (0 != ret) { + PyErr_SetNone(PyExc_OSError); + return NULL; + } + return PyLong_FromLong(color); + + } else if (PyList_Check(samples_obj)) { + // input is a list of samples, return a tuple of interpolated colors + size_t num_samples = PyList_Size(samples_obj); + PyObject* result = PyTuple_New(num_samples); + for (size_t idx = 0; idx < num_samples; idx++) { + color_t color; + ret = interp_fn( + &color_sequence_obj->sequence, + PyFloat_AsDouble(PyList_GetItem(samples_obj, idx)), &color); + if (0 != ret) { + PyErr_SetNone(PyExc_OSError); + return NULL; + } + ret = PyTuple_SetItem(result, idx, PyLong_FromLong(color)); + if (0 != ret) { + return NULL; + } + } + return result; + + } else if (PyTuple_Check(samples_obj)) { + // input is a tuple of samples, return a tuple of interpolated colors + size_t num_samples = PyTuple_Size(samples_obj); + PyObject* result = PyTuple_New(num_samples); + for (size_t idx = 0; idx < num_samples; idx++) { + color_t color; + ret = interp_fn( + &color_sequence_obj->sequence, + PyFloat_AsDouble(PyTuple_GetItem(samples_obj, idx)), &color); + if (0 != ret) { + PyErr_SetNone(PyExc_OSError); + return NULL; + } + ret = PyTuple_SetItem(result, idx, PyLong_FromLong(color)); + if (0 != ret) { + return NULL; + } + } + + } else { + PyErr_SetNone(PyExc_TypeError); + return NULL; + } + + // should never get here + PyErr_SetNone(PyExc_NotImplementedError); + return NULL; +} diff --git a/src/submodules/functional/color_correction.c b/src/submodules/functional/color_correction.c index cf5a8d6..4c487b7 100644 --- a/src/submodules/functional/color_correction.c +++ b/src/submodules/functional/color_correction.c @@ -1,5 +1,6 @@ #define PY_SSIZE_T_CLEAN #include +// python includes first (clang-format) #include "pysicgl/types/interface.h" #include "sicgl/gamma.h" diff --git a/src/submodules/functional/drawing/global.c b/src/submodules/functional/drawing/global.c index 0f5f532..9ed7b82 100644 --- a/src/submodules/functional/drawing/global.c +++ b/src/submodules/functional/drawing/global.c @@ -1,10 +1,10 @@ #define PY_SSIZE_T_CLEAN -#include "sicgl/domain/global.h" - #include +// python includes first (clang-format) #include "pysicgl/types/interface.h" #include "sicgl/blit.h" +#include "sicgl/domain/global.h" PyObject* global_pixel(PyObject* self_in, PyObject* args) { (void)self_in; diff --git a/src/submodules/functional/drawing/interface.c b/src/submodules/functional/drawing/interface.c index a056032..aa0c334 100644 --- a/src/submodules/functional/drawing/interface.c +++ b/src/submodules/functional/drawing/interface.c @@ -1,6 +1,6 @@ #define PY_SSIZE_T_CLEAN #include -// python includes must come first +// python includes first (clang-format) #include "pysicgl/types/interface.h" #include "sicgl/blit.h" diff --git a/src/submodules/functional/drawing/screen.c b/src/submodules/functional/drawing/screen.c index b0e721c..0ca8351 100644 --- a/src/submodules/functional/drawing/screen.c +++ b/src/submodules/functional/drawing/screen.c @@ -1,6 +1,6 @@ #define PY_SSIZE_T_CLEAN #include -// python includes must come first +// python includes first (clang-format) #include "pysicgl/types/interface.h" #include "sicgl/domain/screen.h" diff --git a/src/submodules/functional/module.c b/src/submodules/functional/module.c index deec576..675a626 100644 --- a/src/submodules/functional/module.c +++ b/src/submodules/functional/module.c @@ -1,5 +1,6 @@ #define PY_SSIZE_T_CLEAN #include +// python includes first (clang-format) #include "pysicgl/submodules/functional/color.h" #include "pysicgl/submodules/functional/color_correction.h" @@ -79,6 +80,10 @@ static PyMethodDef funcs[] = { "Return the color comprised of the RGBA input 4-tuple."}, {"color_to_rgba", (PyCFunction)color_to_rgba, METH_VARARGS, "Return the individual RGBA components of the input color as a 4-tuple."}, + {"interpolate_color_sequence", (PyCFunction)interpolate_color_sequence, + METH_VARARGS | METH_KEYWORDS, + "Interpolate the color sequence at one or more points using the given " + "interpolation type."}, // color correction {"gamma_correct", (PyCFunction)gamma_correct, METH_VARARGS, diff --git a/src/submodules/functional/operations.c b/src/submodules/functional/operations.c index c69a656..272c60c 100644 --- a/src/submodules/functional/operations.c +++ b/src/submodules/functional/operations.c @@ -1,5 +1,6 @@ #define PY_SSIZE_T_CLEAN #include +// python includes first (clang-format) #include "pysicgl/types/color_sequence.h" #include "pysicgl/types/color_sequence_interpolator.h" @@ -36,22 +37,18 @@ PyObject* scalar_field(PyObject* self_in, PyObject* args, PyObject* kwds) { ScreenObject* field_obj; ScalarFieldObject* scalar_field_obj; ColorSequenceObject* color_sequence_obj; - ColorSequenceInterpolatorObject* interpolator_obj; double offset = 0.0; char* keywords[] = { - "interface", "field", "scalars", "color_sequence", - "interpolator", "offset", NULL, + "interface", "screen", "scalar_field", "color_sequence", "offset", NULL, }; if (!PyArg_ParseTupleAndKeywords( - args, kwds, "O!O!O!O!O!|d", keywords, &InterfaceType, &interface_obj, + args, kwds, "O!O!O!O!|d", keywords, &InterfaceType, &interface_obj, &ScreenType, &field_obj, &ScalarFieldType, &scalar_field_obj, - &ColorSequenceType, &color_sequence_obj, - &ColorSequenceInterpolatorType, &interpolator_obj, &offset)) { + &ColorSequenceType, &color_sequence_obj, &offset)) { return NULL; } Py_INCREF(color_sequence_obj); - Py_INCREF(interpolator_obj); Py_INCREF(scalar_field_obj); // check length of scalars is sufficient for the field @@ -68,6 +65,8 @@ PyObject* scalar_field(PyObject* self_in, PyObject* args, PyObject* kwds) { return NULL; } + ColorSequenceInterpolatorObject* interpolator_obj = + color_sequence_obj->interpolator; ret = sicgl_scalar_field( &interface_obj->interface, field_obj->screen, scalar_field_obj->scalars, offset, &color_sequence_obj->sequence, interpolator_obj->fn); @@ -77,7 +76,6 @@ PyObject* scalar_field(PyObject* self_in, PyObject* args, PyObject* kwds) { } Py_DECREF(scalar_field_obj); - Py_DECREF(interpolator_obj); Py_DECREF(color_sequence_obj); Py_INCREF(Py_None); diff --git a/src/submodules/interpolation/module.c b/src/submodules/interpolation/module.c index 8c0047e..8d10f00 100644 --- a/src/submodules/interpolation/module.c +++ b/src/submodules/interpolation/module.c @@ -1,6 +1,6 @@ #define PY_SSIZE_T_CLEAN #include -// python includes must come first +// python includes first (clang-format) #include "pysicgl/types/color_sequence_interpolator.h" #include "sicgl/color_sequence.h" diff --git a/src/types/color_sequence/type.c b/src/types/color_sequence/type.c index 6e8077e..b979811 100644 --- a/src/types/color_sequence/type.c +++ b/src/types/color_sequence/type.c @@ -1,6 +1,6 @@ #define PY_SSIZE_T_CLEAN #include -// python includes must come first +// python includes first (clang-format) #include @@ -63,108 +63,21 @@ static int allocate_sequence(ColorSequenceObject* self, size_t len) { // methods ////////// -/** - * @brief Interpolate the color sequence at one or more points using the given - * interpolation type. - * - * @param self_in - * @param args - * - samples_obj: The sample(s) to interpolate at. (int, float, list, tuple) - * - interp_type: The interpolation type. (int) - * @param kwds - * @return PyObject* a new reference to the interpolated color(s). - * - * @note - */ -static PyObject* interpolate( - PyObject* self_in, PyObject* args, PyObject* kwds) { - int ret = 0; +static PyObject* get_colors(PyObject* self_in, void* closure) { + (void)closure; ColorSequenceObject* self = (ColorSequenceObject*)self_in; - PyObject* samples_obj; - ColorSequenceInterpolatorObject* interpolator_obj; - char* keywords[] = { - "samples", - "interpolator", - NULL, - }; - if (!PyArg_ParseTupleAndKeywords( - args, kwds, "OO!", keywords, &samples_obj, - &ColorSequenceInterpolatorType, &interpolator_obj)) { - return NULL; - } - - // determine the interpolation function - sequence_map_fn interp_fn = interpolator_obj->fn; - - // use this sequences' interpolation method to handle the input - if (PyLong_Check(samples_obj)) { - // input is a single sample, return the interpolated color directly - color_t color; - ret = - interp_fn(&self->sequence, (double)PyLong_AsLong(samples_obj), &color); - if (0 != ret) { - PyErr_SetNone(PyExc_OSError); - return NULL; - } - return PyLong_FromLong(color); - - } else if (PyFloat_Check(samples_obj)) { - // input is a single sample, return the interpolated color directly - color_t color; - ret = interp_fn(&self->sequence, PyFloat_AsDouble(samples_obj), &color); - if (0 != ret) { - PyErr_SetNone(PyExc_OSError); - return NULL; - } - return PyLong_FromLong(color); - - } else if (PyList_Check(samples_obj)) { - // input is a list of samples, return a tuple of interpolated colors - size_t num_samples = PyList_Size(samples_obj); - PyObject* result = PyTuple_New(num_samples); - for (size_t idx = 0; idx < num_samples; idx++) { - color_t color; - ret = interp_fn( - &self->sequence, PyFloat_AsDouble(PyList_GetItem(samples_obj, idx)), - &color); - if (0 != ret) { - PyErr_SetNone(PyExc_OSError); - return NULL; - } - ret = PyTuple_SetItem(result, idx, PyLong_FromLong(color)); - if (0 != ret) { - return NULL; - } - } - return result; - - } else if (PyTuple_Check(samples_obj)) { - // input is a tuple of samples, return a tuple of interpolated colors - size_t num_samples = PyTuple_Size(samples_obj); - PyObject* result = PyTuple_New(num_samples); - for (size_t idx = 0; idx < num_samples; idx++) { - color_t color; - ret = interp_fn( - &self->sequence, PyFloat_AsDouble(PyTuple_GetItem(samples_obj, idx)), - &color); - if (0 != ret) { - PyErr_SetNone(PyExc_OSError); - return NULL; - } - ret = PyTuple_SetItem(result, idx, PyLong_FromLong(color)); - if (0 != ret) { - return NULL; - } - } - - } else { - PyErr_SetNone(PyExc_TypeError); - return NULL; + PyObject* colors = PyList_New(self->sequence.length); + for (size_t idx = 0; idx < self->sequence.length; idx++) { + PyList_SetItem(colors, idx, PyLong_FromLong(self->sequence.colors[idx])); } + return colors; +} - // should never get here - PyErr_SetNone(PyExc_NotImplementedError); - return NULL; +static PyObject* get_interpolator(PyObject* self_in, void* closure) { + (void)closure; + ColorSequenceObject* self = (ColorSequenceObject*)self_in; + Py_INCREF((PyObject*)self->interpolator); + return (PyObject*)self->interpolator; } static Py_ssize_t mp_length(PyObject* self_in) { @@ -200,6 +113,7 @@ static PyObject* tp_iternext(PyObject* self_in) { static void tp_dealloc(PyObject* self_in) { ColorSequenceObject* self = (ColorSequenceObject*)self_in; + Py_XDECREF(self->interpolator); deallocate_sequence(self); Py_TYPE(self)->tp_free(self); } @@ -208,14 +122,22 @@ static int tp_init(PyObject* self_in, PyObject* args, PyObject* kwds) { int ret = 0; ColorSequenceObject* self = (ColorSequenceObject*)self_in; PyObject* colors_obj; + ColorSequenceInterpolatorObject* interpolator_obj; char* keywords[] = { "colors", + "interpolator", NULL, }; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O", keywords, &colors_obj)) { + if (!PyArg_ParseTupleAndKeywords( + args, kwds, "OO!", keywords, &colors_obj, + &ColorSequenceInterpolatorType, &interpolator_obj)) { return -1; } + // set the interpolator + self->interpolator = interpolator_obj; + Py_INCREF(self->interpolator); + // ensure that the colors object is a list if (!PyList_Check(colors_obj)) { PyErr_SetNone(PyExc_TypeError); @@ -234,17 +156,13 @@ static int tp_init(PyObject* self_in, PyObject* args, PyObject* kwds) { // copy the colors into the sequence for (size_t idx = 0; idx < len; idx++) { - self->sequence.colors[idx] = - PyLong_AsLong(PyList_GetItem(colors_obj, idx)); + self->sequence.colors[idx] = PyLong_AsLong(PyList_GetItem(colors_obj, idx)); } return ret; } static PyMethodDef tp_methods[] = { - {"interpolate", (PyCFunction)interpolate, METH_VARARGS | METH_KEYWORDS, - "interpolate the color sequence at one or more points using the given " - "interpolation type"}, {NULL}, }; @@ -253,6 +171,12 @@ static PyMappingMethods tp_as_mapping = { .mp_subscript = mp_subscript, }; +static PyGetSetDef tp_getset[] = { + {"colors", get_colors, NULL, "colors", NULL}, + {"interpolator", get_interpolator, NULL, "interpolator", NULL}, + {NULL}, +}; + PyTypeObject ColorSequenceType = { PyVarObject_HEAD_INIT(NULL, 0).tp_name = "_sicgl_core.ColorSequence", .tp_doc = PyDoc_STR("sicgl color"), @@ -262,6 +186,7 @@ PyTypeObject ColorSequenceType = { .tp_new = PyType_GenericNew, .tp_dealloc = tp_dealloc, .tp_init = tp_init, + .tp_getset = tp_getset, .tp_methods = tp_methods, .tp_as_mapping = &tp_as_mapping, .tp_iter = tp_iter, diff --git a/src/types/color_sequence_interpolator/type.c b/src/types/color_sequence_interpolator/type.c index 6462472..c0b3740 100644 --- a/src/types/color_sequence_interpolator/type.c +++ b/src/types/color_sequence_interpolator/type.c @@ -1,6 +1,6 @@ #define PY_SSIZE_T_CLEAN #include -// python includes must come first +// python includes first (clang-format) #include "pysicgl/types/color_sequence_interpolator.h" diff --git a/src/types/compositor/type.c b/src/types/compositor/type.c index 82c0aeb..dd25b24 100644 --- a/src/types/compositor/type.c +++ b/src/types/compositor/type.c @@ -1,7 +1,7 @@ #define PY_SSIZE_T_CLEAN #include #include -// python includes must come first +// python includes first (clang-format) #include #include diff --git a/src/types/interface/type.c b/src/types/interface/type.c index d9902f1..da1e21b 100644 --- a/src/types/interface/type.c +++ b/src/types/interface/type.c @@ -1,6 +1,6 @@ #define PY_SSIZE_T_CLEAN #include -// python includes must come first +// python includes first (clang-format) #include #include diff --git a/src/types/scalar_field/type.c b/src/types/scalar_field/type.c index b42ad0b..334dd75 100644 --- a/src/types/scalar_field/type.c +++ b/src/types/scalar_field/type.c @@ -1,10 +1,10 @@ #define PY_SSIZE_T_CLEAN #include -#include -// python includes must come first +// python includes first (clang-format) #include #include +#include #include "pysicgl/types/scalar_field.h" diff --git a/src/types/screen/type.c b/src/types/screen/type.c index aa11c6b..56c2833 100644 --- a/src/types/screen/type.c +++ b/src/types/screen/type.c @@ -1,7 +1,7 @@ #define PY_SSIZE_T_CLEAN #include #include -// python includes must come first +// python includes first (clang-format) #include #include diff --git a/tests/test_color_sequence.py b/tests/test_color_sequence.py index 2cf5d8d..c922922 100644 --- a/tests/test_color_sequence.py +++ b/tests/test_color_sequence.py @@ -3,32 +3,43 @@ DEFAULT_COLORS = [2] +DEFAULT_INTERPOLATOR = pysicgl.interpolation.CONTINUOUS_CIRCULAR def test_initialization(): - sequence = pysicgl.ColorSequence(DEFAULT_COLORS) + sequence = pysicgl.ColorSequence( + colors=DEFAULT_COLORS, interpolator=DEFAULT_INTERPOLATOR + ) @pytest.mark.skip(reason="Not implemented") def test_has_len(): - sequence = pysicgl.ColorSequence(DEFAULT_COLORS) + sequence = pysicgl.ColorSequence( + colors=DEFAULT_COLORS, interpolator=DEFAULT_INTERPOLATOR + ) assert hasattr(sequence, "__len__") def test_len(): - sequence = pysicgl.ColorSequence(DEFAULT_COLORS) + sequence = pysicgl.ColorSequence( + colors=DEFAULT_COLORS, interpolator=DEFAULT_INTERPOLATOR + ) assert len(sequence) == len(DEFAULT_COLORS) def test_subscr(): - sequence = pysicgl.ColorSequence(DEFAULT_COLORS) + sequence = pysicgl.ColorSequence( + colors=DEFAULT_COLORS, interpolator=DEFAULT_INTERPOLATOR + ) 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) + sequence = pysicgl.ColorSequence( + colors=DEFAULT_COLORS, interpolator=DEFAULT_INTERPOLATOR + ) assert len(sequence) == 0 sequence.colors = ((0, 0, 0, 0),) @@ -39,7 +50,9 @@ def test_length(): def test_iterator(): - sequence = pysicgl.ColorSequence(DEFAULT_COLORS) + sequence = pysicgl.ColorSequence( + colors=DEFAULT_COLORS, interpolator=DEFAULT_INTERPOLATOR + ) assert hasattr(sequence, "__iter__") assert iter(sequence) is sequence assert len(list(sequence)) == len(DEFAULT_COLORS)