Skip to content

Commit

Permalink
Merge pull request #124 from PatrikHlobil/use-poetry-as-package-manager
Browse files Browse the repository at this point in the history
use poetry as package manager
  • Loading branch information
PatrikHlobil authored Mar 25, 2022
2 parents 3b9356e + 34efdfb commit e71bb52
Show file tree
Hide file tree
Showing 15 changed files with 1,191 additions and 429 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.6', '3.7', '3.8', '3.9']
python-version: ['3.7', '3.8', '3.9']
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -22,9 +22,10 @@ jobs:
sudo apt-get update
sudo apt-get install openjdk-8-jre
python -m pip install --upgrade pip
python -m pip install black pypandoc
pip install -r Tests/requirements_test.txt
python -m pip install poetry
# Only Test Pyspark API for supported Python versions:
if [ "${{ matrix.python-version }}" != "3.10" ]; then echo "Install Pyspark" && poetry add pyspark; fi
poetry install
- name: Test with pytest
run: |
pip install .
pytest --color=yes -s -x -vv --cov-report term-missing --cov=pandas_bokeh Tests/
poetry run pytest --color=yes -s -x -vv --cov-report term-missing --cov=pandas_bokeh Tests/
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ github-pages-tmp/
!index.html
!template.html
docs/sphinx/source/index.md
venv
.DS_Store
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,7 @@ Now, before every commit you make to your repository, it will automatically appl
[verdimrc](https://github.com/verdimrc)

* Pull request[#96](https://github.com/PatrikHlobil/Pandas-Bokeh/pull/96) *fix problem when passing string-values to `bins`*

[vroger11](https://github.com/vroger11)

* Pull request[#115](https://github.com/PatrikHlobil/Pandas-Bokeh/pull/115) *Fix longitude and latitude values checking*
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ p_scatter = df.plot_bokeh.scatter(
)

# Combine Table and Scatterplot via grid layout:
pandas_bokeh.plot_grid([[data_table, p_scatter]], plot_width=400, plot_height=350)
pandas_bokeh.plot_grid([[data_table, p_scatter]], width=400, height=350)
```
<p id="scatterplot_picture"> </p>

Expand Down Expand Up @@ -468,7 +468,7 @@ p_stacked_hbar = df.plot_bokeh.barh(
#Plot all barplot examples in a grid:
pandas_bokeh.plot_grid([[p_bar, p_stacked_bar],
[p_hbar, p_stacked_hbar]],
plot_width=450)
width=450)
```

![Barplot3](docs/Images/Barplot3.png)
Expand Down Expand Up @@ -556,7 +556,7 @@ p_hist_cum = df_hist.plot_bokeh.hist(
title="Normal distributions (normed & cumulative)",
show_figure=False)

pandas_bokeh.plot_grid([[p_hist, p_hist_cum]], plot_width=450, plot_height=300)
pandas_bokeh.plot_grid([[p_hist, p_hist_cum]], width=450, height=300)
```

![Histogram2](docs/Images/Histogram2.png)
Expand Down Expand Up @@ -1124,7 +1124,7 @@ df = pd.DataFrame({"Animal": ["Mouse", "Rabbit", "Dog", "Tiger", "Elefant", "Wal
"Weight [g]": [19, 3000, 40000, 200000, 6000000, 50000000]})
p_scientific = df.plot_bokeh(x="Animal", y="Weight [g]", show_figure=False)
p_non_scientific = df.plot_bokeh(x="Animal", y="Weight [g]", disable_scientific_axes="y", show_figure=False,)
pandas_bokeh.plot_grid([[p_scientific, p_non_scientific]], plot_width = 450)
pandas_bokeh.plot_grid([[p_scientific, p_non_scientific]], width = 450)
```

![Number format](docs/Images/Scientific_axes.png)
Expand Down Expand Up @@ -1209,16 +1209,16 @@ p_hist = df_hist.plot_bokeh(

#Make Dashboard with Grid Layout:
pandas_bokeh.plot_grid([[p_line, p_bar],
[p_scatter, p_hist]], plot_width=450)
[p_scatter, p_hist]], width=450)
```

![Dashboard Layout](docs/Images/Startimage.gif)

Using a combination of *row* and *column* elements (see also [Bokeh Layouts](https://bokeh.pydata.org/en/latest/docs/user_guide/layout.html)) allow for a very easy general arrangement of elements. An alternative layout to the one above is:

```python
p_line.plot_width = 900
p_hist.plot_width = 900
p_line.width = 900
p_hist.width = 900

layout = pandas_bokeh.column(p_line,
pandas_bokeh.row(p_scatter, p_bar),
Expand Down
6 changes: 6 additions & 0 deletions Release_Notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,9 @@ Plots like scatterplot or histogram also have many more additional customization
## 0.5.5

* Display adaptive xticks per default

# 0.6.0

* Drop support for Python 3.6
* Rename **plot_height -> height, plot_width -> width** in `pandas_bokeh.plot_grid` interface
* Bugfixes (i.e. fix of lattitude/longitude checking -> thanks @vroger11)
20 changes: 10 additions & 10 deletions Tests/test_PandasBokeh.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import json
import os

import numpy as np
Expand All @@ -18,6 +17,7 @@
##############################################################################
#################################FIXTURES#####################################
##############################################################################
pytestmark = pytest.mark.filterwarnings("error")


@pytest.fixture(scope="function")
Expand Down Expand Up @@ -547,7 +547,7 @@ def test_barplot_layout(df_fruits):
p_stacked_hbar_pandas_backend,
],
],
plot_width=450,
width=450,
show_plot=False,
return_html=True,
)
Expand Down Expand Up @@ -681,8 +681,8 @@ def test_histogram_average_diplay(df_hist):

p_average = pandas_bokeh.plot_grid(
[[p_hist, p_hist_cum, p_hist_cum_pandas_backend]],
plot_width=450,
plot_height=300,
width=450,
height=300,
show_plot=False,
)

Expand Down Expand Up @@ -746,8 +746,8 @@ def test_area_plots(df_energy):
[p_area, p_area_normed],
[p_area_pandas_backend, p_area_normed_pandas_backend],
],
plot_width=450,
plot_height=300,
width=450,
height=300,
show_plot=False,
)

