Skip to content

Commit

Permalink
✈️ ➡️ 🇧🇪 Autosize support (#273)
Browse files Browse the repository at this point in the history
* ✈️ 🇧🇪 fix for #259

* 💨 linting

* 💨 adding autosize support

* ✨ updating action versions

* 🙈 skip dtype test on window

* 🙏 skip test
  • Loading branch information
jonasvdd committed Nov 20, 2023
1 parent dcfb78b commit 8a7e34c
Show file tree
Hide file tree
Showing 5 changed files with 383 additions and 226 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
lfs: true
- name: Set up Python 3.10
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Cache poetry
id: cached-poetry-dependencies
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}-python-${{ matrix.python-version }}
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ jobs:
shell: bash

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
lfs: true
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

Expand All @@ -50,7 +50,7 @@ jobs:
version: 1.5.1
- name: Cache poetry
id: cached-poetry-dependencies
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}-python-${{ matrix.python-version }}
Expand All @@ -70,12 +70,12 @@ jobs:
run: |
poetry run pytest --cov=plotly_resampler --junitxml=junit/test-results-${{ matrix.python-version }}.xml --cov-report=xml tests
- name: Upload pytest test results
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: pytest-results-${{ matrix.python-version }}
path: junit/test-results-${{ matrix.python-version }}.xml
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v3
563 changes: 355 additions & 208 deletions examples/basic_example.ipynb

Large diffs are not rendered by default.

21 changes: 12 additions & 9 deletions plotly_resampler/figure_resampler/figure_resampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,8 @@ def show_dash(
), f"mode must be one of {available_modes}"
graph_properties = {} if graph_properties is None else graph_properties
assert "config" not in graph_properties # There is a param for config
if self["layout"]["autosize"] is True and self["layout"]["height"] is None:
graph_properties.setdefault("style", {}).update({"height": "100%"})

# 0. Check if the traces need to be updated when there is a xrange set
# This will be the case when the users has set a xrange (via the `update_layout`
Expand Down Expand Up @@ -569,17 +571,18 @@ def show_dash(
else:
# jupyter dash uses a normal Dash app as figure
app = dash.Dash("local_app", **app_init_kwargs)

# fmt: off
div = dash.html.Div(
[
dash.dcc.Graph(
id="resample-figure", figure=self, config=config, **graph_properties
),
TraceUpdater(
id="trace-updater", gdID="resample-figure", sequentialUpdate=False
),
]
style={
"display": "flex", "flex-flow": "column",
"height": "95vh", "width": "100%",
},
children=[
dash.dcc.Graph(id="resample-figure", figure=self, config=config, **graph_properties),
TraceUpdater(id="trace-updater", gdID="resample-figure", sequentialUpdate=False),
],
)
# # fmt: on
if self._create_overview:
overview_config = config.copy() if config is not None else {}
overview_config["displayModeBar"] = False
Expand Down
9 changes: 8 additions & 1 deletion tests/test_figure_resampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

__author__ = "Jonas Van Der Donckt, Jeroen Van Der Donckt, Emiel Deprost"


import datetime
import multiprocessing
import subprocess
import sys
import time
from datetime import timedelta
from typing import List
Expand Down Expand Up @@ -129,6 +129,10 @@ def test_add_trace_not_resampling_insert_gaps():


def test_various_dtypes(float_series):
# skip the test on windows
if sys.platform.lower().startswith("win"):
pytest.skip("Skipping test on windows")

# List of dtypes supported by orjson >= 3.8
valid_dtype_list = [
np.bool_,
Expand Down Expand Up @@ -1192,6 +1196,9 @@ def test_showdash_not_hanging_when_port_in_use():


def test_manual_jupyterdashpersistentinline():
if sys.platform.lower().startswith("win"):
pytest.skip("This test is currently not supported on windows")

# Manually call the JupyterDashPersistentInline its method
# This requires some gimmicky stuff to mimmick the behaviour of a jupyter notebook.

Expand Down

0 comments on commit 8a7e34c

Please sign in to comment.