Skip to content
Merged
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
3 changes: 2 additions & 1 deletion examples/dash_apps/04_minimal_cache_overview.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ def plot_graph(_):
)


# --- FigureResampler update callback ---
# ------ FigureResampler update callback ------


# The plotly-resampler callback to update the graph after a relayout event (= zoom/pan)
# As we use the figure again as output, we need to set: allow_duplicate=True
Expand Down
1 change: 1 addition & 0 deletions examples/dash_apps/05_cache_overview_subplots.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ def plot_graph(_):

# --- FigureResampler update callback ---


# The plotly-resampler callback to update the graph after a relayout event (= zoom/pan)
# As we use the figure again as output, we need to set: allow_duplicate=True
@app.callback(
Expand Down
1 change: 1 addition & 0 deletions examples/dash_apps/11_sine_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ def construct_display_graph(n, exp, n_added_graphs) -> FigureResampler:

# --- FigureResampler update callback ---


# The plotly-resampler callback to update the graph after a relayout event (= zoom/pan)
# As we use the figure again as output, we need to set: allow_duplicate=True
@app.callback(
Expand Down
1 change: 1 addition & 0 deletions examples/dash_apps/12_file_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ def plot_graph(n_clicks, *folder_list):

# --------- FigureResampler update callback ---------


# The plotly-resampler callback to update the graph after a relayout event (= zoom/pan)
# As we use the figure again as output, we need to set: allow_duplicate=True
@app.callback(
Expand Down
1 change: 1 addition & 0 deletions examples/dash_apps/13_coarse_fine.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
TODO: add an rectangle on the coarse graph

"""

from __future__ import annotations

__author__ = "Jonas Van Der Donckt"
Expand Down
6 changes: 3 additions & 3 deletions plotly_resampler/aggregation/gap_handler_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ def insert_fill_value_between_gaps(
# Set the NaN values
# We add the gap index offset (via the np.arange) to the indices to account for
# the repeats (i.e., expanded y_agg array).
y_agg_exp_nan[
np.where(gap_mask)[0] + np.arange(gap_mask.sum())
] = self.fill_value
y_agg_exp_nan[np.where(gap_mask)[0] + np.arange(gap_mask.sum())] = (
self.fill_value
)

return y_agg_exp_nan, idx_exp_nan
30 changes: 17 additions & 13 deletions plotly_resampler/figure_resampler/figure_resampler_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,9 +597,7 @@ def _parse_get_trace_props(
hf_y = (
trace["y"]
if hasattr(trace, "y") and hf_y is None
else hf_y.values
if isinstance(hf_y, (pd.Series, pd.Index))
else hf_y
else hf_y.values if isinstance(hf_y, (pd.Series, pd.Index)) else hf_y
)
# NOTE: the if will not be triggered for a categorical series its values
if not hasattr(hf_y, "dtype"):
Expand All @@ -608,17 +606,21 @@ def _parse_get_trace_props(
hf_text = (
hf_text
if hf_text is not None
else trace["text"]
if hasattr(trace, "text") and trace["text"] is not None
else None
else (
trace["text"]
if hasattr(trace, "text") and trace["text"] is not None
else None
)
)

hf_hovertext = (
hf_hovertext
if hf_hovertext is not None
else trace["hovertext"]
if hasattr(trace, "hovertext") and trace["hovertext"] is not None
else None
else (
trace["hovertext"]
if hasattr(trace, "hovertext") and trace["hovertext"] is not None
else None
)
)

hf_marker_size = (
Expand Down Expand Up @@ -1114,9 +1116,11 @@ def add_traces(

# Convert each trace into a BaseTraceType object
data = [
self._data_validator.validate_coerce(trace)[0]
if not isinstance(trace, BaseTraceType)
else trace
(
self._data_validator.validate_coerce(trace)[0]
if not isinstance(trace, BaseTraceType)
else trace
)
for trace in data
]

Expand All @@ -1137,7 +1141,7 @@ def add_traces(
limit_to_views = [limit_to_views] * len(data)

zipped = zip(data, max_n_samples, downsamplers, gap_handlers, limit_to_views)
for (i, (trace, max_out, downsampler, gap_handler, limit_to_view)) in enumerate(
for i, (trace, max_out, downsampler, gap_handler, limit_to_view) in enumerate(
zipped
):
if (
Expand Down
91 changes: 39 additions & 52 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ numpy = [
]
orjson = "^3.10.0" # Faster json serialization (from 3.10 onwards f16 is supported)
# Optional dependencies
Flask-Cors = { version = "^3.0.10", optional = true }
Flask-Cors = { version = "^4.0.2", optional = true }
# Lock kaleido dependency until https://github.com/plotly/Kaleido/issues/156 is resolved
kaleido = {version = "0.2.1", optional = true}
tsdownsample = ">=0.1.3"
Expand All @@ -58,7 +58,7 @@ tsdownsample = ">=0.1.3"
inline_persistent = ["kaleido", "Flask-Cors"]

[tool.poetry.dev-dependencies]
pytest = "^6.2.5"
pytest = "^7.2.0"
pytest-cov = "^3.0.0"
selenium = "4.2.0"
pytest-selenium = "^2.0.1"
Expand All @@ -72,7 +72,7 @@ ipywidgets = "^7.7.1" # needs to be v7 in order to support serialization
memory-profiler = "^0.60.0"
line-profiler = "^4.0"
ruff = "^0.0.262"
black = "^22.6.0"
black = "^24.3.0"
pytest-lazy-fixture = "^0.6.3"
# yep = "^0.4" # c code profiling
mkdocs = "^1.5.3"
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Fixtures and helper functions for testing"""


import os
from typing import Union

Expand Down Expand Up @@ -71,6 +70,7 @@ def driver():
driver = webdriver.Chrome(
options=options,
# executable_path="/home/jeroen/chromedriver",
# executable_path="/home/jonas/Documents/chromedriver-linux64/chromedriver",
desired_capabilities=d,
)
# driver = webdriver.Firefox(executable_path='/home/jonas/git/gIDLaB/plotly-dynamic-resampling/geckodriver')
Expand Down
10 changes: 6 additions & 4 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ def construct_hf_data_dict(hf_x, hf_y, **kwargs):
hf_data_dict = {
"x": hf_x,
"y": hf_y,
"axis_type": "date"
if isinstance(hf_x, pd.DatetimeIndex)
or pd.core.dtypes.common.is_datetime64_any_dtype(hf_x)
else "linear",
"axis_type": (
"date"
if isinstance(hf_x, pd.DatetimeIndex)
or pd.core.dtypes.common.is_datetime64_any_dtype(hf_x)
else "linear"
),
"downsampler": MinMaxLTTB(),
"gap_handler": MedDiffGapHandler(),
"max_n_samples": 1_000,
Expand Down
Loading