Skip to content

Commit a419424

Browse files
authored
fix: Ensure that the default value of Map.basemap is MaplibreBasemap if no value of basemap was passed. (#963)
Extracted from #908 so that `main` is clear
1 parent ce5b80e commit a419424

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

lonboard/_map.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,9 @@ def on_click(self, callback: Callable, *, remove: bool = False) -> None:
221221

222222
basemap: t.Instance[MaplibreBasemap | None] = t.Instance(
223223
MaplibreBasemap,
224+
# If both `args` and `kw` are None, then the default value is None.
225+
# Set empty kw so that the default is MaplibreBasemap() with default params
226+
kw={},
224227
allow_none=True,
225228
).tag(
226229
sync=True,

tests/test_map.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from traitlets import TraitError
33

44
from lonboard import Map, ScatterplotLayer, SolidPolygonLayer
5+
from lonboard.basemap import MaplibreBasemap
56

67

78
def test_map_fails_with_unexpected_argument():
@@ -38,3 +39,13 @@ def allow_single_layer():
3839
def test_map_basemap_non_url():
3940
with pytest.raises(TraitError, match=r"expected to be a HTTP\(s\) URL"):
4041
_m = Map([], basemap_style="hello world")
42+
43+
44+
def test_map_default_basemap():
45+
m = Map([])
46+
assert isinstance(m.basemap, MaplibreBasemap), (
47+
"Default basemap should be MaplibreBasemap"
48+
)
49+
50+
assert m.basemap.mode == MaplibreBasemap().mode, "Should match default parameters"
51+
assert m.basemap.style == MaplibreBasemap().style, "Should match default parameters"

0 commit comments

Comments
 (0)