()
| 13 | |
| 14 | |
| 15 | def 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 | |
| 57 | def test_heatmap_data(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…