diff --git a/folium/utilities.py b/folium/utilities.py index 2b319194ae..dddd93e25f 100644 --- a/folium/utilities.py +++ b/folium/utilities.py @@ -14,6 +14,14 @@ import numpy as np +# import here for backwards compatibility +from branca.utilities import ( # noqa F401 + _locations_mirror, + _parse_size, + none_max, + none_min, +) + try: import pandas as pd except ImportError: @@ -321,24 +329,6 @@ def mercator(x): return out -def none_min(x, y): - if x is None: - return y - elif y is None: - return x - else: - return min(x, y) - - -def none_max(x, y): - if x is None: - return y - elif y is None: - return x - else: - return max(x, y) - - def iter_coords(obj): """ Returns all the coordinate tuples from a geometry or feature. @@ -362,23 +352,6 @@ def iter_coords(obj): yield from iter_coords(coord) -def _locations_mirror(x): - """ - Mirrors the points in a list-of-list-of-...-of-list-of-points. - For example: - >>> _locations_mirror([[[1, 2], [3, 4]], [5, 6], [7, 8]]) - [[[2, 1], [4, 3]], [6, 5], [8, 7]] - - """ - if hasattr(x, "__iter__"): - if hasattr(x[0], "__iter__"): - return list(map(_locations_mirror, x)) - else: - return list(x[::-1]) - else: - return x - - def get_bounds(locations, lonlat=False): """ Computes the bounds of the object in the form @@ -415,22 +388,6 @@ def camelize(key): return "".join(x.capitalize() if i > 0 else x for i, x in enumerate(key.split("_"))) -def _parse_size(value): - try: - if isinstance(value, (int, float)): - value_type = "px" - value = float(value) - assert value > 0 - else: - value_type = "%" - value = float(value.strip("%")) - assert 0 <= value <= 100 - except Exception: - msg = "Cannot parse value {!r} as {!r}".format - raise ValueError(msg(value, value_type)) - return value, value_type - - def compare_rendered(obj1, obj2): """ Return True/False if the normalized rendered version of