Skip to content

fix(python): restore Vector3r/Quaternionr scalar ops on NumPy 2#9798

Open
Bartok9 wants to merge 1 commit into
microsoft:mainfrom
Bartok9:aerial/fix-numpy2-sctypes-20260722
Open

fix(python): restore Vector3r/Quaternionr scalar ops on NumPy 2#9798
Bartok9 wants to merge 1 commit into
microsoft:mainfrom
Bartok9:aerial/fix-numpy2-sctypes-20260722

Conversation

@Bartok9

@Bartok9 Bartok9 commented Jul 22, 2026

Copy link
Copy Markdown

Summary

NumPy 2 removed np.sctypes. AirSim's Vector3r / Quaternionr mul and div helpers still consulted that table, so any scalar math against numpy integers/floats raised AttributeError under current defaults.

This swaps the check for an isinstance-based _is_real_number helper covering Python int/float and np.integer / np.floating. msgpackrpc import is optional so the new offline unit tests can run without the full RPC stack.

Motivation

Python 3.12+ environments commonly ship NumPy ≥2. Without this, simple client-side geometry helpers break before simGet* is even called.

Verification

python3 PythonClient/airsim/tests/test_types_numpy2_scalars.py -v
# 6 tests OK

AI-assisted; human-reviewed.

np.sctypes was removed in NumPy 2.0, so mul/div against numpy scalars
raised AttributeError. Use isinstance checks for int/float and
np.integer/np.floating. Make msgpackrpc import optional so type math
unit tests can run without the full RPC stack. Add offline unit tests.

Signed-off-by: Bartok9 <danielrpike9@gmail.com>
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