Skip to content

Commit a0d58c2

Browse files
committed
Add shapely specific import error
1 parent 39299d5 commit a0d58c2

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

nucleus/metrics/__init__.py

+21
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,28 @@
1+
import sys
2+
13
from .base import Metric, MetricResult
24
from .polygon_metrics import (
35
PolygonIOU,
46
PolygonMetric,
57
PolygonPrecision,
68
PolygonRecall,
79
)
10+
11+
try:
12+
import shapely
13+
except ModuleNotFoundError as e:
14+
if sys.platform.startswith("darwin"):
15+
platform_specific_msg = (
16+
"Depending on Python environment used GEOS might need to be installed via "
17+
"`brew install geos`."
18+
)
19+
elif sys.platform.startswith("linux"):
20+
platform_specific_msg = (
21+
"Depending on Python environment used GEOS might need to be installed via "
22+
"system package `libgeos-dev`."
23+
)
24+
else:
25+
platform_specific_msg = "GEOS package will need to be installed see (https://trac.osgeo.org/geos/)"
26+
raise ModuleNotFoundError(
27+
f"Module 'shapely' not found. Install optionally with `scale-nucleus[metrics]`. {platform_specific_msg}"
28+
) from e

0 commit comments

Comments
 (0)