Expand Down Expand Up @@ -797,8 +797,8 @@ def test_pieplot(df_election):
[p_pie, p_pie_multiple],
[p_pie_pandas_backend, p_pie_multiple_pandas_backend],
],
plot_width=450,
plot_height=300,
width=450,
height=300,
show_plot=False,
)

Expand Down Expand Up @@ -833,8 +833,8 @@ def test_mapplot(df_mapplot):
[p_map, p_map_accessor],
[p_map_pandas_backend, p_map_accessor_pandas_backend],
],
plot_width=450,
plot_height=300,
width=450,
height=300,
show_plot=False,
)

Expand Down
3 changes: 1 addition & 2 deletions Tests/test_PySpark.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import json
import os
import sys

Expand All @@ -23,7 +22,7 @@ def spark():


@pytest.mark.skipif(
sys.version_info >= (3, 8), reason="Pyspark 2.4.2 requires Python <= 3.7"
sys.version_info >= (3, 10), reason="Pyspark 3.2.1 requires Python <= 3.9"
)
def test_basic_lineplot_pyspark(spark):
"""Test for basic lineplot with Pyspark"""
Expand Down
339 changes: 0 additions & 339 deletions pandas_bokeh/.ipynb_checkpoints/README-checkpoint.md

This file was deleted.

17 changes: 8 additions & 9 deletions pandas_bokeh/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,11 @@ def stepplot(self, **kwargs):
pass


# Define Bokeh-plot method for PySpark DataFrames:
if sys.version_info[1] < 8: # TODO: pyspark currently does not support Python 3.8!
try:
import pyspark

plot_bokeh = CachedAccessor("plot_bokeh", FramePlotMethods)
pyspark.sql.dataframe.DataFrame.plot_bokeh = plot_bokeh
except ImportError:
pass
# Define Bokeh-plot method for PySpark DataFrames:¥
try:
import pyspark

plot_bokeh = CachedAccessor("plot_bokeh", FramePlotMethods)
pyspark.sql.dataframe.DataFrame.plot_bokeh = plot_bokeh
except ImportError:
pass
4 changes: 2 additions & 2 deletions pandas_bokeh/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ def plot_grid(children, show_plot=True, return_html=False, **kwargs):
-ncols (int, optional) – Specify the number of columns you would like in your grid.
You must only pass an un-nested list of plots (as opposed to a list of lists of
plots) when using ncols.
- plot_width (int, optional) – The width you would like all your
- width (int, optional) – The width you would like all your
plots to be
- plot_height (int, optional) – The height you would like all your
- height (int, optional) – The height you would like all your
plots to be.
- toolbar_options (dict, optional) – A dictionary of options that
will be used to construct the grid’s toolbar (an instance of ToolbarBox). If
Expand Down
11 changes: 5 additions & 6 deletions pandas_bokeh/geoplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def add_x_and_y_columns(row, geometry):
df_new.append(add_x_and_y_columns(row, geometry))

