Description of proposed changes
The kwargs_to_ctypes_array function was one of the oldest functions in PyGMT. It was first added in PR #55 (It's 2017! Seven years ago!) and has not changed since then.
The function converts a sequence (like a list or a tuple) into a ctypes array, but the sequence must be the argument of a keyword dictionary, so it's called like this:
dim = kwargs_to_ctypes_array("dim", kwargs, ctp.c_uint64 * 4)
but why not just have a more general function sequence_to_ctypes_array, which can be called like:
dim = sequence_to_ctypes_array(kwargs.get("dim"), ctp.c_uint64 * 4)
The new function also works if dim is not a keyword argument:
dim = sequence_to_ctypes_array(dim, ctp.c_uint64 * 4)
This PR removes the old kwargs_to_ctypes_array function and adds the new sequence_to_ctypes_array function. It's defined differently and should be called like:
dim = sequence_to_ctypes_array(dim, ctp.c_uint64, 4)
which I think is more readable.
The Session.create_data method is also slightly refactored because the kwargs parameter makes little sense in this method.
PR #3137 adds a similar function that converts a sequence of strings into a ctypes array. Better to review these two PRs back-to-back.