diff --git a/datascience/geodata/geocode_states.csv b/datascience/geodata/geocode_states.csv old mode 100755 new mode 100644 diff --git a/datascience/maps.py b/datascience/maps.py index 652491b30..2ce6eaba7 100644 --- a/datascience/maps.py +++ b/datascience/maps.py @@ -535,7 +535,8 @@ def _folium_kwargs(self): # If statement does not check to see if color is an empty string. icon_args['background_color'] = icon_args['border_color'] = icon_args.pop('color') if icon_args['background_color'][1] == icon_args['background_color'][3] == icon_args['background_color'][5] == 'f': - icon_args['text_color'] = 'gray' + # White background, use black text for visibility + icon_args['text_color'] = 'black' else: icon_args['text_color'] = 'white' icon_args['icon_shape'] = 'marker' diff --git a/datascience/tables.py b/datascience/tables.py index 51298c885..7c4c40b94 100644 --- a/datascience/tables.py +++ b/datascience/tables.py @@ -4037,12 +4037,14 @@ def scatter(self, column_for_x, select=None, overlay=True, fit_line=False, if height is None: height = 5 + if "colors" in vargs and vargs["colors"]: + warnings.warn("scatter(colors=x) has been removed. Use scatter(group=x)", FutureWarning) + vargs.pop("colors") + options = self.default_options.copy() options.update(vargs) x_data, y_labels = self._split_column_and_labels(column_for_x) - if "colors" in vargs and vargs["colors"]: - warnings.warn("scatter(colors=x) has been removed. Use scatter(group=x)", FutureWarning) if group is not None: y_labels.remove(self._as_label(group)) if sizes is not None: @@ -4073,7 +4075,8 @@ def draw(axis, label, color): if fit_line: m, b = np.polyfit(x_data, self[label], 1) minx, maxx = np.min(x_data),np.max(x_data) - axis.plot([minx,maxx],[m*minx+b,m*maxx+b], color=color) + line_color = color_list[0] if group is not None else color + axis.plot([minx,maxx],[m*minx+b,m*maxx+b], color=line_color) if labels is not None: for x, y, label in zip(x_data, y_data, self[labels]): axis.annotate(label, (x, y), diff --git a/tests/test_coverage_augmentation.py b/tests/test_coverage_augmentation.py new file mode 100644 index 000000000..7599411bd --- /dev/null +++ b/tests/test_coverage_augmentation.py @@ -0,0 +1,223 @@ +""" +This file has extra tests to make sure we cover more of the code. +It's mostly for checking edge cases and making sure everything works as expected. +""" +import numpy as np +import datascience as ds +from datascience import maps +from datascience.tables import Table + +def test_marker_repr_html(): + """Test that Marker has proper _repr_html_ implementation.""" + # This just checks if the HTML representation is a string and looks reasonable. + marker = ds.Marker(51.514, -0.132) + html = marker._repr_html_() + assert isinstance(html, str) + assert 'marker' in html.lower() or 'folium' in html.lower() + +def test_circle_repr_html(): + """Test that Circle has proper _repr_html_ implementation.""" + circle = ds.Circle(51.514, -0.132) + html = circle._repr_html_() + assert isinstance(html, str) + assert 'circle' in html.lower() or 'folium' in html.lower() + +def test_region_repr_html(): + """Test that Region has proper _repr_html_ implementation.""" + states = ds.Map.read_geojson('tests/us-states.json') + region = states['CA'] + html = region._repr_html_() + assert isinstance(html, str) + +def test_map_repr_html(): + """Test that Map has proper _repr_html_ implementation.""" + states = ds.Map.read_geojson('tests/us-states.json') + html = states._repr_html_() + assert isinstance(html, str) + assert 'folium' in html.lower() + +def test_inline_map(): + """Test the _inline_map static method.""" + # This is an internal method, but we test it for coverage. + states = ds.Map.read_geojson('tests/us-states.json') + html = ds.maps._FoliumWrapper._inline_map(states, 800, 600) + assert isinstance(html, str) + assert 'iframe' in html.lower() or '