ProjectPythia / pythia-foundations

Jupyterbook source for the Foundations collection
http://foundations.projectpythia.org
Apache License 2.0
61 stars 43 forks source link

Shorten build time of Foundations book #206

Closed ktyle closed 2 years ago

ktyle commented 2 years ago

A significant time-suck when building the Foundations book (either on a local install or as a part of our CI suite) is during the rendering of the Intro to Cartopy notebook.

This is almost entirely within the https://foundations.projectpythia.org/core/cartopy/cartopy.html#create-a-regional-map-centered-over-new-york-state section. It is due to very slow performance when plotting the Oceans Cartopy Feature, noted here. The referenced issue now has a workaround which greatly reduces the time-to-plot.

Although it is useful to have an actual example of slow performance, so learners are not surprised when they run this or similar code, now that there is a workaround I think it's prudent to revise this notebook, while including an admonition about what would happen if the code remained as currently written.

Unless anyone objects, I'll plan on submitting a PR to correct this (a PR looks to be necessary regardless since I notice that the notebook currently leads off with this error: )

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Input In [1], in <module>
     47     plt.show()
     50 if __name__ == '__main__':
---> 51     main()

Input In [1], in main()
     29 logo_path = matplotlib.textpath.TextPath((-175, -35), 'cartopy', size=1, prop=fp)
     30 # scale the letters up to sensible longitude and latitude sizes
---> 31 logo_path._vertices *= np.array([80, 160])
     33 # add a background image
     34 im = ax.stock_img()

ValueError: output array is read-only
brian-rose commented 2 years ago

+1 for speeding up the builds!

brian-rose commented 2 years ago

@ktyle it looks like the Cartopy logo image file was not included in PR #209 so https://foundations.projectpythia.org/core/cartopy/cartopy.html is now showing an empty image.

ktyle commented 2 years ago

@brian-rose Yes I independently just noticed that as well! #212 should resolve this.

brian-rose commented 2 years ago

Resolved! I think we can close this issue now.