Skip to content
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

Spot an error of mplstereonet while using Google Colab #34

Closed
yohanesnuwara opened this issue Mar 20, 2020 · 5 comments
Closed

Spot an error of mplstereonet while using Google Colab #34

yohanesnuwara opened this issue Mar 20, 2020 · 5 comments

Comments

@yohanesnuwara
Copy link

Hi @joferkington, I just tried the code of basic usage in Google Colab 2 weeks ago and it succeeded, but when I re-try to plot in Google Colab again, I spot an error that I couldn't solve. It's related to code: ax = fig.add_subplot(111, projection='stereonet'). The error is as follows:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-13-5f249805830b> in <module>()
      3 
      4 fig = plt.figure()
----> 5 ax = fig.add_subplot(111, projection='stereonet')
      6 
      7 strike, dip = 315, 30

11 frames
/usr/local/lib/python3.6/dist-packages/mplstereonet/stereonet_transforms.py in transform_non_affine(self, ll)
     69     _inverse_type = 'BaseInvertedTransform'
     70     def transform_non_affine(self, ll):
---> 71         longitude = ll[:, 0:1]
     72         latitude  = ll[:, 1:2]
     73         clong = self._center_longitude

TypeError: tuple indices must be integers or slices, not tuple

I also attached my Colab notebook to you, link here. Is there something wrong or missing in my codes? Looking forward for your help :)

@fwrite
Copy link

fwrite commented Mar 20, 2020

Probably ll is expected to be a numpy.ndarray, but is a tuple instead. You might be able to trace back ll. As a quick fix you can cast it to an array (just like #20) locally? There has probably been some change in the API that remained unnoticed.

@yohanesnuwara
Copy link
Author

@fwrite thanks! I have found the issue of running mplstereonet in Google Colab using Python 3 runtime. I found mplstereonet working in Python 2 runtime instead.

@robgeotech
Copy link

robgeotech commented May 7, 2020

@yohanesnuwara
I had the same issue in Jupyter notebook (with Anacondo) after updating versions of Matplotlib (from 3.1.1 to 3.1.2) and Numpy. Updating to the development version of mplstereonet as referenced in another issue (#16 (comment)) seemed to solve the problem.

@ICWallis
Copy link

I had the same issue in VSCode and Juypter Lab (using Anaconda managed environments) also resolved by updating to the development version as linked above #16 . Thanks joferkington for making and updating this tool. It's been a great help to my doctoral research.

/opt/anaconda3/envs/Py36/lib/python3.6/site-packages/mplstereonet/stereonet_transforms.py in transform_non_affine(self, ll)
69 _inverse_type = 'BaseInvertedTransform'
70 def transform_non_affine(self, ll):
---> 71 longitude = ll[:, 0:1]
72 latitude = ll[:, 1:2]
73 clong = self._center_longitude

TypeError: tuple indices must be integers or slices, not tuple

@joferkington
Copy link
Owner

As other folks mentioned, this has been fixed in master for quite awhile, but things were long overdue for a release. v0.6 includes fixes for this, among other things, so a default pip install should work now. To upgrade to the current release, you can do either pip install 'mplstereonet==0.6.0' or pip install --upgrade mplstereonet

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

No branches or pull requests

5 participants