1212from matplotlib .patches import StepPatch as _StepPatch
1313from matplotlib .text import Text as _Text
1414import matplotlib .transforms as mtransforms
15- from matplotlib .collections import LineCollection as _LineCollection , PathCollection as _PathCollection
15+ from matplotlib .collections import (
16+ LineCollection as _LineCollection ,
17+ PathCollection as _PathCollection ,
18+ )
1619from matplotlib .artist import Artist as _Artist
1720
1821from data_prototype .containers import DataContainer , _MatplotlibTransform
@@ -60,7 +63,9 @@ def identity(**kwargs):
6063 (_ ,) = kwargs .values ()
6164 return _
6265
63- identity .__signature__ = inspect .Signature ([inspect .Parameter (k , inspect .Parameter .POSITIONAL_OR_KEYWORD )])
66+ identity .__signature__ = inspect .Signature (
67+ [inspect .Parameter (k , inspect .Parameter .POSITIONAL_OR_KEYWORD )]
68+ )
6469 return identity
6570
6671
@@ -116,7 +121,9 @@ def draw(self, renderer):
116121 def _update_wrapped (self , data ):
117122 raise NotImplementedError
118123
119- def _query_and_transform (self , renderer , * , xunits : List [str ], yunits : List [str ]) -> Dict [str , Any ]:
124+ def _query_and_transform (
125+ self , renderer , * , xunits : List [str ], yunits : List [str ]
126+ ) -> Dict [str , Any ]:
120127 """
121128 Helper to centralize the data querying and python-side transforms
122129
@@ -152,7 +159,9 @@ def _query_and_transform(self, renderer, *, xunits: List[str], yunits: List[str]
152159 self ._cache [cache_key ] = transformed_data
153160 return transformed_data
154161
155- def __init__ (self , data , converters : ConversionNode | list [ConversionNode ] | None , ** kwargs ):
162+ def __init__ (
163+ self , data , converters : ConversionNode | list [ConversionNode ] | None , ** kwargs
164+ ):
156165 super ().__init__ (** kwargs )
157166 self .data = data
158167 self ._cache = LFUCache (64 )
@@ -180,23 +189,43 @@ def __getattr__(self, key):
180189 return getattr (self ._wrapped_instance , key )
181190
182191 def __setattr__ (self , key , value ):
183- if key in ("_wrapped_instance" , "data" , "_cache" , "_converters" , "stale" , "_sigs" ):
192+ if key in (
193+ "_wrapped_instance" ,
194+ "data" ,
195+ "_cache" ,
196+ "_converters" ,
197+ "stale" ,
198+ "_sigs" ,
199+ ):
184200 super ().__setattr__ (key , value )
185- elif hasattr (self , "_wrapped_instance" ) and hasattr (self ._wrapped_instance , key ):
201+ elif hasattr (self , "_wrapped_instance" ) and hasattr (
202+ self ._wrapped_instance , key
203+ ):
186204 setattr (self ._wrapped_instance , key , value )
187205 else :
188206 super ().__setattr__ (key , value )
189207
190208
191209class LineWrapper (ProxyWrapper ):
192210 _wrapped_class = _Line2D
193- _privtized_methods = ("set_xdata" , "set_ydata" , "set_data" , "get_xdata" , "get_ydata" , "get_data" )
211+ _privtized_methods = (
212+ "set_xdata" ,
213+ "set_ydata" ,
214+ "set_data" ,
215+ "get_xdata" ,
216+ "get_ydata" ,
217+ "get_data" ,
218+ )
194219 required_keys = {"x" , "y" }
195220
196221 def __init__ (self , data : DataContainer , converters = None , / , ** kwargs ):
197222 super ().__init__ (data , converters )
198- self ._wrapped_instance = self ._wrapped_class (np .array ([]), np .array ([]), ** kwargs )
199- self ._converters .insert (- 1 , RenameConversionNode .from_mapping ({"x" : "xdata" , "y" : "ydata" }))
223+ self ._wrapped_instance = self ._wrapped_class (
224+ np .array ([]), np .array ([]), ** kwargs
225+ )
226+ self ._converters .insert (
227+ - 1 , RenameConversionNode .from_mapping ({"x" : "xdata" , "y" : "ydata" })
228+ )
200229 setters = [f [4 :] for f in dir (self ._wrapped_class ) if f .startswith ("set_" )]
201230 self ._converters [- 1 ] = LimitKeysConversionNode .from_keys (setters )
202231
@@ -252,7 +281,9 @@ class ImageWrapper(ProxyWrapper):
252281 _wrapped_class = _AxesImage
253282 required_keys = {"xextent" , "yextent" , "image" }
254283
255- def __init__ (self , data : DataContainer , converters = None , / , cmap = None , norm = None , ** kwargs ):
284+ def __init__ (
285+ self , data : DataContainer , converters = None , / , cmap = None , norm = None , ** kwargs
286+ ):
256287 converters = converters or []
257288 if cmap is not None or norm is not None :
258289 if converters is not None and "image" in converters :
@@ -261,7 +292,11 @@ def __init__(self, data: DataContainer, converters=None, /, cmap=None, norm=None
261292 cmap = mpl .colormaps ["viridis" ]
262293 if norm is None :
263294 raise ValueError ("not sure how to do autoscaling yet" )
264- converters .append (FunctionConversionNode .from_funcs ({"image" : lambda image : cmap (norm (image ))}))
295+ converters .append (
296+ FunctionConversionNode .from_funcs (
297+ {"image" : lambda image : cmap (norm (image ))}
298+ )
299+ )
265300 super ().__init__ (data , converters )
266301 kwargs .setdefault ("origin" , "lower" )
267302 self ._wrapped_instance = self ._wrapped_class (None , ** kwargs )
@@ -341,7 +376,9 @@ def __setattr__(self, key, value):
341376 super ().__setattr__ (key , value )
342377 if hasattr (self , "_wrapped_instances" ):
343378 # We can end up with out wrapped instance as part of init
344- children_have_attrs = [hasattr (c , key ) for c in self ._wrapped_instances .values ()]
379+ children_have_attrs = [
380+ hasattr (c , key ) for c in self ._wrapped_instances .values ()
381+ ]
345382 if any (children_have_attrs ):
346383 if not all (children_have_attrs ):
347384 raise Exception ("mixed attributes 😱" )
@@ -356,7 +393,9 @@ def get_children(self):
356393
357394class ErrorbarWrapper (MultiProxyWrapper ):
358395 required_keys = {"x" , "y" }
359- expected_keys = {f"{ axis } { dirc } " for axis in ["x" , "y" ] for dirc in ["upper" , "lower" ]}
396+ expected_keys = {
397+ f"{ axis } { dirc } " for axis in ["x" , "y" ] for dirc in ["upper" , "lower" ]
398+ }
360399
361400 def __init__ (self , data : DataContainer , converters = None , / , ** kwargs ):
362401 super ().__init__ (data , converters )
@@ -387,7 +426,9 @@ def __init__(self, data: DataContainer, converters=None, /, **kwargs):
387426 def draw (self , renderer ):
388427 self ._update_wrapped (
389428 self ._query_and_transform (
390- renderer , xunits = ["x" , "xupper" , "xlower" ], yunits = ["y" , "yupper" , "ylower" ]
429+ renderer ,
430+ xunits = ["x" , "xupper" , "xlower" ],
431+ yunits = ["y" , "yupper" , "ylower" ],
391432 ),
392433 )
393434 for k , v in self ._wrapped_instances .items ():
0 commit comments