if geometry.type == "MultiPolygon":
for polygon in geometry:
for polygon in geometry.geoms:
df_new.append(add_x_and_y_columns(row, polygon))

df_new = pd.DataFrame(df_new)
Expand All @@ -125,7 +125,6 @@ def add_x_and_y_columns(row, geometry):


def get_tick_formatter(formatter_arg):

if issubclass(formatter_arg.__class__, TickFormatter):
return formatter_arg
elif isinstance(formatter_arg, str):
Expand Down Expand Up @@ -225,8 +224,8 @@ def geoplot( # noqa C901
"title": title,
"x_axis_label": xlabel,
"y_axis_label": ylabel,
"plot_width": 600,
"plot_height": 400,
"width": 600,
"height": 400,
"toolbar_location": toolbar_location,
"active_scroll": "wheel_zoom",
"x_axis_type": "mercator",
Expand All @@ -235,8 +234,8 @@ def geoplot( # noqa C901
}
if figsize is not None:
width, height = figsize
figure_options["plot_width"] = width
figure_options["plot_height"] = height
figure_options["width"] = width
figure_options["height"] = height
if webgl:
figure_options["output_backend"] = "webgl"

Expand Down
27 changes: 16 additions & 11 deletions pandas_bokeh/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@ def plot( # noqa C901
"title": title,
"toolbar_location": toolbar_location,
"active_scroll": "wheel_zoom",
"plot_width": 600,
"plot_height": 400,
"width": 600,
"height": 400,
"output_backend": "webgl",
"sizing_mode": sizing_mode,
"x_axis_location": x_axis_location,
Expand All @@ -261,8 +261,8 @@ def plot( # noqa C901

if figsize is not None:
width, height = figsize
figure_options["plot_width"] = width
figure_options["plot_height"] = height
figure_options["width"] = width
figure_options["height"] = height
if logx:
figure_options["x_axis_type"] = "log"
if logy:
Expand Down Expand Up @@ -1608,15 +1608,13 @@ def pieplot(
max_col_stringlength = max([len(col) for col in data_cols])

# Create Figure for Pieplot:
plot_width = figure_options["plot_width"]
plot_height = figure_options["plot_height"]
title = figure_options["title"]
toolbar_location = None
x_range = (-1.4 - 0.05 * max_col_stringlength, 2)
y_range = (-1.2, 1.2)
p = figure(
plot_width=plot_width,
plot_height=plot_height,
width=figure_options["width"],
height=figure_options["height"],
title=title,
toolbar_location=toolbar_location,
x_range=x_range,
Expand Down Expand Up @@ -2425,8 +2423,8 @@ def _initialize_rangetool(p, x_axis_type, source):
# Initialize range tool plot
p_rangetool = figure(
title="Drag the box to change the range above.",
plot_height=130,
plot_width=p.plot_width,
height=130,
width=p.width,
y_range=p.y_range,
x_axis_type=x_axis_type,
y_axis_type=None,
Expand All @@ -2436,7 +2434,14 @@ def _initialize_rangetool(p, x_axis_type, source):

# Need to explicitly set the initial range of the plot for the range tool.
start_index = int(0.75 * len(source["__x__values"]))
p.x_range = Range1d(source["__x__values"][start_index], source["__x__values"][-1])
start = source["__x__values"][start_index]
end = source["__x__values"][-1]
# Explicitly cast to python datetime object due to a bug in numpy
# (see https://github.com/bokeh/bokeh/blob/branch-3.0/bokeh/core/property/bases.py#L251):
if source["__x__values"].dtype.name == "datetime64[ns]":
start = datetime.datetime.fromtimestamp(int(start) / 1_000_000_000)
end = datetime.datetime.fromtimestamp(int(end) / 1_000_000_000)
p.x_range = Range1d(start, end)

range_tool = RangeTool(x_range=p.x_range)
range_tool.overlay.fill_color = "navy"
Expand Down
Loading

0 comments on commit e71bb52

Please sign in to comment.