Skip to content

Commit 45c1de6

Browse files
committed
try to fix docstring issues
1 parent 677e766 commit 45c1de6

File tree

2 files changed

+30
-58
lines changed

2 files changed

+30
-58
lines changed

src/sme_contrib/plot.py

+29-57
Original file line numberDiff line numberDiff line change
@@ -139,40 +139,22 @@ def facet_grid_3D(
139139
plotfuncs_kwargs: dict[str, dict[str, Any]] = {},
140140
) -> pv.Plotter:
141141
"""
142-
Create a 3D facet plot using PyVista. This follows the seaborn.FacetGrid concept. This function creates a grid of subplots where each subplot is filled by a function in the plotfuncs argument. The keys for plotfuncs and data must be the same, such that plotfuncs can be unambiguously mapped over the data dictionary.
143-
Do not attempt to plot 2D images and 3D images into the same facet grid, as this will create odd artifacts and
144-
may not work as expected.
145-
Parameters:
146-
-----------
147-
data : dict[str, np.ndarray]
148-
A dictionary where keys are labels and values are numpy arrays containing the data to be plotted.
149-
plotfuncs : dict[str, Callable]
150-
A dictionary where keys are labels and values are functions with signature f(
151-
label:str,
152-
data:np.ndarray | pyvista.ImageData | pyvista.UniformGrid,
153-
plotter:pv.Plotter,
154-
panel:tuple[int, int],
155-
show_cmap:bool=show_cmap,
156-
cmap=cmap,
157-
**plotfuncs_kwargs
158-
) -> None
159-
show_cmap : bool, optional
160-
Whether to show the color map. Default is False.
161-
cmap : str | np.ndarray | pv.LookupTable, optional
162-
The color map to use. Default is "viridis".
163-
portrait : bool, optional
164-
Whether to use a portrait layout. Default is False.
165-
linked_views : bool, optional
166-
Whether to link the views of the subplots. Default is True.
167-
plotter_kwargs : dict, optional
168-
Additional keyword arguments to pass to the PyVista Plotter.
169-
plotfuncs_kwargs : dict[str, dict[str, Any]], optional
170-
Additional keyword arguments to pass to each plotting function.
142+
Create a 3D facet plot using PyVista.
143+
144+
This follows the seaborn.FacetGrid concept. This function creates a grid of subplots where each subplot is filled by a function in the plotfuncs argument. The keys for plotfuncs and data must be the same, such that plotfuncs can be unambiguously mapped over the data dictionary. Do not attempt to plot 2D images and 3D images into the same facet grid, as this will create odd artifacts and may not work as expected.
145+
146+
Args:
147+
data : dict[str, np.ndarray] A dictionary where keys are labels and values are numpy arrays containing the data to be plotted.
148+
plotfuncs : dict[str, Callable] A dictionary where keys are labels and values are functions with signature f(label:str, data:np.ndarray | pyvista.ImageData | pyvista.UniformGrid, plotter:pv.Plotter, panel:tuple[int, int], show_cmap:bool=show_cmap, cmap=cmap, **plotfuncs_kwargs ) -> None
149+
show_cmap : bool, optional Whether to show the color map. Default is False.
150+
cmap : str | np.ndarray | pv.LookupTable, optional The color map to use. Default is "viridis".
151+
portrait : bool, optional Whether to use a portrait layout. Default is False.
152+
linked_views : bool, optional Whether to link the views of the subplots. Default is True.
153+
plotter_kwargs : dict, optional Additional keyword arguments to pass to the PyVista Plotter.
154+
plotfuncs_kwargs : dict[str, dict[str, Any]], optional Additional keyword arguments to pass to each plotting function.
171155
172156
Returns:
173-
--------
174-
pv.Plotter
175-
The PyVista Plotter object with the created facet plot.
157+
pv.Plotter The PyVista Plotter object with the created facet plot.
176158
"""
177159
if data.keys() != plotfuncs.keys():
178160
raise ValueError(
@@ -218,33 +200,23 @@ def facet_grid_animate_3D(
218200
) -> str:
219201
"""
220202
Create a 3D animation from a series of data snapshots using PyVista.
203+
221204
This series must be a list of dictionaries with the data for each frame keyed by a label used to title the panel it will be plotted into. The final plot will have as many subplots as there are labels in the data dictionaries. The keys for plotfuncs and data must be the same.
222-
Parameters:
223-
-----------
224-
filename : str
225-
The name of the output movie file.
226-
data : list[dict[str, np.ndarray]]
227-
A list of dictionaries containing the data for each timestep.
228-
plotfuncs : dict[str, Callable]
229-
A dictionary of plotting functions keyed by data label. The keys for plotfuncs and data must be the same.
230-
show_cmap : bool, optional
231-
Whether to show the color map (default is False).
232-
cmap : str | np.ndarray | pv.LookupTable, optional
233-
The colormap to use (default is "viridis").
234-
portrait : bool, optional
235-
Whether to use portrait layout (default is False).
236-
linked_views : bool, optional
237-
Whether to link the views of the subplots (default is True).
238-
titles : list[dict[str, str]], optional
239-
A list of dictionaries containing titles for each subplot (default is an empty list).
240-
plotter_kwargs : dict, optional
241-
Additional keyword arguments to pass to the PyVista Plotter (default is an empty dictionary).
242-
plotfuncs_kwargs : dict[str, dict[str, Any]], optional
243-
Additional keyword arguments to pass to each plotting function (default is an empty dictionary).
205+
206+
Args:
207+
filename : str The name of the output movie file.
208+
data : list[dict[str, np.ndarray]] A list of dictionaries containing the data for each timestep.
209+
plotfuncs : dict[str, Callable] A dictionary of plotting functions keyed by data label. The keys for plotfuncs and data must be the same.
210+
show_cmap : bool, optional Whether to show the color map (default is False).
211+
cmap : str | np.ndarray | pv.LookupTable, optional The colormap to use (default is "viridis").
212+
portrait : bool, optional Whether to use portrait layout (default is False).
213+
linked_views : bool, optional Whether to link the views of the subplots (default is True).
214+
titles : list[dict[str, str]], optional A list of dictionaries containing titles for each subplot (default is an empty list).
215+
plotter_kwargs : dict, optional Additional keyword arguments to pass to the PyVista Plotter (default is an empty dictionary).
216+
plotfuncs_kwargs : dict[str, dict[str, Any]], optional Additional keyword arguments to pass to each plotting function (default is an empty dictionary).
217+
244218
Returns:
245-
--------
246-
str
247-
The filename of the created movie.
219+
str The filename of the created movie.
248220
"""
249221

250222
if len(titles) > 0 and len(titles) != len(data):

src/sme_contrib/pyvista_utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def make_discrete_colormap(
2525
cmap: str = "tab10", values: np.ndarray = np.array([])
2626
) -> pv.LookupTable:
2727
"""
28-
Create a discrete colormap for use with PyVista with as many colors as unique values in the `values`array based on a given matplotlbit colormap. The colors will possibly repeat if there are more unique values than colors in the colormap. In this case, the outcome is intended, e.g., for separability of regions in the visualization,
28+
Create a discrete colormap for use with PyVista with as many colors as unique values in the ``values``array based on a given matplotlbit colormap. The colors will possibly repeat if there are more unique values than colors in the colormap. In this case, the outcome is intended, e.g., for separability of regions in the visualization,
2929
3030
Parameters:
3131
cmap (str): The name of the colormap to use. Default is 'tab10'.

0 commit comments

Comments
 (0)