1919from .core import ImageArray
2020
2121
22- def _prep_figure (self , kargs ):
23- plts = kargs .pop ("plots_per_page" , getattr (self , "plots_per_page" , len (self )))
22+ def _prep_figure (self , kwargs ):
23+ plts = kwargs .pop ("plots_per_page" , getattr (self , "plots_per_page" , len (self )))
2424 self .plots_per_page = plts
2525 plts = min (plts , len (self ))
2626
27- fig_num = kargs .pop ("figure" , getattr (self , "_figure" , None ))
27+ fig_num = kwargs .pop ("figure" , getattr (self , "_figure" , None ))
2828 if isinstance (fig_num , Figure ):
29- kargs .setdefault ("figsize" , tuple (fig_num .get_size_inches ()))
30- kargs .setdefault ("facecolor" , fig_num .get_facecolor ())
31- kargs .setdefault ("edgecolor" , fig_num .get_edgecolor ())
32- kargs .setdefault ("frameon" , fig_num .get_frameon ())
33- kargs .setdefault ("FigureClass" , fig_num .__class__ )
29+ kwargs .setdefault ("figsize" , tuple (fig_num .get_size_inches ()))
30+ kwargs .setdefault ("facecolor" , fig_num .get_facecolor ())
31+ kwargs .setdefault ("edgecolor" , fig_num .get_edgecolor ())
32+ kwargs .setdefault ("frameon" , fig_num .get_frameon ())
33+ kwargs .setdefault ("FigureClass" , fig_num .__class__ )
3434 fig_num = fig_num .number
3535
3636 fig_args = getattr (self , "_fig_args" , [])
37- fig_kargs = getattr (self , "_fig_kargs " , {"layout" : "constrained" })
37+ fig_kwargs = getattr (self , "_fig_kwargs " , {"layout" : "constrained" })
3838 for arg in ("figsize" , "dpi" , "facecolor" , "edgecolor" , "frameon" , "FigureClass" ):
39- if arg in kargs :
40- fig_kargs [arg ] = kargs .pop (arg )
39+ if arg in kwargs :
40+ fig_kwargs [arg ] = kwargs .pop (arg )
4141 if fig_num is None :
42- fig = figure (* fig_args , ** fig_kargs )
42+ fig = figure (* fig_args , ** fig_kwargs )
4343 elif fig_num in get_fignums ():
4444 fig = figure (fig_num )
4545 else :
46- fig = figure (fig_num , ** fig_kargs )
47- kargs ["figure" ] = fig_num
46+ fig = figure (fig_num , ** fig_kwargs )
47+ kwargs ["figure" ] = fig_num
4848 return fig , plts
4949
5050
@@ -138,7 +138,7 @@ def __getter__(self, name, instantiate=True):
138138 ret ._title = name
139139 return ret
140140
141- def align (self , * args , ** kargs ):
141+ def align (self , * args , ** kwargs ):
142142 """Align each image in the folder to the reference image.
143143
144144 Args:
@@ -184,7 +184,7 @@ def align(self, *args, **kargs):
184184 except (TypeError , ValueError ) as err :
185185 raise TypeError (f"Cannot interpret { type (ref )} as reference image data." ) from err
186186 # Call align on each object
187- self .each .align (ref_data , ** kargs )
187+ self .each .align (ref_data , ** kwargs )
188188 limits = self .metadata .slice ("translation_limits" , output = "array" )
189189 stack_limits = np .zeros (4 )
190190 stack_limits [::2 ] = limits .max (axis = 0 )[::2 ]
@@ -195,7 +195,7 @@ def align(self, *args, **kargs):
195195 self .metadata ["align_box" ] = tuple (stack_limits .astype (int ))
196196 return self
197197
198- def apply_all (self , func , * args , ** kargs ):
198+ def apply_all (self , func , * args , ** kwargs ):
199199 """Apply function to all images in the stack.
200200
201201 Args:
@@ -205,10 +205,10 @@ def apply_all(self, func, *args, **kargs):
205205 if False print '.' for every iteration
206206
207207 Note:
208- Further args, kargs are passed through to the function
208+ Further args, kwargs are passed through to the function
209209 """
210210 warn ("apply_all is deprecated and will be removed in a future version. Use ImageFolder.each() instead" )
211- return self .each (func , * args , ** kargs )
211+ return self .each (func , * args , ** kwargs )
212212
213213 def average (self , weights = None , _box = False , _metadata = "first" ):
214214 """Get an array of average pixel values for the stack.
@@ -256,9 +256,9 @@ def as_stack(self):
256256 return k
257257
258258 @classmethod
259- def from_tiff (cls , filename , ** kargs ):
259+ def from_tiff (cls , filename , ** kwargs ):
260260 """Create a new ImageArray from a tiff file."""
261- self = cls (** kargs )
261+ self = cls (** kwargs )
262262 with Image .open (filename , "r" ) as img :
263263 tags = img .tag_v2
264264 if 270 in tags :
@@ -321,12 +321,12 @@ def mean(self, _box=False, _metadata="first"):
321321 """
322322 return self .average (_box = _box , _metadata = _metadata )
323323
324- def montage (self , * args , ** kargs ):
324+ def montage (self , * args , ** kwargs ):
325325 """Call the plot method for each metadataObject, but switching to a subplot each time.
326326
327327 Args:
328328 args: Positional arguments to pass through to the :py:meth:`Stoner.plot.PlotMixin.plot` call.
329- kargs : Keyword arguments to pass through to the :py:meth:`Stoner.plot.PlotMixin.plot` call.
329+ kwargs : Keyword arguments to pass through to the :py:meth:`Stoner.plot.PlotMixin.plot` call.
330330
331331 Keyword Arguments:
332332 plot_extra (callable(i,j,d)):
@@ -355,36 +355,36 @@ def montage(self, *args, **kargs):
355355 Each plot is generated as sub-plot on a page. The number of rows and columns of subplots is computed
356356 from the aspect ratio of the figure and the number of files in the :py:class:`PlotFolder`.
357357 """
358- fig , plts = _prep_figure (self , kargs )
358+ fig , plts = _prep_figure (self , kwargs )
359359
360- plot_extra = kargs .pop ("plot_extra" , lambda i , j , d : None )
360+ plot_extra = kwargs .pop ("plot_extra" , lambda i , j , d : None )
361361
362362 w , h = fig .get_size_inches ()
363363 plt_x = int (np .floor (np .sqrt (plts ) * w / h ))
364364 plt_y = int (np .ceil (plts / plt_x ))
365365
366- kargs ["figure" ] = fig
366+ kwargs ["figure" ] = fig
367367 ret = []
368368 j = 0
369369 fignum = fig .number
370370 for i , d in enumerate (self ):
371- plt_kargs = copy (kargs )
371+ plt_kwargs = copy (kwargs )
372372 if i % plts == 0 and i != 0 :
373- fig , _ = _prep_figure (self , kargs )
373+ fig , _ = _prep_figure (self , kwargs )
374374 fignum = fig .number
375375 j = 1
376376 else :
377377 j += 1
378378 fig = figure (fignum )
379379 ax = subplot (plt_y , plt_x , j )
380- plt_kargs ["figure" ] = fig
381- plt_kargs ["ax" ] = ax
382- if "title" in kargs :
383- if isinstance (kargs ["title" ], str ):
384- plt_kargs ["title" ] = kargs ["title" ].format (** d )
385- elif callable (kargs ["title" ]):
386- plt_kargs ["title" ] = kargs ["title" ](d )
387- ret .append (d .imshow (* args , ** plt_kargs ))
380+ plt_kwargs ["figure" ] = fig
381+ plt_kwargs ["ax" ] = ax
382+ if "title" in kwargs :
383+ if isinstance (kwargs ["title" ], str ):
384+ plt_kwargs ["title" ] = kwargs ["title" ].format (** d )
385+ elif callable (kwargs ["title" ]):
386+ plt_kwargs ["title" ] = kwargs ["title" ](d )
387+ ret .append (d .imshow (* args , ** plt_kwargs ))
388388 plot_extra (i , j , d )
389389 return ret
390390
0 commit comments