AttributeError Traceback (most recent call last) Cell In[37], line 36 34 #%% 35 Pano_len = len(Pano_set_org) ---> 36 path_mat = np.zeros([Pano_len,Pano_len]).astype(np.bool) 37 for ind in list(Pano_set_org): 38 match_all_pd_start = match_all_pd_current[match_all_pd_current.pic_id1 == ind] File C:\Anaconda3\envs\pytorch\lib\site-packages\numpy\__init__.py:305, in __getattr__(attr) 300 warnings.warn( 301 f"In the future `np.{attr}` will be defined as the " 302 "corresponding NumPy scalar.", FutureWarning, stacklevel=2) 304 if attr in __former_attrs__: --> 305 raise AttributeError(__former_attrs__[attr]) 307 # Importing Tester requires importing all of UnitTest which is not a 308 # cheap import Since it is mainly used in test suits, we lazy import it 309 # here to save on the order of 10 ms of import time for most users 310 # 311 # The previous way Tester was imported also had a side effect of adding 312 # the full `numpy.testing` namespace 313 if attr == 'testing': AttributeError: module 'numpy' has no attribute 'bool'. `np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here. The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
时间: 2024-02-14 20:19:03 浏览: 50
这个错误是因为你使用了已经被弃用的np.bool,你需要将其改为Python内置的bool类型。你可以将代码中的以下语句:
```
path_mat = np.zeros([Pano_len,Pano_len]).astype(np.bool)
```
改为:
```
path_mat = np.zeros([Pano_len,Pano_len], dtype=bool)
```
这样就可以避免这个错误了。
相关问题
AttributeError Traceback (most recent call last
This error occurs when you try to access an attribute or method that does not exist in the object you are using.
To fix this error, you should check the spelling and syntax of the attribute or method you are trying to access. Make sure that it exists in the object you are using. If you are not sure, you can use the `dir()` function to list all the attributes and methods of the object.
If the attribute or method is supposed to exist but is still giving you an error, it could be a problem with the object itself. In this case, you may need to check the documentation or seek help from the developer community.
AttributeError Traceback (most recent call last)
This error occurs when you try to access an attribute or method that does not exist in the object you are working with. It is a common error in Python and can be caused by various reasons such as typos, incorrect usage of variables or objects, or missing imports.
To fix this error, you should carefully check your code and ensure that all the attributes and methods you are calling actually exist in the object you are working with. If you are still unable to find the error, you can try printing out the object and its attributes to see what is going wrong.