Function "addcyclic": IndexError
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- numpy, python
- Domain
- data-visualization
Research direction
Start by reproducing the reported call with the linked psi_p and lon data under Python 3.8.8, numpy 1.23.5, and Basemap 1.2.2. Then inspect mpl_toolkits/basemap/init.py around addcyclic and _addcyclic, especially the failing array indexing. Done means identifying a compatible fix or documenting the required input or version conditions that prevent the IndexError.
Written by the indexing model from the issue text.
Description
Hi, I am using "addcyclic" function and encounter the Index Error. Error details are:
IndexError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_11852/1134487354.py in
6 m.drawmeridians(np.arange(0.,360.,90.),linewidth=0.4,color='gray',labels=[True,True,True,True])
7 #在Py3.7下使用basemap==1.2.0,在循环填白addcyclic时可能会报错
----> 8 psi_p1,lon1=addcyclic(np.array(psi_p),np.array(lon))
9 lonsn, latsn = np.meshgrid(lon1, lat)
10 x_cyc,y_cyc=m(lonsn,latsn) #建立投影坐标映射D:\AnacondaSoftware\lib\site-packages\mpl_toolkits\basemap_init_.py in addcyclic(*arr, **kwargs)
5101 return _addcyclic_lon(arr[-1])
5102 else:
-> 5103 return list(map(_addcyclic,arr[:-1])) + [_addcyclic_lon(arr[-1])]
5104
5105 def _choosecorners(width,height,**kwargs):D:\AnacondaSoftware\lib\site-packages\mpl_toolkits\basemap_init_.py in _addcyclic(a)
5086 raise ValueError('The specified axis does not correspond to an '
5087 'array dimension.')
-> 5088 return npsel.concatenate((a,a[slicer]),axis=axis)
5089 def _addcyclic_lon(a):
5090 """addcyclic function for a single longitude array"""IndexError: only integers, slices (
:), ellipsis (...), numpy.newaxis (None) and integer or boolean arrays are valid indices
The code is:
psi_p1,lon1=addcyclic(np.array(psi_p),np.array(lon))
Here is the variable psi_p: https://box.nju.edu.cn/f/64583aedd0c24eae909d/
lon: https://box.nju.edu.cn/f/a273d137b454468c8007/
Software and module versions are: Python 3.8.8, numpy 1.23.5, basemap: 1.2.2
I am wondering whether it is due to inconsistency of package version? Is it possible to fix the bug without reinstall python or modules due to interdependence of a lot of my other modules. Thanks a lot!!
- Dominant language
- Python
- Stars
- 817
- Forks
- 395
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from matplotlib/basemap
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
matplotlib/basemap#368 ·
-
Python 3.14 wheels Open
Difficulty 4/5 3-5 days Newbie friendliness 48/100
matplotlib/basemap#652 · 2 comments · 5 reactions ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
matplotlib/basemap#649 · 2 reactions ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
matplotlib/basemap#646 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 48/100
matplotlib/basemap#645 · 2 comments ·
All issues in matplotlib/basemap
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100