Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions datascience/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -3183,7 +3183,7 @@ def interactive_plots(cls):
>>> table.plot('days') # doctest: +SKIP
<plotly interactive line graph with days as x-axis and lines for price and projection>
"""
global _INTERACTIVE_PLOTS

_INTERACTIVE_PLOTS = True
if go is None or make_subplots is None:
cls._import_plotly()
Expand Down Expand Up @@ -3217,7 +3217,7 @@ def static_plots(cls):
>>> table.plot('days') # doctest: +SKIP
<matplotlib line graph with days as x-axis and lines for price and projection>
"""
global _INTERACTIVE_PLOTS

_INTERACTIVE_PLOTS = False

def plot(self, column_for_xticks=None, select=None, overlay=True, width=None, height=None, **vargs):
Expand Down Expand Up @@ -3265,7 +3265,7 @@ def plot(self, column_for_xticks=None, select=None, overlay=True, width=None, he
>>> table.plot('days', 'price') # doctest: +SKIP
<line graph with days as x-axis and line for price>
"""
global _INTERACTIVE_PLOTS

if _INTERACTIVE_PLOTS:
return self.iplot(column_for_xticks, select, overlay, width, height, **vargs)

Expand Down Expand Up @@ -3586,7 +3586,7 @@ def bar(self, column_for_categories=None, select=None, overlay=True, width=None,
See http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.bar
for additional arguments that can be passed into vargs.
"""
global _INTERACTIVE_PLOTS

if _INTERACTIVE_PLOTS:
show = vargs.pop('show', True)
return self.ibar(
Expand Down Expand Up @@ -3780,7 +3780,7 @@ def barh(self, column_for_categories=None, select=None, overlay=True, width=None
>>> t.barh('Furniture', make_array(1, 2)) # doctest: +SKIP
<bar graph with furniture as categories and bars for count and price>
"""
global _INTERACTIVE_PLOTS

if _INTERACTIVE_PLOTS:
show = vargs.pop('show', True)
return self.ibarh(
Expand Down Expand Up @@ -4015,7 +4015,7 @@ def scatter(self, column_for_x, select=None, overlay=True, fit_line=False,
>>> table.scatter('x', fit_line=True) # doctest: +SKIP
<scatterplot of values in y and z on x with lines of best fit>
"""
global _INTERACTIVE_PLOTS

if _INTERACTIVE_PLOTS:
return self.iscatter(
column_for_x = column_for_x,
Expand Down Expand Up @@ -4404,7 +4404,7 @@ def scatter3d(self, column_for_x, column_for_y, select=None, overlay=True, fit_l
<plotly 3D scatterplot of values in z1 on x and y>
<plotly 3D scatterplot of values in z2 on x and y
"""
global _INTERACTIVE_PLOTS


# can't use scatter3d if not interactive mode; just a wrapper for iscatter3d
if not _INTERACTIVE_PLOTS:
Expand Down Expand Up @@ -5355,7 +5355,7 @@ def hist(self, *columns, overlay=True, bins=None, bin_column=None, unit=None, co
raise ValueError("You can't specify both normed and density. "
"Use one or the other.")

global _INTERACTIVE_PLOTS

if _INTERACTIVE_PLOTS:
if "shade_split" not in vargs:
vargs["shade_split"] = "split"
Expand Down
21 changes: 15 additions & 6 deletions tests/test_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ def test_draw_map(states):
def test_setup_map():
""" Tests that passing kwargs doesn't error. """
kwargs1 = {
'tiles': 'Stamen Toner',
'tiles': 'OpenStreetMap',
'zoom_start': 17,
'width': 960,
'height': 500,
'features': [],
}
""" Tests features as NumPy array. """
kwargs2 = {
'tiles': 'Stamen Toner',
'tiles': 'OpenStreetMap',
'zoom_start': 17,
'width': 960,
'height': 500,
Expand Down Expand Up @@ -161,14 +161,23 @@ def test_marker_copy():
assert lon == b_lat_lon[1]

def test_background_color_condition_white():
# Test the condition when the background color is white (all 'f' in the hex code)
marker = ds.Marker(0, 0, color='#ffffff')
assert marker._folium_kwargs['icon'].options['textColor'], 'gray'

text_color = marker._folium_kwargs['icon'].options.get('text_color')
if text_color is None:
text_color = marker._folium_kwargs['icon'].options.get('textColor')

assert text_color == 'gray'


def test_background_color_condition_not_white():
# Test the condition when the background color is not white
marker = ds.Marker(0, 0, color='#ff0000')
assert marker._folium_kwargs['icon'].options['textColor'], 'white'

text_color = marker._folium_kwargs['icon'].options.get('text_color')
if text_color is None:
text_color = marker._folium_kwargs['icon'].options.get('textColor')

assert text_color == 'white'

def test_icon_args_icon_not_present():
# Test when 'icon' key is not present in icon_args
Expand Down