fix: exports crash without optional deps, Vector.like() type safety, and docstring corrections#716
Draft
henryiii wants to merge 2 commits into
Draft
fix: exports crash without optional deps, Vector.like() type safety, and docstring corrections#716henryiii wants to merge 2 commits into
henryiii wants to merge 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #716 +/- ##
==========================================
+ Coverage 87.16% 87.23% +0.06%
==========================================
Files 96 96
Lines 11199 11200 +1
==========================================
+ Hits 9762 9770 +8
+ Misses 1437 1430 -7 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
43 tasks
…and docstring corrections
- Define all optional-dep names (MomentumSympy2D/3D/4D, VectorSympy2D/3D/4D,
awkward_transform) as None in the except branches so `from vector import *`
no longer raises AttributeError when sympy or awkward is absent
- Fix __dir__() to filter out sympy and awkward names when those deps are missing
- Make Vector.like() raise TypeError for non-vector arguments instead of
silently calling to_Vector4D()
- Fix eta docstring: remove copy-paste from theta (no longer says "in radians,
always between 0 and pi"); add correct pseudorapidity formula
- Fix rotate_euler docstring: Tait-Bryan list was a copy of the Euler list;
corrected to xzy/xyz/yxz/yzx/zyx/zxy per compute file
- Fix MomentumProtocolLorentz.E docstring typo ("synonyor" -> "synonym for")
- Fix MomentumProtocolLorentz.E2 broken cross-ref (VectorProtocolLorent2 ->
VectorProtocolLorentz.t2)
- Fix to_pxpythetamass docstring: "$energy$" -> "$mass$"
- Fix to_ptphietamass docstring: "$\theta$" -> "$\eta$"
- Fix to_Vector4D error messages in Vector2D and Vector3D: "longitudinal
coordinate" -> "temporal coordinate" for temporal over-specification error
- Add tests for all of the above
Assisted-by: ClaudeCode:claude-sonnet-4-6
6d83076 to
c6f0644
Compare
… no-cover The star-import fix's regression test runs in a subprocess, so its coverage of the optional-dependency fallbacks is not captured by pytest-cov. Mark those import-time except branches as no-cover and add an in-process test for the __dir__ name-exclusion logic. Assisted-by: ClaudeCode:claude-opus-4.8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 AI text below 🤖
Summary
Part of #711
from vector import *crash without optional deps (src/vector/__init__.py): All optional names (MomentumSympy2D/3D/4D,VectorSympy2D/3D/4D,awkward_transform) are now defined asNonein theexcept ImportErrorbranches, so star-imports no longer raiseAttributeErrorwhen sympy or awkward is absent.__dir__()is also updated to filter these names out when the corresponding dependency is missing.Vector.like()to raiseTypeErrorfor non-vector arguments (src/vector/_methods.py): Theelsebranch now only triggers forVector4D; anything else raisesTypeError(matching the style ofdim()).src/vector/_methods.py):etaproperty: removed copy-paste fromtheta("in radians, always between 0 and π"); replaced with correct pseudorapidity description including the formulaη = −ln tan(θ/2).rotate_euler: Tait-Bryan list was a duplicate of the proper Euler list; corrected to"xzy", "xyz", "yxz", "yzx", "zyx", "zxy"(verified against_compute/spatial/rotate_euler.py).MomentumProtocolLorentz.E: fixed typo "synonyor" → "synonym for".MomentumProtocolLorentz.E2: fixed broken cross-ref:attr:VectorProtocolLorent2→ `:attr:`VectorProtocolLorentz.t2.to_pxpythetamass: corrected "$energy$" → "$mass$" in first-line description.to_ptphietamass: corrected "$\theta$" → "$\eta$" in first-line description.Vector2D.to_Vector4DandVector3D.to_Vector4Derror messages: "At most one longitudinal coordinate" → "temporal" for the temporal over-specification check.Test plan
test_star_import_without_optional_deps: subprocess test that blocks sympy via afind_specmeta-path finder, then verifiesfrom vector import *succeeds and sympy names are absent fromdir(vector)test_like_non_vector_raises: verifiesv.like(5)raisesTypeErrortest_to_vector4d_temporal_error_message: verifies the error message says "temporal" for bothVector2D.to_Vector4DandVector3D.to_Vector4D--doctest-plus src/vector/; only pre-existing_pytree.pyoptree failure)prek -a --quietpasses cleanly🤖 Generated with Claude Code