Skip to content

Commit

Permalink
blackify everything
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrik Hlobil committed Nov 27, 2020
1 parent aabb52c commit 8096502
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 37 deletions.
19 changes: 8 additions & 11 deletions Tests/test_GeoPandasBokeh.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,15 @@
import pandas_bokeh

directory = os.path.dirname(__file__)
test_sets_directory = os.path.join(
os.path.dirname(directory), "docs", "Testdata"
)
test_sets_directory = os.path.join(os.path.dirname(directory), "docs", "Testdata")
os.makedirs(os.path.join(directory, "Plots"), exist_ok=True)


@pytest.fixture
def df_states():

return gpd.read_file(
os.path.join(test_sets_directory, "states", "states.geojson")
)
return gpd.read_file(os.path.join(test_sets_directory, "states", "states.geojson"))


@pytest.fixture
def df_cities():
Expand All @@ -31,14 +29,13 @@ def df_cities():
)
)


def test_geolayers_simple(df_states):
"Tests for simple geoplot"

figure = df_states.plot_bokeh(simplify_shapes=10000, show_figure=False)

with open(
os.path.join(directory, "Plots", "Geolayers_Simple.html"), "w"
) as f:
with open(os.path.join(directory, "Plots", "Geolayers_Simple.html"), "w") as f:
f.write(pandas_bokeh.embedded_html(figure))

assert True
Expand Down Expand Up @@ -108,11 +105,12 @@ def test_geolayers_slider(df_states, df_cities):
) as f:
f.write(html_multilayer_slider)


def test_hole_geplot():
"Tests for (multi-)polygones with holes."

df = gpd.GeoDataFrame.from_file(
os.path.join(test_sets_directory, 'hole_shapes', 'hole_shapes.geojson')
os.path.join(test_sets_directory, "hole_shapes", "hole_shapes.geojson")
)
figure = df.plot_bokeh(show_figure=False)

Expand All @@ -122,4 +120,3 @@ def test_hole_geplot():
f.write(pandas_bokeh.embedded_html(figure))

assert True

16 changes: 10 additions & 6 deletions Tests/test_PySpark.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import pytest

# only run tests for Python <= 3.7 due to pyspark support:
if sys.version_info[1] < 8:
if sys.version_info[1] < 8:

directory = os.path.dirname(__file__)
os.makedirs(os.path.join(directory, "Plots"), exist_ok=True)
Expand All @@ -16,19 +16,21 @@
def spark():
# Start PySpark
from pyspark.sql import SparkSession

spark = SparkSession.builder.getOrCreate()
yield spark
spark.stop()


def test_basic_lineplot_pyspark(spark):
"""Test for basic lineplot with Pyspark"""

# Create basic lineplot:
np.random.seed(42)
df = pd.DataFrame(
{"Google": np.random.randn(1000) + 0.2,
"Apple": np.random.randn(1000) + 0.17},
{
"Google": np.random.randn(1000) + 0.2,
"Apple": np.random.randn(1000) + 0.17,
},
index=pd.date_range("1/1/2000", periods=1000),
)
df.index.name = "Date"
Expand All @@ -40,7 +42,9 @@ def test_basic_lineplot_pyspark(spark):

# Output plot as HTML:
output = pandas_bokeh.row([p_basic_lineplot, p_basic_lineplot_accessor])
with open(os.path.join(directory, "Plots", "Basic_lineplot_PySpark.html"), "w") as f:
with open(
os.path.join(directory, "Plots", "Basic_lineplot_PySpark.html"), "w"
) as f:
f.write(pandas_bokeh.embedded_html(output))

assert True
assert True
8 changes: 6 additions & 2 deletions docs/github-pages/replace_pictures_with_Bokeh_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,14 @@
for plotname, plot in plots.items():
print(f"Replace image {plotname}")
if re.search(r"!\[{plotname}\]\(.+\)".format(plotname=plotname), readme):
to_replace = re.search(r"!\[{plotname}\]\(.+\)".format(plotname=plotname), readme).group()
to_replace = re.search(
r"!\[{plotname}\]\(.+\)".format(plotname=plotname), readme
).group()
readme = readme.replace(to_replace, f'<div align="center">\n\n{plot}\n\n</div>')
else:
raise KeyError(f"No image with name '{plotname}' has been found in the README file '{readme_file}'.")
raise KeyError(
f"No image with name '{plotname}' has been found in the README file '{readme_file}'."
)

