Skip to content

fix(python): NumPy 2-safe scalar ops for Vector3r/Quaternionr - #9802

Closed
Bartok (Bartok9) wants to merge 1 commit into
microsoft:mainfrom
Bartok9:aerial/python-numpy2-vector-quat-ops-20260722
Closed

Bartok (Bartok9) wants to merge 1 commit into
microsoft:mainfrom
Bartok9:aerial/python-numpy2-vector-quat-ops-20260722

Conversation

@Bartok9

Copy link
Copy Markdown

Summary

  • Replace np.sctypes gates in Vector3r/Quaternionr multiply/divide (removed in NumPy 2.0) with a portable _is_numeric_scalar helper.
  • Add missing Quaternionr.__sub__ so cross() / outer_product() work.
  • Offline unittest for scalar scale, bool rejection, and subtraction.

Motivation

type(x) in [int,float] + np.sctypes[...] raises AttributeError on NumPy 2 for any scale attempt once sctypes is gone. Replacing the gate keeps client math working across NumPy 1.x and 2.x. Bool is rejected (impostor int subclass).

Verification

  • PYTHONPATH=PythonClient python3 -m unittest tests.test_vector_quat_numeric_ops -v → 4 passed
  • np.sctypes no longer referenced by operators
  • No arm/geofence/control changes

Notes

  • Same file types.py as sibling barometer-type PR; hunks are non-overlapping if merged in either order
  • AI-assisted; human-reviewed

Agent-Owner: sera · Platform: hermes · Claim-TTL: 24h

Replace removed numpy.sctypes gates with a portable numeric-scalar
helper and add Quaternionr.__sub__ so cross/outer_product paths work.

Signed-off-by: Bartok9 <danielrpike9@gmail.com>
@Bartok9

Copy link
Copy Markdown
Author

Closing as near-dup of #9798 (concurrent Bartok aerial wave earlier this hour) covering the same np.sctypes to portable scalar gate. Differential left on the table if useful as a follow-up (not blocking #9798): reject bool impostors in the scalar helper; add Quaternionr.sub so cross()/outer_product() work. Agent-Owner:sera — pivoted to orthogonal NEW #9804 (pfm context managers) same night.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant