Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Introduce import error tests for optionals #926

Merged
merged 2 commits into from
Dec 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 19 additions & 13 deletions src/pyedb/common/nets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
import os
import time

import shapely

from pyedb.generic.constants import CSS4_COLORS


Expand Down Expand Up @@ -120,22 +118,30 @@ def mirror_poly(poly):
sign = -1
return [[sign * i[0], i[1]] for i in poly]

import matplotlib.pyplot as plt
try:
import matplotlib.pyplot as plt
except ImportError: # pragma: no cover
self._pedb.logger.error("Matplotlib is needed. Please, install it first.")
return False

dpi = 100.0
figsize = (size[0] / dpi, size[1] / dpi)

fig = plt.figure(figsize=figsize)
ax = fig.add_subplot(1, 1, 1)
from shapely import affinity
from shapely.geometry import (
LinearRing,
MultiLineString,
MultiPolygon,
Point,
Polygon,
)
from shapely.plotting import plot_line, plot_polygon
try:
from shapely import affinity, union_all
from shapely.geometry import (
LinearRing,
MultiLineString,
MultiPolygon,
Point,
Polygon,
)
from shapely.plotting import plot_line, plot_polygon
except ImportError: # pragma: no cover
self._pedb.logger.error("Shapely is needed. Please, install it first.")
return False

start_time = time.time()
if not nets:
Expand Down Expand Up @@ -317,7 +323,7 @@ def create_poly(prim, polys, lines):
h1 = mirror_poly([(i, j) for i, j in zip(xvt, yvt)])
holes.append(h1)
if len(holes) > 1:
holes = shapely.union_all([Polygon(i) for i in holes])
holes = union_all([Polygon(i) for i in holes])
if isinstance(holes, MultiPolygon):
holes = [i.boundary for i in list(holes.geoms)]
else:
Expand Down
Loading