From 23d7882b93c8eb97bc95caa7d814cdbe7bbb79a5 Mon Sep 17 00:00:00 2001 From: John McCardle Date: Thu, 30 Oct 2025 11:25:43 -0400 Subject: [PATCH] fix: correct normalize() documentation to match implementation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The normalize() method's implementation returns a zero vector when called on a zero-magnitude vector, rather than raising ValueError as the documentation claimed. Updated the MCRF_RAISES to MCRF_NOTE to accurately describe the actual behavior. Also added test coverage in tools/test_vector_docs.py to verify the normalize() docstring contains the correct Note section. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/PyVector.cpp | 2 +- tools/test_vector_docs.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/PyVector.cpp b/src/PyVector.cpp index 51cfbcf..ead01f3 100644 --- a/src/PyVector.cpp +++ b/src/PyVector.cpp @@ -22,7 +22,7 @@ PyMethodDef PyVector::methods[] = { MCRF_SIG("()", "Vector"), MCRF_DESC("Return a unit vector in the same direction."), MCRF_RETURNS("Vector: New normalized vector with magnitude 1.0") - MCRF_RAISES("ValueError", "If vector has zero magnitude") + MCRF_NOTE("For zero vectors (magnitude 0.0), returns a zero vector rather than raising an exception") )}, {"dot", (PyCFunction)PyVector::dot, METH_O, MCRF_METHOD(Vector, dot, diff --git a/tools/test_vector_docs.py b/tools/test_vector_docs.py index cb3f4ae..a908f64 100644 --- a/tools/test_vector_docs.py +++ b/tools/test_vector_docs.py @@ -15,5 +15,13 @@ assert "dot(other: Vector)" in dot_doc assert "Args:" in dot_doc assert "other:" in dot_doc +# Check Vector.normalize docstring +normalize_doc = mcrfpy.Vector.normalize.__doc__ +print("normalize doc:", normalize_doc) +assert "normalize()" in normalize_doc +assert "Return a unit vector" in normalize_doc +assert "Returns:" in normalize_doc +assert "Note:" in normalize_doc + print("SUCCESS: All docstrings present and complete") sys.exit(0)