<commit_before># -*- coding: utf-8 -*-
"""
Marker Cluster plugin
---------------------

Creates a MarkerCluster plugin to add on a folium map.
"""

from jinja2 import Template

from . import MarkerCluster


class FastMarkerCluster(MarkerCluster):
    """Creates a FasterMarkerCluster plugin to append into a map with
        FasterMarkerCluster(data, callback=create_marker).add_to(map)
        map.add_to(fig).

        Parameters
        ----------
            data: list of list or array of shape (n,2).
                Data points of the form [[lat, lng]].

            callback: list of length n.

            popup: popup for each marker
    """
    def __init__(self, data, callback=None):
        super(FastMarkerCluster, self).__init__([])
        self._name = 'Script'
        self._data = data
        if callback is None:
            self._callback = ('var callback;\n' +
                              'callback = function (row) {\n' +
                              '\tvar icon, marker;\n' +
                              '\t// Returns a L.marker object\n' +
                              '\ticon = L.AwesomeMarkers.icon();\n' +
                              '\tmarker = L.marker(new L.LatLng(row[0], ' +
                              'row[1]));\n' +
                              '\tmarker.setIcon(icon);\n' +
                              '\treturn marker;\n' +
                              '};')
        else:
            self._callback = "var callback = {};".format(callback)

        self._template = Template(u"""
            {% macro script(this, kwargs) %}
            {{this._callback}}

            (function(){
                var data = {{this._data}};<commit_msg>Tidy up docstrings<commit_after># -*- coding: utf-8 -*-
"""
Marker Cluster plugin
---------------------

Creates a MarkerCluster plugin to add on a folium map.
"""

from jinja2 import Template

from . import MarkerCluster


class FastMarkerCluster(MarkerCluster):
    """Add marker clusters to a map using in-browser rendering"""
    def __init__(self, data, callback=None):
        """Add marker clusters to a map using in-browser rendering.
           Using FastMarkerCluster it is possible to render 000's of
           points far quicker than the MarkerCluster class. Be aware
           that the FastMarkerCluster class does not retain a
           reference to any marker data, and therefore methods such as
           get_bounds() are not available when using it.

        Parameters
        ----------
            data: list
                List of list of shape [[], []]. Data points should be of
                the form [[lat, lng]].

            callback: string, default None
                A string representation of a valid Javascript function
                that will be passed a lat, lon coordinate pair. See the
                FasterMarkerCluster for an example of a custom callback.

        """
        super(FastMarkerCluster, self).__init__([])
        self._name = 'FastMarkerCluster'
        self._data = data

        if callback is None:
            self._callback = ('var callback;\n' +
                              'callback = function (row) {\n' +
                              '\tvar icon, marker;\n' +
                              '\t// Returns a L.marker object\n' +
                              '\ticon = L.AwesomeMarkers.icon();\n' +
                              '\tmarker = L.marker(new L.LatLng(row[0], ' +
                              'row[1]));\n' +
                              '\tmarker.setIcon(icon);\n' +
                              '\treturn marker;\n' +
                              '};')
        else:
            self._callback = "var callback = {};".format(callback)

        self._template = Template(u"""
            {% macro script(this, kwargs) %}
            {{this._callback}}

            (function(){
                var data = {{this._data}};
{'fraction_non_alphanumeric': 0.12054372916132342, 'fraction_numerical': 0.00307771223390613, 'mean_word_length': 1.3970497848801475, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4922689', 'n_tokens_mistral': 993, 'n_tokens_neox': 953, 'n_words': 306}