From 9a145bca3bae45d42b7572472fcfe994ac22b134 Mon Sep 17 00:00:00 2001 From: Andrew Annex Date: Tue, 14 Apr 2020 19:57:22 -0400 Subject: [PATCH] more callback doc fixes, but more work needed to clean up type hints --- spiceypy/utils/callbacks.py | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/spiceypy/utils/callbacks.py b/spiceypy/utils/callbacks.py index c6aacbd5..364e8dd7 100644 --- a/spiceypy/utils/callbacks.py +++ b/spiceypy/utils/callbacks.py @@ -42,9 +42,7 @@ def SpiceUDFUNC(f: Callable[[float], float]) -> UDFUNC: """ Decorator for wrapping python functions in spice udfunc callback type :param f: function that has one argument of type float, and returns a float - :type f: builtins.function :return: wrapped udfunc function - :rtype: builtins.function """ @functools.wraps(f) @@ -55,30 +53,27 @@ def wrapping_udfunc(x: float, value: POINTER(c_double)) -> None: return UDFUNC(wrapping_udfunc) -def SpiceUDFUNS(f) -> UDFUNS: +def SpiceUDFUNS(f: Callable[[float], float]) -> UDFUNS: """ Decorator for wrapping python functions in spice udfuns callback type :param f: function that has one argument of type float, and returns a float - :type f: builtins.function :return: wrapped udfunc function - :rtype: builtins.function """ @functools.wraps(f) - def wrapping_udfuns(x, value): + def wrapping_udfuns(x: float, value: POINTER(c_double)): result = f(x) value[0] = c_double(result) return UDFUNS(wrapping_udfuns) -def SpiceUDFUNB(f): +def SpiceUDFUNB(f) -> UDFUNB: """ Decorator for wrapping python functions in spice udfunb callback type :param f: function to be wrapped :type f: builtins.function :return: wrapped udfunb function - :rtype: builtins.function """ @functools.wraps(f) @@ -89,13 +84,12 @@ def wrapping_udfunb(udf, et, xbool): return UDFUNB(wrapping_udfunb) -def SpiceUDSTEP(f): +def SpiceUDSTEP(f) -> UDSTEP: """ Decorator for wrapping python functions in spice udstep callback type :param f: function to be wrapped :type f: builtins.function :return: wrapped udstep function - :rtype: builtins.function """ @functools.wraps(f) @@ -106,13 +100,12 @@ def wrapping_udstep(x, value): return UDSTEP(wrapping_udstep) -def SpiceUDREFN(f): +def SpiceUDREFN(f) -> UDREFN: """ Decorator for wrapping python functions in spice udrefn callback type :param f: function to be wrapped :type f: builtins.function :return: wrapped udrefn function - :rtype: builtins.function """ @functools.wraps(f) @@ -123,13 +116,12 @@ def wrapping_udrefn(t1, t2, s1, s2, t): return UDREFN(wrapping_udrefn) -def SpiceUDREPI(f): +def SpiceUDREPI(f) -> UDREPI: """ Decorator for wrapping python functions in spice udfrepi callback type :param f: function to be wrapped :type f: builtins.function :return: wrapped udrepi function - :rtype: builtins.function """ @functools.wraps(f) @@ -139,13 +131,12 @@ def wrapping_udrepi(cnfine, srcpre, srcsurf): return UDREPI(wrapping_udrepi) -def SpiceUDREPU(f): +def SpiceUDREPU(f) -> UDREPU: """ Decorator for wrapping python functions in spice udrepu callback type :param f: function to be wrapped :type f: builtins.function :return: wrapped udrepu function - :rtype: builtins.function """ @functools.wraps(f) @@ -155,13 +146,12 @@ def wrapping_udrepu(beg, end, et): return UDREPU(wrapping_udrepu) -def SpiceUDREPF(f): +def SpiceUDREPF(f) -> UDREPF: """ Decorator for wrapping python functions in spice udrepf callback type :param f: function to be wrapped :type f: builtins.function :return: wrapped udrepf function - :rtype: builtins.function """ @functools.wraps(f) @@ -171,13 +161,12 @@ def wrapping_udrepf(): return UDREPF(wrapping_udrepf) -def SpiceUDBAIL(f): +def SpiceUDBAIL(f: Callable[[], bool]) -> UDBAIL: """ Decorator for wrapping python functions in spice udbail callback type :param f: function to be wrapped :type f: builtins.function :return: wrapped udbail function - :rtype: builtins.function """ @functools.wraps(f) @@ -188,16 +177,13 @@ def wrapping_udbail(): return UDBAIL(wrapping_udbail) -def CallUDFUNS(f, x): +def CallUDFUNS(f: UDFUNS, x: float) -> float: """ We are given a UDF CFUNCTYPE and want to call it in python :param f: SpiceUDFUNS - :type f: CFUNCTYPE :param x: some scalar - :type x: float :return: value - :rtype: float """ value = c_double() f(x, byref(value))