Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

perf: check if package has been imported instead of installed (#3109)

Myles Scolnickc0ff797ce2aa
diff --git a/marimo/_output/formatters/holoviews_formatters.py b/marimo/_output/formatters/holoviews_formatters.py
index ac962520c2..7581c72996 100644
--- a/marimo/_output/formatters/holoviews_formatters.py
+++ b/marimo/_output/formatters/holoviews_formatters.py
@@ -41,6 +41,9 @@ class HoloViewsFormatter(FormatterFactory):
def apply_theme(self, theme: Theme) -> None:
import holoviews as hv # type: ignore
+ # TODO: checking for has() imports the library, which is not ideal,
+ # but the importing bokeh may come after importing holoviews.
+ # We can maybe improve this hooking into the holoviews Store.renderers
if DependencyManager.bokeh.has():
hv.renderer("bokeh").theme = (
"dark_minimal" if theme == "dark" else None
diff --git a/marimo/_plugins/ui/_impl/input.py b/marimo/_plugins/ui/_impl/input.py
index ee10a1ee59..3bc0521f99 100644
--- a/marimo/_plugins/ui/_impl/input.py
+++ b/marimo/_plugins/ui/_impl/input.py
@@ -1650,7 +1650,7 @@ class form(UIElement[Optional[JSONTypeBound], Optional[T]]):
def _convert_numpy_array(steps: Any) -> list[Numeric]:
"""Convert numpy array to list if needed."""
- if DependencyManager.numpy.has():
+ if DependencyManager.numpy.imported():
import numpy as np
if isinstance(steps, np.ndarray):