Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions pygmt/clib/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import io
import sys
from collections.abc import Callable, Generator, Sequence
from typing import Literal
from typing import Any, Literal

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -286,7 +286,7 @@ def get_enum(self, name: str) -> int:
return value

def get_libgmt_func(
self, name: str, argtypes: list | None = None, restype=None
self, name: str, argtypes: list | None = None, restype: Any = ctp.c_int
) -> Callable:
"""
Get a ctypes function from the libgmt shared library.
Expand All @@ -302,9 +302,10 @@ def get_libgmt_func(
argtypes
List of ctypes types used to convert the Python input arguments for the API
function.
restype : ctypes type
The ctypes type used to convert the input returned by the function into a
Python type.
restype
The ctypes type used to convert the value returned by the function into a
Python type [Default is :class:`ctypes.c_int`]. Use ``None`` for functions
that return void.

Returns
-------
Expand All @@ -322,13 +323,10 @@ def get_libgmt_func(
>>> type(func)
<class 'ctypes.CDLL.__init__.<locals>._FuncPtr'>
"""
if not hasattr(self, "_libgmt"):
self._libgmt = _libgmt
function = getattr(self._libgmt, name)
function = getattr(_libgmt, name)
if argtypes is not None:
function.argtypes = argtypes
if restype is not None:
function.restype = restype
function.restype = restype
return function

def create(self, name: str) -> None:
Expand Down
Loading