# Replace path to remaining pictures:
readme = readme.replace(r"![](docs/Images/Pandas-Bokeh-Logo.png)", "")
Expand Down
8 changes: 4 additions & 4 deletions pandas_bokeh/geoplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@


def _get_background_tile(provider_name):
"""Returns a Bokeh WTMS Tile Provider Source from <provider_name>. If
"""Returns a Bokeh WTMS Tile Provider Source from <provider_name>. If
<provider_name is not valid, it returns False."""

if provider_name not in TILE_PROVIDERS:
Expand All @@ -38,8 +38,8 @@ def _get_background_tile(provider_name):
def _add_backgroundtile(
p, tile_provider, tile_provider_url, tile_attribution, tile_alpha
):
"""Add a background tile to the plot. Either uses predefined Tiles from Bokeh
(parameter: tile_provider) or user passed a tile_provider_url of the form
"""Add a background tile to the plot. Either uses predefined Tiles from Bokeh
(parameter: tile_provider) or user passed a tile_provider_url of the form
'<url>/{Z}/{X}/{Y}*.png' or '<url>/{Z}/{Y}/{X}*.png'."""

from bokeh.models import WMTSTileSource
Expand Down Expand Up @@ -89,7 +89,7 @@ def _get_figure(col):


def convert_geoDataFrame_to_patches(gdf, geometry_column):
"""Creates from a geoDataFrame with Polygons and Multipolygons a Pandas DataFrame
"""Creates from a geoDataFrame with Polygons and Multipolygons a Pandas DataFrame
with x any y columns specifying the geometry of the Polygons."""

df_new = []
Expand Down
18 changes: 9 additions & 9 deletions pandas_bokeh/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,18 +180,18 @@ def plot(
--------
>>> df.plot_bokeh.line()
>>> df.plot_bokeh.scatter(x='x',y='y')
These plotting methods can also be accessed by calling the accessor as a
method with the ``kind`` argument (except of "map" plot):
``df.plot_bokeh(kind='line')`` is equivalent to ``df.plot_bokeh.line()``
For more information about the individual plot kind implementations, have a
look at the underlying method accessors (like df.plot_bokeh.line) or visit
https://github.com/PatrikHlobil/Pandas-Bokeh.
https://github.com/PatrikHlobil/Pandas-Bokeh.
If `sizing_mode` is not fixed (default), it will overide the set plot width or height
depending on which axis it is scaled on.
"""

# Make a local copy of the DataFrame:
Expand Down Expand Up @@ -1818,7 +1818,7 @@ def line(self, x=None, y=None, **kwargs):
Returns
-------
Bokeh.plotting.figure or Bokeh.layouts.row
Examples
Expand Down Expand Up @@ -1869,7 +1869,7 @@ def step(self, x=None, y=None, **kwargs):
Returns
-------
Bokeh.plotting.figure or Bokeh.layouts.row
Examples
Expand Down Expand Up @@ -1920,7 +1920,7 @@ def point(self, x=None, y=None, **kwargs):
Returns
-------
Bokeh.plotting.figure or Bokeh.layouts.row
Examples
Expand Down Expand Up @@ -2294,9 +2294,9 @@ def scatter(self, x, y, category=None, **kwds):
The column name or column position to be used as vertical
coordinates for each point.
category : str or object
category : str or object
A column name whose values will be used to color the
marker points according to a colormap.
marker points according to a colormap.
**kwds
Keyword arguments to pass on to :meth:`pandas.DataFrame.plot_bokeh`.
Expand Down Expand Up @@ -2422,7 +2422,7 @@ def map(self, x, y, **kwds):
def _initialize_rangetool(p, x_axis_type, source):
"""
Initializes the range tool chart and slider.
Parameters
----------
p : Bokeh.plotting.figure
Expand Down
10 changes: 5 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import setuptools

import pandas_bokeh

version = pandas_bokeh.__version__

long_description = f"""# Pandas Bokeh
Expand Down Expand Up @@ -67,7 +68,6 @@
"""



setuptools.setup(
name="pandas-bokeh",
version=version,
Expand All @@ -85,9 +85,9 @@
"Programming Language :: Python :: 3.8",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
'Intended Audience :: Science/Research',
'Topic :: Scientific/Engineering',
'Topic :: Scientific/Engineering :: Visualization'
"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Visualization",
],
python_requires=">=3.6"
python_requires=">=3.6",
)

0 comments on commit 8096502

Please sign in to comment.