diff --git a/matplotview/_docs.py b/matplotview/_docs.py index acea1f2..5753df5 100644 --- a/matplotview/_docs.py +++ b/matplotview/_docs.py @@ -5,7 +5,7 @@ def dynamic_doc_string(**kwargs): def convert(func): default_vals = { k: v.default for k, v in inspect.signature(func).parameters.items() - if(v.default is not inspect.Parameter.empty) + if (v.default is not inspect.Parameter.empty) } default_vals.update(kwargs) func.__doc__ = func.__doc__.format(**default_vals) @@ -18,6 +18,6 @@ def convert(func): def get_interpolation_list_str(): from matplotlib.image import _interpd_ return ", ".join([ - f"'{k}'" if(i != len(_interpd_) - 1) else f"or '{k}'" + f"'{k}'" if (i != len(_interpd_) - 1) else f"or '{k}'" for i, k in enumerate(_interpd_) ]) diff --git a/matplotview/_transform_renderer.py b/matplotview/_transform_renderer.py index 8c6e747..a61d1ba 100644 --- a/matplotview/_transform_renderer.py +++ b/matplotview/_transform_renderer.py @@ -105,7 +105,7 @@ def _scale_gc(self, gc: GraphicsContextBase) -> GraphicsContextBase: unit_box = transfer_transform.transform_bbox(unit_box) mult_factor = np.sqrt(unit_box.width * unit_box.height) - if(mult_factor == 0 or (not np.isfinite(mult_factor))): + if (mult_factor == 0 or (not np.isfinite(mult_factor))): return new_gc new_gc.set_linewidth(gc.get_linewidth() * mult_factor) @@ -218,18 +218,18 @@ def draw_path( # We check if the path intersects the axes box at all, if not don't # waste time drawing it. - if(not path.intersects_bbox(bbox, True)): + if (not path.intersects_bbox(bbox, True)): return - if(self.__scale_widths): + if (self.__scale_widths): gc = self._scale_gc(gc) # Change the clip to the sub-axes box gc.set_clip_rectangle(bbox) - if(not isinstance(self.__bounding_axes.patch, Rectangle)): + if (not isinstance(self.__bounding_axes.patch, Rectangle)): gc.set_clip_path(TransformedPatchPath(self.__bounding_axes.patch)) - rgbFace = tuple(rgbFace) if(rgbFace is not None) else None + rgbFace = tuple(rgbFace) if (rgbFace is not None) else None self.__renderer.draw_path(gc, path, IdentityTransform(), rgbFace) @@ -244,7 +244,7 @@ def _draw_text_as_path( ismath: bool ): # If the text field is empty, don't even try rendering it... - if((s is None) or (s.strip() == "")): + if ((s is None) or (s.strip() == "")): return # Call the super class instance, which works for all cases except one @@ -264,14 +264,14 @@ def draw_gouraud_triangle( path = Path(points, closed=True) bbox = self._get_axes_display_box() - if(not path.intersects_bbox(bbox, True)): + if (not path.intersects_bbox(bbox, True)): return - if(self.__scale_widths): + if (self.__scale_widths): gc = self._scale_gc(gc) gc.set_clip_rectangle(bbox) - if(not isinstance(self.__bounding_axes.patch, Rectangle)): + if (not isinstance(self.__bounding_axes.patch, Rectangle)): gc.set_clip_path(TransformedPatchPath(self.__bounding_axes.patch)) self.__renderer.draw_gouraud_triangle(gc, path.vertices, colors, @@ -299,7 +299,7 @@ def draw_image( out_box = img_bbox_disp.transformed(shift_data_transform) clipped_out_box = Bbox.intersection(out_box, axes_bbox) - if(clipped_out_box is None): + if (clipped_out_box is None): return # We compute what the dimensions of the final output image within the @@ -307,7 +307,7 @@ def draw_image( x, y, out_w, out_h = clipped_out_box.bounds out_w, out_h = int(np.ceil(out_w * mag)), int(np.ceil(out_h * mag)) - if((out_w <= 0) or (out_h <= 0)): + if ((out_w <= 0) or (out_h <= 0)): return # We can now construct the transform which converts between the @@ -330,16 +330,16 @@ def draw_image( alpha=1) out_arr[:, :, 3] = trans_msk - if(self.__scale_widths): + if (self.__scale_widths): gc = self._scale_gc(gc) gc.set_clip_rectangle(clipped_out_box) - if(not isinstance(self.__bounding_axes.patch, Rectangle)): + if (not isinstance(self.__bounding_axes.patch, Rectangle)): gc.set_clip_path(TransformedPatchPath(self.__bounding_axes.patch)) x, y = clipped_out_box.x0, clipped_out_box.y0 - if(self.option_scale_image()): + if (self.option_scale_image()): self.__renderer.draw_image(gc, x, y, out_arr, None) else: self.__renderer.draw_image(gc, x, y, out_arr) diff --git a/matplotview/_view_axes.py b/matplotview/_view_axes.py index c9162ea..f0b47a9 100644 --- a/matplotview/_view_axes.py +++ b/matplotview/_view_axes.py @@ -53,14 +53,14 @@ def draw(self, renderer: RendererBase): # If we are working with a 3D object, swap out it's axes with # this zoom axes (swapping out the 3d transform) and reproject it. - if(hasattr(self._artist, "do_3d_projection")): + if (hasattr(self._artist, "do_3d_projection")): self.do_3d_projection() # Check and see if the passed limiting box and extents of the # artist intersect, if not don't bother drawing this artist. # First 2 checks are a special case where we received a bad clip box. # (those can happen when we try to get the bounds of a map projection) - if( + if ( self._clip_box.width == 0 or self._clip_box.height == 0 or Bbox.intersection(full_extents, self._clip_box) is not None ): @@ -128,7 +128,7 @@ class ViewSpecification: def __post_init__(self): self.image_interpolation = str(self.image_interpolation) - if(self.filter_set is not None): + if (self.filter_set is not None): self.filter_set = set(self.filter_set) self.scale_lines = bool(self.scale_lines) @@ -138,7 +138,6 @@ class __ViewType: PRIVATE: A simple identifier class for identifying view types, a view will inherit from the axes class it is wrapping and this type... """ - ... # Cache classes so grabbing the same type twice leads to actually getting the @@ -162,7 +161,7 @@ def view_wrapper(axes_class: Type[Axes]) -> Type[Axes]: another axes contents... """ # If the passed class is a view, simply return it. - if(issubclass(axes_class, Axes) and issubclass(axes_class, __ViewType)): + if (issubclass(axes_class, Axes) and issubclass(axes_class, __ViewType)): return axes_class class View(axes_class, __ViewType): @@ -228,14 +227,14 @@ def get_children(self) -> List[Artist]: child_list = super().get_children() def filter_check(artist, filter_set): - if(filter_set is None): + if (filter_set is None): return True return ( (artist not in filter_set) and (type(artist) not in filter_set) ) - if(self.__renderer is not None): + if (self.__renderer is not None): for ax, spec in self.view_specifications.items(): mock_renderer = _TransformRenderer( self.__renderer, ax.transData, self.transData, @@ -253,7 +252,7 @@ def filter_check(artist, filter_set): for a in itertools.chain( ax._children, ax.child_axes - ) if(filter_check(a, spec.filter_set)) + ) if (filter_check(a, spec.filter_set)) ]) return child_list @@ -262,7 +261,7 @@ def draw(self, renderer: RendererBase = None): # It is possible to have two axes which are views of each other # therefore we track the number of recursions and stop drawing # at a certain depth - if(self.figure._current_render_depth >= self.__max_render_depth): + if (self.figure._current_render_depth >= self.__max_render_depth): return self.figure._current_render_depth += 1 # Set the renderer, causing get_children to return the view's @@ -281,7 +280,7 @@ def __reduce__(self): cls = type(self) args = tuple( - arg if(arg != cls) else cls.__bases__[0] for arg in args + arg if (arg != cls) else cls.__bases__[0] for arg in args ) return ( @@ -318,7 +317,7 @@ def set_max_render_depth(self, val: int): allow. Zero and negative values are invalid, and will raise a ValueError. """ - if(val <= 0): + if (val <= 0): raise ValueError(f"Render depth must be positive, not {val}.") self.__max_render_depth = val @@ -376,12 +375,12 @@ def from_axes( If the provided axes to convert has an Axes type which does not match the axes class this view type wraps. """ - if(isinstance(axes, cls)): - if(render_depth is not None): + if (isinstance(axes, cls)): + if (render_depth is not None): axes.set_max_render_depth(render_depth) return axes - if(type(axes) != axes_class): + if (type(axes) is not axes_class): raise TypeError( f"Can't convert {type(axes).__name__} to {cls.__name__}" ) @@ -389,7 +388,7 @@ def from_axes( axes.__class__ = cls axes._init_vars( DEFAULT_RENDER_DEPTH - if(render_depth is None) + if (render_depth is None) else render_depth ) return axes diff --git a/matplotview/tests/test_view_obj.py b/matplotview/tests/test_view_obj.py index 5eb6067..c356664 100644 --- a/matplotview/tests/test_view_obj.py +++ b/matplotview/tests/test_view_obj.py @@ -18,8 +18,9 @@ def test_obj_comparison(): assert view_class1 is view_class2 assert view_class1 == view_class2 - if(mpl_version >= (3, 7)): - # As of 3.7.0, the subplot class no longer exists, and is an alias to the Axes class... + if (mpl_version >= (3, 7)): + # As of 3.7.0, the subplot class no longer exists, and is an alias + # to the Axes class... assert view_class2 == view_class3 else: assert view_class2 != view_class3 diff --git a/setup.py b/setup.py index b62ee79..2f0e9c4 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ import setuptools -VERSION = "1.0.0" +VERSION = "1.0.1" with open("README.md", "r", encoding="utf-8") as fh: long_description = fh.read()