Skip to content

Commit

Permalink
Merge with master
Browse files Browse the repository at this point in the history
  • Loading branch information
marthacryan committed Feb 7, 2025
2 parents 4573074 + 19b611d commit 10b2b87
Show file tree
Hide file tree
Showing 22 changed files with 35 additions and 11,314 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ commands:
name: Test dependencdies not imported
command: |
. venv/bin/activate
pytest -x test_init/test_dependencies_not_imported.py
python -m pytest -x test_init/test_dependencies_not_imported.py
- run:
name: Test lazy imports
command: |
. venv/bin/activate
pytest -x test_init/test_lazy_imports.py
python -m pytest -x test_init/test_lazy_imports.py
test_orca:
parameters:
py:
Expand Down
5 changes: 1 addition & 4 deletions requires-optional.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,13 @@ numpy
# matplotlib==2.2.2

## testing dependencies ##
# see also test_requirements/*.txt for specific Python versions
coverage==4.3.1
mock==2.0.0
pytest==8.1.1
xarray
pytz

## orca dependencies ##
requests
psutil

## code formatting ##
pre-commit
black==22.3.0
Expand Down
7 changes: 4 additions & 3 deletions test_requirements/requirements_311_optional.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ pyshp==2.1.3
matplotlib==3.8.0
scikit-image==0.22.0
psutil==5.7.0
kaleido
orjson==3.8.12
polars[timezone]
pyarrow
narwhals>=1.15.1
anywidget==0.9.13
polars[timezone]
pyarrow
kaleido
plotly-geo
1 change: 1 addition & 0 deletions test_requirements/requirements_312_optional.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ pyarrow
narwhals>=1.15.1
anywidget==0.9.13
jupyter-console==6.4.4
plotly-geo
20 changes: 10 additions & 10 deletions tests/test_core/test_subplots/test_make_subplots.py
Original file line number Diff line number Diff line change
Expand Up @@ -1954,10 +1954,10 @@ def test_make_subplots_spacing_error():
# vertical_spacing is raised when spacing exceeds that value
for match in [
(
"^%s spacing cannot be greater than \(1 / \(%s - 1\)\) = %f."
r"^%s spacing cannot be greater than \(1 / \(%s - 1\)\) = %f."
% ("Vertical", "rows", 1.0 / 50.0)
).replace(".", "\."),
"The resulting plot would have 51 rows \(rows=51\)\.$",
).replace(".", r"\."),
r"The resulting plot would have 51 rows \(rows=51\)\.$",
]:
with pytest.raises(
ValueError,
Expand All @@ -1966,10 +1966,10 @@ def test_make_subplots_spacing_error():
fig = subplots.make_subplots(51, 1, vertical_spacing=0.0201)
for match in [
(
"^%s spacing cannot be greater than \(1 / \(%s - 1\)\) = %f."
r"^%s spacing cannot be greater than \(1 / \(%s - 1\)\) = %f."
% ("Horizontal", "cols", 1.0 / 50.0)
).replace(".", "\."),
"The resulting plot would have 51 columns \(cols=51\)\.$",
).replace(".", r"\."),
r"The resulting plot would have 51 columns \(cols=51\)\.$",
]:
with pytest.raises(
ValueError,
Expand Down Expand Up @@ -2011,18 +2011,18 @@ def test_make_subplots_spacing_error():
# This shouldn't happen so we assert False to force failure
assert False
with pytest.raises(
ValueError, match="^Horizontal spacing must be between 0 and 1\.$"
ValueError, match=r"^Horizontal spacing must be between 0 and 1\.$"
):
fig = subplots.make_subplots(1, 1, horizontal_spacing=-0.01)
with pytest.raises(
ValueError, match="^Horizontal spacing must be between 0 and 1\.$"
ValueError, match=r"^Horizontal spacing must be between 0 and 1\.$"
):
fig = subplots.make_subplots(1, 1, horizontal_spacing=1.01)
with pytest.raises(
ValueError, match="^Vertical spacing must be between 0 and 1\.$"
ValueError, match=r"^Vertical spacing must be between 0 and 1\.$"
):
fig = subplots.make_subplots(1, 1, vertical_spacing=-0.01)
with pytest.raises(
ValueError, match="^Vertical spacing must be between 0 and 1\.$"
ValueError, match=r"^Vertical spacing must be between 0 and 1\.$"
):
fig = subplots.make_subplots(1, 1, vertical_spacing=1.01)
3 changes: 2 additions & 1 deletion tests/test_io/test_to_from_plotly_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@ def test_sanitize_json(engine):
fig = go.Figure(layout=layout)
fig_json = pio.to_json_plotly(fig, engine=engine)
layout_2 = json.loads(fig_json)["layout"]
del layout_2["template"]
if "template" in layout_2:
del layout_2["template"]

assert layout == layout_2

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def test_np_layers(self):
"center": {"lon": 0.5, "lat": 51},
},
}
data = [{"type": "scattermapbox"}]
data = [{"type": "scattermap"}]

