From 800f69c634c14cc50da1d78cb3b2fa3b6cc49423 Mon Sep 17 00:00:00 2001 From: vocx-fc Date: Mon, 5 Aug 2019 11:20:52 -0500 Subject: [PATCH] Draft: DraftVecUtils, better docstrings; removed the last comma at the end of the list of vectors --- src/Mod/Draft/DraftVecUtils.py | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/src/Mod/Draft/DraftVecUtils.py b/src/Mod/Draft/DraftVecUtils.py index 5df8e93467..b3a0fc9374 100644 --- a/src/Mod/Draft/DraftVecUtils.py +++ b/src/Mod/Draft/DraftVecUtils.py @@ -57,17 +57,20 @@ def typecheck(args_and_types, name="?"): Parameters ---------- - args_and_types : iterable - An iterable of two elements, for example a list, - from which the first element is tested as being an instance - of the second element. - name : str - The name of the object. + args_and_types : list + [(a, b), (c, d), ...] : list + A list of tuples. The first element of the tuple is tested as being + an instance of the second element. + `isinstance(a, b)` + `isinstance(c, d)` + name : str, optional + Defaults to '?'. The name of the object. Raises ------- TypeError - If the first argument is not an instance of the second argument. + If the first element in the tuple is not an instance of the second + element. """ for v, t in args_and_types: if not isinstance(v, t): @@ -103,7 +106,7 @@ def toString(u): s += ", " first = True # Remove the last comma - s = s.rstrip(",") + s = s.rstrip(", ") s += "]" return s else: @@ -138,7 +141,19 @@ def tup(u, array=False): def neg(u): - "neg(Vector) - returns an opposite (negative) vector" + """Return the negative of a given FreeCAD.Vector. + + Parameters + ---------- + u : Base::Vector3 + A FreeCAD.Vector. + + Returns + ------- + Base::Vector3 + A vector in which each element has the opposite sign as + the original element. + """ typecheck([(u, Vector)], "neg") return Vector(-u.x, -u.y, -u.z)