Skip to content

Commit

Permalink
use column as areas, not radii
Browse files Browse the repository at this point in the history
  • Loading branch information
papajohn committed Feb 13, 2017
1 parent 8ac6228 commit 646843b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions datascience/maps.py
Expand Up @@ -11,8 +11,9 @@
import abc
import collections
import collections.abc
import json
import functools
import json
import math
import random

from .tables import Table
Expand Down Expand Up @@ -98,7 +99,7 @@ def copy(self):
"""
Copies the current Map into a new one and returns it.
"""

m = Map(features=self._features, width=self._width,
height=self._height, **self._attrs)
m._folium_map = self._folium_map
Expand Down Expand Up @@ -473,13 +474,13 @@ def _convert_point(cls, feature):
return cls(lat, lon)

@classmethod
def map(cls, latitudes, longitudes, labels=None, colors=None, radii=None, **kwargs):
def map(cls, latitudes, longitudes, labels=None, colors=None, areas=None, **kwargs):
"""Return markers from columns of coordinates, labels, & colors.
The radii column is not applicable to markers, but sets circle radius.
The areas column is not applicable to markers, but sets circle areas.
"""
assert len(latitudes) == len(longitudes)
assert radii is None or hasattr(cls, '_has_radius'), "A " + cls.__name__ + " has no radius"
assert areas is None or hasattr(cls, '_has_radius'), "A " + cls.__name__ + " has no radius"
inputs = [latitudes, longitudes]
if labels is not None:
assert len(labels) == len(latitudes)
Expand All @@ -489,9 +490,9 @@ def map(cls, latitudes, longitudes, labels=None, colors=None, radii=None, **kwar
if colors is not None:
assert len(colors) == len(latitudes)
inputs.append(colors)
if radii is not None:
assert len(radii) == len(latitudes)
inputs.append(radii)
if areas is not None:
assert len(areas) == len(latitudes)
inputs.append(np.array(areas) ** 0.5 / math.pi)
ms = [cls(*args, **kwargs) for args in zip(*inputs)]
return Map(ms)

Expand Down Expand Up @@ -616,4 +617,3 @@ def _lat_lons_from_geojson(s):
return [(lat, lon)]
else:
return [lat_lon for sub in s for lat_lon in _lat_lons_from_geojson(sub)]

2 changes: 1 addition & 1 deletion datascience/version.py
@@ -1 +1 @@
__version__ = '0.9.2'
__version__ = '0.9.3'

0 comments on commit 646843b

Please sign in to comment.