MCPcopy Create free account
hub / github.com/python-visualization/folium / test_heat_map

Function test_heat_map

tests/plugins/test_heat_map.py:15–54  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

13
14
15def test_heat_map():
16 np.random.seed(3141592)
17 data = np.random.normal(size=(100, 2)) * np.array([[1, 1]]) + np.array([[48, 5]])
18 m = folium.Map([48.0, 5.0], zoom_start=6)
19 hm = HeatMap(data)
20 m.add_child(hm)
21 m._repr_html_()
22
23 out = normalize(m._parent.render())
24
25 # We verify that the script import is present.
26 script = '<script src="https://cdn.jsdelivr.net/gh/python-visualization/folium@main/folium/templates/leaflet_heat.min.js"></script>' # noqa
27 assert script in out
28
29 # We verify that the script part is correct.
30 tmpl = Template(
31 """
32 var {{this.get_name()}} = L.heatLayer(
33 {{this.data}},
34 {
35 minOpacity: {{this.min_opacity}},
36 maxZoom: {{this.max_zoom}},
37 radius: {{this.radius}},
38 blur: {{this.blur}},
39 gradient: {{this.gradient}}
40 })
41 .addTo({{this._parent.get_name()}});
42 """
43 )
44
45 assert tmpl.render(this=hm)
46
47 bounds = m.get_bounds()
48 np.testing.assert_allclose(
49 bounds,
50 [
51 [46.218566840847025, 3.0302801394447734],
52 [50.75345011431167, 7.132453997672826],
53 ],
54 )
55
56
57def test_heatmap_data():

Callers

nothing calls this directly

Calls 7

_repr_html_Method · 0.95
HeatMapClass · 0.90
normalizeFunction · 0.90
TemplateClass · 0.90
get_boundsMethod · 0.80
add_childMethod · 0.45
renderMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…