4040
4141# field is field_name + conversion if any
4242M_SPECIFIER_PATTERN = re .compile (r'\{(?P<field>[^:}]*):(?P<format_spec>[^m}]*)m\}' )
43+ ICON_DIR = os .path .join (os .path .dirname (os .path .realpath (__file__ )), 'images' )
4344
4445logger = logging .getLogger ("editor" )
4546
@@ -240,17 +241,17 @@ def get_idx_rect(index_list):
240241
241242class IconManager :
242243 _icons = {'larray' : 'larray.ico' }
243- _icon_dir = os .path .join (os .path .dirname (os .path .realpath (__file__ )), 'images' )
244244
245245 def icon (self , ref ):
246246 if ref in self ._icons :
247- icon_path = os .path .join (self ._icon_dir , self ._icons [ref ])
247+ icon_path = os .path .join (ICON_DIR , self ._icons [ref ])
248+ assert os .path .exists (icon_path )
248249 return QIcon (icon_path )
249250 else :
250- # By default, only X11 will support themed icons. In order to use
251- # themed icons on Mac and Windows, you will have to bundle a compliant
252- # theme in one of your PySide. QtGui.QIcon.themeSearchPaths() and set the
253- # appropriate PySide. QtGui.QIcon.themeName() .
251+ # By default, only X11 supports themed icons. In order to use
252+ # themed icons on Mac and Windows, we need to bundle a
253+ # compliant theme in one of the QtGui.QIcon.themeSearchPaths()
254+ # directories and set QtGui.QIcon.themeName() accordingly .
254255 return QIcon .fromTheme (ref )
255256
256257
@@ -352,7 +353,8 @@ def __getitem__(self, key):
352353 key_isnan = np .isnan (key )[..., np .newaxis ]
353354 color = color0 + (color1 - color0 ) * normalized_value [..., np .newaxis ]
354355 color = np .where (key_isnan , self .nan_color .getHsvF (), color )
355- return from_hsvf (color [..., 0 ], color [..., 1 ], color [..., 2 ], color [..., 3 ])
356+ return from_hsvf (color [..., 0 ], color [..., 1 ], color [..., 2 ],
357+ color [..., 3 ])
356358
357359
358360class PlotDialog (QDialog ):
@@ -493,7 +495,8 @@ def __init__(self, list_name, parent_action=None, triggered=None):
493495 if self .settings .value (list_name ) is None :
494496 self .settings .setValue (list_name , [])
495497 if parent_action is not None :
496- actions = [QAction (parent_action ) for _ in range (self .MAX_RECENT_FILES )]
498+ actions = [QAction (parent_action )
499+ for _ in range (self .MAX_RECENT_FILES )]
497500 for action in actions :
498501 action .setVisible (False )
499502 if triggered is not None :
@@ -544,7 +547,8 @@ def _update_actions(self):
544547 action .setStatusTip (filepath )
545548 action .setData (filepath )
546549 action .setVisible (True )
547- # if we have less recent files than actions, hide the remaining actions
550+ # if we have less recent files than actions, hide the remaining
551+ # actions
548552 for action in self .actions [len (recent_files ):]:
549553 action .setVisible (False )
550554
@@ -553,7 +557,8 @@ def cached_property(must_invalidate_cache_method):
553557 """A decorator to cache class properties."""
554558 def getter_decorator (original_getter ):
555559 def caching_getter (self ):
556- if must_invalidate_cache_method (self ) or not hasattr (self , '_cached_property_values' ):
560+ if (must_invalidate_cache_method (self ) or
561+ not hasattr (self , '_cached_property_values' )):
557562 self ._cached_property_values = {}
558563 try :
559564 # cache hit
@@ -803,7 +808,7 @@ def get_func_name(frame):
803808 func_name = frame .f_code .co_name
804809 if 'self' in frame .f_locals :
805810 # We do not use Python 3.11+ frame.f_code.co_qualname because
806- # because it returns the (super) class where the method is
811+ # it returns the (super) class where the method is
807812 # defined, not the instance class which is usually much more useful
808813 func_name = f"{ frame .f_locals ['self' ].__class__ .__name__ } .{ func_name } "
809814 return func_name
0 commit comments