Skip to content

Commit 0845bce

Browse files
authored
remove duplicate utility functions (#1676)
1 parent 2447e49 commit 0845bce

1 file changed

Lines changed: 8 additions & 51 deletions

File tree

folium/utilities.py

Lines changed: 8 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@
1414

1515
import numpy as np
1616

17+
# import here for backwards compatibility
18+
from branca.utilities import ( # noqa F401
19+
_locations_mirror,
20+
_parse_size,
21+
none_max,
22+
none_min,
23+
)
24+
1725
try:
1826
import pandas as pd
1927
except ImportError:
@@ -321,24 +329,6 @@ def mercator(x):
321329
return out
322330

323331

324-
def none_min(x, y):
325-
if x is None:
326-
return y
327-
elif y is None:
328-
return x
329-
else:
330-
return min(x, y)
331-
332-
333-
def none_max(x, y):
334-
if x is None:
335-
return y
336-
elif y is None:
337-
return x
338-
else:
339-
return max(x, y)
340-
341-
342332
def iter_coords(obj):
343333
"""
344334
Returns all the coordinate tuples from a geometry or feature.
@@ -362,23 +352,6 @@ def iter_coords(obj):
362352
yield from iter_coords(coord)
363353

364354

365-
def _locations_mirror(x):
366-
"""
367-
Mirrors the points in a list-of-list-of-...-of-list-of-points.
368-
For example:
369-
>>> _locations_mirror([[[1, 2], [3, 4]], [5, 6], [7, 8]])
370-
[[[2, 1], [4, 3]], [6, 5], [8, 7]]
371-
372-
"""
373-
if hasattr(x, "__iter__"):
374-
if hasattr(x[0], "__iter__"):
375-
return list(map(_locations_mirror, x))
376-
else:
377-
return list(x[::-1])
378-
else:
379-
return x
380-
381-
382355
def get_bounds(locations, lonlat=False):
383356
"""
384357
Computes the bounds of the object in the form
@@ -415,22 +388,6 @@ def camelize(key):
415388
return "".join(x.capitalize() if i > 0 else x for i, x in enumerate(key.split("_")))
416389

417390

418-
def _parse_size(value):
419-
try:
420-
if isinstance(value, (int, float)):
421-
value_type = "px"
422-
value = float(value)
423-
assert value > 0
424-
else:
425-
value_type = "%"
426-
value = float(value.strip("%"))
427-
assert 0 <= value <= 100
428-
except Exception:
429-
msg = "Cannot parse value {!r} as {!r}".format
430-
raise ValueError(msg(value, value_type))
431-
return value, value_type
432-
433-
434391
def compare_rendered(obj1, obj2):
435392
"""
436393
Return True/False if the normalized rendered version of

0 commit comments

Comments
 (0)