fig = go.Figure(data=data, layout=layout)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_optional/test_px/test_px_hover.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def test_sunburst_hoverdict_color(backend):

def test_date_in_hover(constructor):
df = nw.from_native(
constructor({"date": ["2015-04-04 19:31:30+01:00"], "value": [3]})
constructor({"date": ["2015-04-04 19:31:30+0100"], "value": [3]})
).with_columns(date=nw.col("date").str.to_datetime(format="%Y-%m-%d %H:%M:%S%z"))
fig = px.scatter(df.to_native(), x="value", y="value", hover_data=["date"])

Expand Down
14 changes: 11 additions & 3 deletions tests/test_optional/test_px/test_px_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,19 @@
from packaging import version
import unittest.mock as mock
from plotly.express._core import build_dataframe
from plotly import optional_imports
from pandas.testing import assert_frame_equal
import sys
import warnings


# FIXME: don't test with vaex if vaex isn't installed
if (optional_imports.get_module("vaex") is None) and (sys.version_info >= (3, 12)):
TEST_LIBS = ["polars"]
else:
TEST_LIBS = ["vaex", "polars"]


def test_numpy():
fig = px.scatter(x=[1, 2, 3], y=[2, 3, 4], color=[1, 3, 9])
assert np.all(fig.data[0].x == np.array([1, 2, 3]))
Expand Down Expand Up @@ -342,7 +350,7 @@ def __dataframe__(self, allow_copy: bool = True):
or sys.version_info >= (3, 12),
reason="plotly doesn't use a dataframe interchange protocol for pandas < 2.0.2",
)
@pytest.mark.parametrize("test_lib", ["vaex", "polars"])
@pytest.mark.parametrize("test_lib", TEST_LIBS)
def test_build_df_from_vaex_and_polars(test_lib):
if test_lib == "vaex":
import vaex as lib
Expand All @@ -365,7 +373,7 @@ def test_build_df_from_vaex_and_polars(test_lib):
or sys.version_info >= (3, 12),
reason="plotly doesn't use a dataframe interchange protocol for pandas < 2.0.2",
)
@pytest.mark.parametrize("test_lib", ["vaex", "polars"])
@pytest.mark.parametrize("test_lib", TEST_LIBS)
@pytest.mark.parametrize(
"hover_data", [["sepal_width"], {"sepal_length": False, "sepal_width": ":.2f"}]
)
Expand Down Expand Up @@ -393,7 +401,7 @@ def test_build_df_with_hover_data_from_vaex_and_polars(test_lib, hover_data):

def test_timezones(constructor):
df = nw.from_native(
constructor({"date": ["2015-04-04 19:31:30+01:00"], "value": [3]})
constructor({"date": ["2015-04-04 19:31:30+0100"], "value": [3]})
).with_columns(nw.col("date").str.to_datetime(format="%Y-%m-%d %H:%M:%S%z"))
args = dict(data_frame=df.to_native(), x="date", y="value")
out = build_dataframe(args, go.Scatter)
Expand Down
Empty file removed tests/test_orca/__init__.py
Empty file.
Loading

0 comments on commit 10b2b87

Please sign in to comment.