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.

Allow np steps docs (#2963)

vincent d warmerdam46436cec199a
diff --git a/docs/api/inputs/slider.md b/docs/api/inputs/slider.md
index 55c6d29346..5563b8fac2 100644
--- a/docs/api/inputs/slider.md
+++ b/docs/api/inputs/slider.md
@@ -11,6 +11,22 @@
def __():
mo.hstack([slider, mo.md(f"Has value: {slider.value}")])
return
+
+ @app.cell
+ def __():
+ # You can also use steps to create a slider on a custom range
+ log_slider = mo.ui.slider(steps=np.logspace(-2, 2, 101), label="Logarithmic Slider", value=1)
+ return
+
+ @app.cell
+ def __():
+ mo.hstack([log_slider, mo.md(f"Has value: {log_slider.value}")])
+ return
+
+ @app.cell
+ def __():
+ import numpy as np
+ return
```
```{eval-rst}
diff --git a/marimo/_plugins/ui/_impl/input.py b/marimo/_plugins/ui/_impl/input.py
index 940b663600..8fa73d336c 100644
--- a/marimo/_plugins/ui/_impl/input.py
+++ b/marimo/_plugins/ui/_impl/input.py
@@ -237,6 +237,7 @@ class slider(UIElement[Numeric, Numeric]):
if not isinstance(steps, list):
if DependencyManager.numpy.has():
import numpy as np
+
if isinstance(steps, np.ndarray):
steps = steps.tolist()
self._dtype = _infer_dtype(steps)