Skip to content

Commit 1cd3b20

Browse files
committed
docs: clarify figure factory return types (#5396)
1 parent 38374ac commit 1cd3b20

3 files changed

Lines changed: 36 additions & 2 deletions

File tree

‎plotly/figure_factory/_quiver.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ def create_quiver(
2727
for more information on valid kwargs call
2828
help(plotly.graph_objs.Scatter)
2929
30-
:rtype (dict): returns a representation of quiver figure.
30+
Returns
31+
-------
32+
plotly.graph_objects.Figure
33+
A Plotly figure containing the quiver arrows.
3134
3235
Example 1: Trivial Quiver
3336

‎plotly/figure_factory/_streamline.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ def create_streamline(
5555
for more information on valid kwargs call
5656
help(plotly.graph_objs.Scatter)
5757
58-
:rtype (dict): returns a representation of streamline figure.
58+
Returns
59+
-------
60+
plotly.graph_objects.Figure
61+
A Plotly figure containing the streamlines and arrows.
5962
6063
Example 1: Plot simple streamline and increase arrow size
6164
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""Figure-factory return type documentation regression checks."""
2+
3+
import inspect
4+
5+
import pytest
6+
7+
import plotly.figure_factory as ff
8+
from plotly.graph_objects import Figure
9+
10+
11+
@pytest.mark.parametrize(
12+
"factory, kwargs",
13+
[
14+
(ff.create_quiver, {"x": [0], "y": [0], "u": [1], "v": [1]}),
15+
(
16+
ff.create_streamline,
17+
{
18+
"x": [0, 1, 2],
19+
"y": [0, 1, 2],
20+
"u": [[1, 1, 1], [1, 1, 1], [1, 1, 1]],
21+
"v": [[1, 1, 1], [1, 1, 1], [1, 1, 1]],
22+
},
23+
),
24+
],
25+
)
26+
def test_factory_return_docs_match_runtime(factory, kwargs):
27+
assert "Returns\n-------\nplotly.graph_objects.Figure" in inspect.getdoc(factory)
28+
assert isinstance(factory(**kwargs), Figure)

0 commit comments

Comments
 (0)