Skip to content

test_heat_map and test_marker_cluster fail on 32-bit #1390

Description

@badshah400

Describe the bug
When building folium (v 0.11.0) packages for openSUSE on i586 systems (against python 3.8.5), two tests (test_heat_map and test_marker_cluster) from the test suite fail (using pytest), seemingly due to precision errors:

[   64s] =================================== FAILURES ===================================
[   64s] ________________________________ test_heat_map _________________________________
[   64s] 
[   64s]     def test_heat_map():
[   64s]         np.random.seed(3141592)
[   64s]         data = (np.random.normal(size=(100, 2)) * np.array([[1, 1]]) +
[   64s]                 np.array([[48, 5]]))
[   64s]         m = folium.Map([48., 5.], tiles='stamentoner', zoom_start=6)
[   64s]         hm = HeatMap(data)
[   64s]         m.add_child(hm)
[   64s]         m._repr_html_()
[   64s]     
[   64s]         out = normalize(m._parent.render())
[   64s]     
[   64s]         # We verify that the script import is present.
[   64s]         script = '<script src="https://leaflet.github.io/Leaflet.heat/dist/leaflet-heat.js"></script>'  # noqa
[   64s]         assert script in out
[   64s]     
[   64s]         # We verify that the script part is correct.
[   64s]         tmpl = Template("""
[   64s]                 var {{this.get_name()}} = L.heatLayer(
[   64s]                     {{this.data}},
[   64s]                     {
[   64s]                         minOpacity: {{this.min_opacity}},
[   64s]                         maxZoom: {{this.max_zoom}},
[   64s]                         max: {{this.max_val}},
[   64s]                         radius: {{this.radius}},
[   64s]                         blur: {{this.blur}},
[   64s]                         gradient: {{this.gradient}}
[   64s]                         })
[   64s]                     .addTo({{this._parent.get_name()}});
[   64s]         """)
[   64s]     
[   64s]         assert tmpl.render(this=hm)
[   64s]     
[   64s]         bounds = m.get_bounds()
[   64s] >       assert bounds == [[46.218566840847025, 3.0302801394447734],
[   64s]                           [50.75345011431167, 7.132453997672826]], bounds
[   64s] E       AssertionError: [[46.218566840847025, 3.030280139444773], [50.75345011431167, 7.132453997672826]]
[   64s] E       assert [[46.21856684...453997672826]] == [[46.21856684...453997672826]]
[   64s] E         At index 0 diff: [46.218566840847025, 3.030280139444773] != [46.218566840847025, 3.0302801394447734]
[   64s] E         Full diff:
[   64s] E           [
[   64s] E         -  [46.218566840847025, 3.0302801394447734],
[   64s] E         ?                                        -
[   64s] E         +  [46.218566840847025, 3.030280139444773],
[   64s] E            [50.75345011431167, 7.132453997672826],...
[   64s] E         
[   64s] E         ...Full output truncated (2 lines hidden), use '-vv' to show
[   64s] 
[   64s] tests/plugins/test_heat_map.py:52: AssertionError
[   64s] _____________________________ test_marker_cluster ______________________________
[   64s] 
[   64s]     def test_marker_cluster():
[   64s]         N = 100
[   64s]         np.random.seed(seed=26082009)
[   64s]         data = np.array([
[   64s]             np.random.uniform(low=35, high=60, size=N),   # Random latitudes.
[   64s]             np.random.uniform(low=-12, high=30, size=N),  # Random longitudes.
[   64s]         ]).T
[   64s]         m = folium.Map([45., 3.], zoom_start=4)
[   64s]         mc = plugins.MarkerCluster(data).add_to(m)
[   64s]     
[   64s]         out = normalize(m._parent.render())
[   64s]     
[   64s]         # We verify that imports
[   64s]         assert '<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/1.1.0/leaflet.markercluster.js"></script>' in out  # noqa
[   64s]         assert '<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/1.1.0/MarkerCluster.css"/>' in out  # noqa
[   64s]         assert '<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/1.1.0/MarkerCluster.Default.css"/>' in out  # noqa
[   64s]     
[   64s]         # Verify the script part is okay.
[   64s]         tmpl = Template("""
[   64s]             var {{this.get_name()}} = L.markerClusterGroup(
[   64s]                 {{ this.options|tojson }}
[   64s]             );
[   64s]             {%- if this.icon_create_function is not none %}
[   64s]                 {{ this.get_name() }}.options.iconCreateFunction =
[   64s]                     {{ this.icon_create_function.strip() }};
[   64s]                 {%- endif %}
[   64s]             {{this._parent.get_name()}}.addLayer({{this.get_name()}});
[   64s]     
[   64s]             {% for marker in this._children.values() %}
[   64s]                 var {{marker.get_name()}} = L.marker(
[   64s]                     {{ marker.location|tojson }},
[   64s]                     {}
[   64s]                 ).addTo({{this.get_name()}});
[   64s]             {% endfor %}
[   64s]         """)
[   64s]         expected = normalize(tmpl.render(this=mc))
[   64s]         assert expected in out
[   64s]     
[   64s]         bounds = m.get_bounds()
[   64s] >       assert bounds == [[35.147332572663785, -11.520684337300109],
[   64s]                           [59.839718052359274, 29.94931046497927]], bounds
[   64s] E       AssertionError: [[35.147332572663785, -11.520684337300109], [59.839718052359274, 29.949310464979266]]
[   64s] E       assert [[35.14733257...310464979266]] == [[35.14733257...931046497927]]
[   64s] E         At index 1 diff: [59.839718052359274, 29.949310464979266] != [59.839718052359274, 29.94931046497927]
[   64s] E         Full diff:
[   64s] E           [
[   64s] E            [35.147332572663785, -11.520684337300109],
[   64s] E         -  [59.839718052359274, 29.94931046497927],
[   64s] E         ?                                       ^
[   64s] E         +  [59.839718052359274, 29.949310464979266],...
[   64s] E         
[   64s] E         ...Full output truncated (3 lines hidden), use '-vv' to show
[   64s] 
[   64s] tests/plugins/test_marker_cluster.py:56: AssertionError

No such problems seen when building on 64 bit systems. Full build log attached.
_log.zip

Environment (please complete the following information):

  • Browser [e.g. chrome, firefox] NA
  • Jupyter Notebook or html files? NA
  • Python version 3.8.5
  • folium version 0.11.0
  • branca version 0.4.0

Possible solutions
Reducing the precision for these two tests?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    testsA PR or issue related to tests

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions