-
Notifications
You must be signed in to change notification settings - Fork 186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError 'numpy._DTypeMeta' object is not subscriptable #2025
Comments
Any thoughts on how to fix this @mathgeekcoder ? |
Oh interesting. Python typing support seems a little troublesome. Since I can't reproduce, @lukegwoolley, can you please try to modify your highs.py, and see if this works for you? # backwards typing support information for HighspyArray
if sys.version_info >= (3, 9):
from typing import TypeAlias
obj_type: TypeAlias = 'np.dtype[np.object_]'
ndarray_object_type = np.ndarray[Any, obj_type]
else:
ndarray_object_type = np.ndarray If that works, I can make a new PR with some relevant fixes. BTW: You can import the |
I had a play around with the code and I think the issue is the sys.version issue is wrong. The below code works for me in python 3.10 and 3.12 but I wasnt able to test for 3.11.
|
Thanks @lukegwoolley. Did you happen to test the code I sent? Can you confirm if it didn't work? Updating that version check just disables the numpy typing for your python 3.10. According to the docs, this typing should be supported in 3.10. Also, do you know if there's anything special about your environment? I'm wondering since this error wasn't picked up in our CI build - which also tests the python wheel on many different versions. |
Happens on both latest numpy version and numpy 1.21.5
Error sits in this line:
File /local_disk0/.ephemeral_nfs/cluster_libraries/python/lib/python3.10/site-packages/highspy/highs.py:21
19 # backwards typing support information for HighspyArray
20 if sys.version_info >= (3, 9):
---> 21 ndarray_object_type = np.ndarray[Any, np.dtype[np.object_]]
The text was updated successfully, but these errors were encountered: