Skip to content

Commit b4bb567

Browse files
Merge pull request #5 from matplotlib/develop
PEP-8 Compliance, support for latest matplotlib versions.
2 parents e23934c + 6e3bca8 commit b4bb567

File tree

5 files changed

+34
-34
lines changed

5 files changed

+34
-34
lines changed

matplotview/_docs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ def dynamic_doc_string(**kwargs):
55
def convert(func):
66
default_vals = {
77
k: v.default for k, v in inspect.signature(func).parameters.items()
8-
if(v.default is not inspect.Parameter.empty)
8+
if (v.default is not inspect.Parameter.empty)
99
}
1010
default_vals.update(kwargs)
1111
func.__doc__ = func.__doc__.format(**default_vals)
@@ -18,6 +18,6 @@ def convert(func):
1818
def get_interpolation_list_str():
1919
from matplotlib.image import _interpd_
2020
return ", ".join([
21-
f"'{k}'" if(i != len(_interpd_) - 1) else f"or '{k}'"
21+
f"'{k}'" if (i != len(_interpd_) - 1) else f"or '{k}'"
2222
for i, k in enumerate(_interpd_)
2323
])

matplotview/_transform_renderer.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def _scale_gc(self, gc: GraphicsContextBase) -> GraphicsContextBase:
105105
unit_box = transfer_transform.transform_bbox(unit_box)
106106
mult_factor = np.sqrt(unit_box.width * unit_box.height)
107107

108-
if(mult_factor == 0 or (not np.isfinite(mult_factor))):
108+
if (mult_factor == 0 or (not np.isfinite(mult_factor))):
109109
return new_gc
110110

111111
new_gc.set_linewidth(gc.get_linewidth() * mult_factor)
@@ -218,18 +218,18 @@ def draw_path(
218218

219219
# We check if the path intersects the axes box at all, if not don't
220220
# waste time drawing it.
221-
if(not path.intersects_bbox(bbox, True)):
221+
if (not path.intersects_bbox(bbox, True)):
222222
return
223223

224-
if(self.__scale_widths):
224+
if (self.__scale_widths):
225225
gc = self._scale_gc(gc)
226226

227227
# Change the clip to the sub-axes box
228228
gc.set_clip_rectangle(bbox)
229-
if(not isinstance(self.__bounding_axes.patch, Rectangle)):
229+
if (not isinstance(self.__bounding_axes.patch, Rectangle)):
230230
gc.set_clip_path(TransformedPatchPath(self.__bounding_axes.patch))
231231

232-
rgbFace = tuple(rgbFace) if(rgbFace is not None) else None
232+
rgbFace = tuple(rgbFace) if (rgbFace is not None) else None
233233

234234
self.__renderer.draw_path(gc, path, IdentityTransform(), rgbFace)
235235

@@ -244,7 +244,7 @@ def _draw_text_as_path(
244244
ismath: bool
245245
):
246246
# If the text field is empty, don't even try rendering it...
247-
if((s is None) or (s.strip() == "")):
247+
if ((s is None) or (s.strip() == "")):
248248
return
249249

250250
# Call the super class instance, which works for all cases except one
@@ -264,14 +264,14 @@ def draw_gouraud_triangle(
264264
path = Path(points, closed=True)
265265
bbox = self._get_axes_display_box()
266266

267-
if(not path.intersects_bbox(bbox, True)):
267+
if (not path.intersects_bbox(bbox, True)):
268268
return
269269

270-
if(self.__scale_widths):
270+
if (self.__scale_widths):
271271
gc = self._scale_gc(gc)
272272

273273
gc.set_clip_rectangle(bbox)
274-
if(not isinstance(self.__bounding_axes.patch, Rectangle)):
274+
if (not isinstance(self.__bounding_axes.patch, Rectangle)):
275275
gc.set_clip_path(TransformedPatchPath(self.__bounding_axes.patch))
276276

277277
self.__renderer.draw_gouraud_triangle(gc, path.vertices, colors,
@@ -299,15 +299,15 @@ def draw_image(
299299
out_box = img_bbox_disp.transformed(shift_data_transform)
300300
clipped_out_box = Bbox.intersection(out_box, axes_bbox)
301301

302-
if(clipped_out_box is None):
302+
if (clipped_out_box is None):
303303
return
304304

305305
# We compute what the dimensions of the final output image within the
306306
# sub-axes are going to be.
307307
x, y, out_w, out_h = clipped_out_box.bounds
308308
out_w, out_h = int(np.ceil(out_w * mag)), int(np.ceil(out_h * mag))
309309

310-
if((out_w <= 0) or (out_h <= 0)):
310+
if ((out_w <= 0) or (out_h <= 0)):
311311
return
312312

313313
# We can now construct the transform which converts between the
@@ -330,16 +330,16 @@ def draw_image(
330330
alpha=1)
331331
out_arr[:, :, 3] = trans_msk
332332

333-
if(self.__scale_widths):
333+
if (self.__scale_widths):
334334
gc = self._scale_gc(gc)
335335

336336
gc.set_clip_rectangle(clipped_out_box)
337-
if(not isinstance(self.__bounding_axes.patch, Rectangle)):
337+
if (not isinstance(self.__bounding_axes.patch, Rectangle)):
338338
gc.set_clip_path(TransformedPatchPath(self.__bounding_axes.patch))
339339

340340
x, y = clipped_out_box.x0, clipped_out_box.y0
341341

342-
if(self.option_scale_image()):
342+
if (self.option_scale_image()):
343343
self.__renderer.draw_image(gc, x, y, out_arr, None)
344344
else:
345345
self.__renderer.draw_image(gc, x, y, out_arr)

matplotview/_view_axes.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ def draw(self, renderer: RendererBase):
5353

5454
# If we are working with a 3D object, swap out it's axes with
5555
# this zoom axes (swapping out the 3d transform) and reproject it.
56-
if(hasattr(self._artist, "do_3d_projection")):
56+
if (hasattr(self._artist, "do_3d_projection")):
5757
self.do_3d_projection()
5858

5959
# Check and see if the passed limiting box and extents of the
6060
# artist intersect, if not don't bother drawing this artist.
6161
# First 2 checks are a special case where we received a bad clip box.
6262
# (those can happen when we try to get the bounds of a map projection)
63-
if(
63+
if (
6464
self._clip_box.width == 0 or self._clip_box.height == 0 or
6565
Bbox.intersection(full_extents, self._clip_box) is not None
6666
):
@@ -128,7 +128,7 @@ class ViewSpecification:
128128

129129
def __post_init__(self):
130130
self.image_interpolation = str(self.image_interpolation)
131-
if(self.filter_set is not None):
131+
if (self.filter_set is not None):
132132
self.filter_set = set(self.filter_set)
133133
self.scale_lines = bool(self.scale_lines)
134134

@@ -138,7 +138,6 @@ class __ViewType:
138138
PRIVATE: A simple identifier class for identifying view types, a view
139139
will inherit from the axes class it is wrapping and this type...
140140
"""
141-
...
142141

143142

144143
# 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]:
162161
another axes contents...
163162
"""
164163
# If the passed class is a view, simply return it.
165-
if(issubclass(axes_class, Axes) and issubclass(axes_class, __ViewType)):
164+
if (issubclass(axes_class, Axes) and issubclass(axes_class, __ViewType)):
166165
return axes_class
167166

168167
class View(axes_class, __ViewType):
@@ -228,14 +227,14 @@ def get_children(self) -> List[Artist]:
228227
child_list = super().get_children()
229228

230229
def filter_check(artist, filter_set):
231-
if(filter_set is None):
230+
if (filter_set is None):
232231
return True
233232
return (
234233
(artist not in filter_set)
235234
and (type(artist) not in filter_set)
236235
)
237236

238-
if(self.__renderer is not None):
237+
if (self.__renderer is not None):
239238
for ax, spec in self.view_specifications.items():
240239
mock_renderer = _TransformRenderer(
241240
self.__renderer, ax.transData, self.transData,
@@ -253,7 +252,7 @@ def filter_check(artist, filter_set):
253252
for a in itertools.chain(
254253
ax._children,
255254
ax.child_axes
256-
) if(filter_check(a, spec.filter_set))
255+
) if (filter_check(a, spec.filter_set))
257256
])
258257

259258
return child_list
@@ -262,7 +261,7 @@ def draw(self, renderer: RendererBase = None):
262261
# It is possible to have two axes which are views of each other
263262
# therefore we track the number of recursions and stop drawing
264263
# at a certain depth
265-
if(self.figure._current_render_depth >= self.__max_render_depth):
264+
if (self.figure._current_render_depth >= self.__max_render_depth):
266265
return
267266
self.figure._current_render_depth += 1
268267
# Set the renderer, causing get_children to return the view's
@@ -281,7 +280,7 @@ def __reduce__(self):
281280
cls = type(self)
282281

283282
args = tuple(
284-
arg if(arg != cls) else cls.__bases__[0] for arg in args
283+
arg if (arg != cls) else cls.__bases__[0] for arg in args
285284
)
286285

287286
return (
@@ -318,7 +317,7 @@ def set_max_render_depth(self, val: int):
318317
allow. Zero and negative values are invalid, and will raise a
319318
ValueError.
320319
"""
321-
if(val <= 0):
320+
if (val <= 0):
322321
raise ValueError(f"Render depth must be positive, not {val}.")
323322
self.__max_render_depth = val
324323

@@ -376,20 +375,20 @@ def from_axes(
376375
If the provided axes to convert has an Axes type which does
377376
not match the axes class this view type wraps.
378377
"""
379-
if(isinstance(axes, cls)):
380-
if(render_depth is not None):
378+
if (isinstance(axes, cls)):
379+
if (render_depth is not None):
381380
axes.set_max_render_depth(render_depth)
382381
return axes
383382

384-
if(type(axes) != axes_class):
383+
if (type(axes) is not axes_class):
385384
raise TypeError(
386385
f"Can't convert {type(axes).__name__} to {cls.__name__}"
387386
)
388387

389388
axes.__class__ = cls
390389
axes._init_vars(
391390
DEFAULT_RENDER_DEPTH
392-
if(render_depth is None)
391+
if (render_depth is None)
393392
else render_depth
394393
)
395394
return axes

matplotview/tests/test_view_obj.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ def test_obj_comparison():
1818

1919
assert view_class1 is view_class2
2020
assert view_class1 == view_class2
21-
if(mpl_version >= (3, 7)):
22-
# As of 3.7.0, the subplot class no longer exists, and is an alias to the Axes class...
21+
if (mpl_version >= (3, 7)):
22+
# As of 3.7.0, the subplot class no longer exists, and is an alias
23+
# to the Axes class...
2324
assert view_class2 == view_class3
2425
else:
2526
assert view_class2 != view_class3

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import setuptools
22

3-
VERSION = "1.0.0"
3+
VERSION = "1.0.1"
44

55
with open("README.md", "r", encoding="utf-8") as fh:
66
long_description = fh.read()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy