1717
1818import numpy as np
1919from pygmt .clib import Session
20- from pygmt .exceptions import GMTError , GMTInvalidInput
20+ from pygmt .exceptions import GMTInvalidInput
2121from pygmt .helpers import launch_external_viewer , unique_name
2222
2323
@@ -331,11 +331,12 @@ def show(
331331 match method :
332332 case "notebook" :
333333 if not _HAS_IPYTHON :
334- raise GMTError (
334+ msg = (
335335 "Notebook display is selected, but IPython is not available. "
336336 "Make sure you have IPython installed, "
337337 "or run the script in a Jupyter notebook."
338338 )
339+ raise ImportError (msg )
339340 png = self ._preview (
340341 fmt = "png" , dpi = dpi , anti_alias = True , as_bytes = True , ** kwargs
341342 )
@@ -344,14 +345,15 @@ def show(
344345 pdf = self ._preview (
345346 fmt = "pdf" , dpi = dpi , anti_alias = False , as_bytes = False , ** kwargs
346347 )
347- launch_external_viewer (pdf , waiting = waiting ) # type: ignore[arg-type]
348+ launch_external_viewer (pdf , waiting = waiting )
348349 case "none" :
349350 pass # Do nothing
350351 case _:
351- raise GMTInvalidInput (
352- f"Invalid display method '{ method } '. Valid values are 'external', "
353- "'notebook', 'none' or None."
352+ msg = (
353+ f"Invalid display method '{ method } '. "
354+ "Valid values are 'external', 'notebook', 'none' or None."
354355 )
356+ raise GMTInvalidInput (msg )
355357
356358 def _preview (self , fmt : str , dpi : int , as_bytes : bool = False , ** kwargs ):
357359 """
@@ -400,7 +402,7 @@ def _repr_html_(self):
400402 html = '<img src="data:image/png;base64,{image}" width="{width}px">'
401403 return html .format (image = base64_png .decode ("utf-8" ), width = 500 )
402404
403- from pygmt .src import ( # type: ignore [misc]
405+ from pygmt .src import ( # type: ignore[misc]
404406 basemap ,
405407 coast ,
406408 colorbar ,
0 commit comments