Skip to content

Commit

Permalink
Merge branch 'master' into ipynb_test_coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
davidwagner committed Sep 3, 2020
2 parents fedbcb7 + 85dd024 commit f155907
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 53 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Expand Up @@ -7,6 +7,17 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### v0.15.10
* Include ipynb files in tests, and when measuring test coverage

### v0.15.9
* Changed the `radius` argument of a Circle (in Maps) to `area`.

### v0.15.8
* Fixes deprecation warnings with matplotlib's warn parameter.
* Small cleanups: update to latest version of folium.
* Add some additional documentation.

### v0.15.7
* Fixes bug with `Table#hist`.

### v0.15.6
* Adds support for NumPy v1.18.0+.

Expand Down
20 changes: 13 additions & 7 deletions datascience/maps.py
Expand Up @@ -16,6 +16,7 @@
import json
import math
import random
import warnings

from .tables import Table

Expand Down Expand Up @@ -295,7 +296,7 @@ def overlay(self, feature, color='Blue', opacity=0.6):
if 'feature' in feature:
feature = feature['feature']

# if marker table e.g. table with columns: latitudes,longitudes,popup,color,radius
# if marker table e.g. table with columns: latitudes,longitudes,popup,color,area
else:
feature = Circle.map_table(feature)

Expand Down Expand Up @@ -504,7 +505,7 @@ def map(cls, latitudes, longitudes, labels=None, colors=None, areas=None, other_
assert latitudes is not None
assert longitudes is not None
assert len(latitudes) == len(longitudes)
assert areas is None or hasattr(cls, '_has_radius'), "A " + cls.__name__ + " has no radius"
assert areas is None or hasattr(cls, '_has_area'), "A " + cls.__name__ + " has no area"
inputs = [latitudes, longitudes]
if labels is not None:
assert len(labels) == len(latitudes)
Expand All @@ -516,7 +517,7 @@ def map(cls, latitudes, longitudes, labels=None, colors=None, areas=None, other_
inputs.append(colors)
if areas is not None:
assert len(areas) == len(latitudes)
inputs.append(np.array(areas) ** 0.5 / math.pi)
inputs.append(areas)
if other_attrs is not None:
other_attrs_processed = []
for i in range(len(latitudes)):
Expand Down Expand Up @@ -570,7 +571,7 @@ class Circle(Marker):
popup -- text that pops up when marker is clicked
color -- fill color
radius -- pixel radius of the circle
area -- pixel-squared area of the circle
Defaults from Folium:
Expand All @@ -587,14 +588,19 @@ class Circle(Marker):
'lon', [-122, -122.1, -121.9],
'label', ['one', 'two', 'three'],
'color', ['red', 'green', 'blue'],
'radius', [3000, 4000, 5000],
'area', [3000, 4000, 5000],
])
Circle.map_table(t)
"""

_has_radius = True
_has_area = True

def __init__(self, lat, lon, popup='', color='blue', radius=10, **kwargs):
def __init__(self, lat, lon, popup='', color='blue', area=math.pi*(10**2), **kwargs):
# Add support for transitioning radius to area
radius = (area/math.pi)**0.5
if 'radius' in kwargs:
warnings.warn("The 'radius' argument is deprecated. Please use 'area' instead.", FutureWarning)
radius = kwargs.pop('radius')
super().__init__(lat, lon, popup, color, radius=radius, **kwargs)

@property
Expand Down
4 changes: 2 additions & 2 deletions datascience/tables.py
Expand Up @@ -323,8 +323,8 @@ def columns(self):
... })
>>> t.columns
(array(['a', 'b', 'c', 'z'], dtype='<U1'),
array([9, 3, 3, 1]),
array([ 1, 2, 2, 10]))
array([9, 3, 3, 1]),
array([ 1, 2, 2, 10]))
"""
return tuple(self._columns.values())

Expand Down

0 comments on commit f155907

Please sign in to comment.