Skip to content

Commit 51b6b03

Browse files
authored
Merge pull request #120 from dstansby/doc-edit
General clean up of existing docs
2 parents a5d0f03 + ec8a90b commit 51b6b03

File tree

7 files changed

+45
-36
lines changed

7 files changed

+45
-36
lines changed

docs/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
# You can set these variables from the command line, and also
55
# from the environment for the first two.
6-
SPHINXOPTS ?= -W
6+
SPHINXOPTS ?= -W --keep-going
77
SPHINXBUILD ?= sphinx-build
88
SOURCEDIR = .
99
BUILDDIR = _build

docs/conf.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,18 @@
5656
automodapi_inheritance_diagram = False
5757

5858
intersphinx_mapping = {
59+
"python": ("https://docs.python.org/3/", None),
5960
"napari": ("https://napari.org/", None),
61+
"numpy": ("https://numpy.org/doc/stable/", None),
6062
"matplotlib": ("https://matplotlib.org/", None),
63+
"PyQT6": ("https://www.riverbankcomputing.com/static/Docs/PyQt6/", None),
6164
}
6265

66+
nitpicky = True
67+
# Can't work out how to link this properley using intersphinx and the PyQT6 docs.
68+
# TODO: fix at some point
69+
nitpick_ignore = [("py:class", "PyQt6.QtWidgets.QWidget")]
70+
6371
# Add any paths that contain templates here, relative to this directory.
6472
templates_path = ["_templates"]
6573

docs/make.bat

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ REM Command file for Sphinx documentation
77
if "%SPHINXBUILD%" == "" (
88
set SPHINXBUILD=sphinx-build
99
)
10+
if "%SPHINXOPTS%" == "" (
11+
set SPHINXOPTS="--keep-going"
12+
)
1013
set SOURCEDIR=.
1114
set BUILDDIR=_build
1215

src/napari_matplotlib/base.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@
2222

2323
class NapariMPLWidget(QWidget):
2424
"""
25-
Base Matplotlib canvas. Widget that can be embedded as a napari widget.
25+
Widget containing a Matplotlib canvas and toolbar.
2626
27-
This creates a single FigureCanvas, which contains a single Figure.
28-
It is not responsible for creating any Axes, because different widgets
29-
may want to implement different subplot layouts.
27+
This creates a single FigureCanvas, which contains a single
28+
`~matplotlib.figure.Figure`, and an associated toolbar.
29+
It is not responsible for creating any Axes, because different
30+
widgets may want to implement different subplot layouts.
3031
3132
This class also handles callbacks to automatically update figures when
3233
the layer selection or z-step is changed in the napari viewer. To take
@@ -64,12 +65,12 @@ def __init__(
6465
self.layout().addWidget(self.toolbar)
6566
self.layout().addWidget(self.canvas)
6667

67-
self.setup_callbacks()
68+
self._setup_callbacks()
6869
self.layers: List[napari.layers.Layer] = []
6970

70-
# Accept any number of input layers by default
71+
#: Number of layers taken as input
7172
n_layers_input = Interval(None, None)
72-
# Accept any type of input layer by default
73+
#: Type of layer taken as input
7374
input_layer_types: Tuple[napari.layers.Layer, ...] = (napari.layers.Layer,)
7475

7576
@property
@@ -87,17 +88,17 @@ def n_selected_layers(self) -> int:
8788
@property
8889
def current_z(self) -> int:
8990
"""
90-
Current z-step of the viewer.
91+
Current z-step of the napari viewer.
9192
"""
9293
return self.viewer.dims.current_step[0]
9394

94-
def setup_callbacks(self) -> None:
95+
def _setup_callbacks(self) -> None:
9596
"""
9697
Sets up callbacks.
9798
98-
Sets up callbacks for:
99-
- Layer selection changing
100-
- z-step changing
99+
Sets up callbacks for when:
100+
- Layer selection is changed
101+
- z-step is changed
101102
"""
102103
# z-step changed in viewer
103104
self.viewer.dims.events.current_step.connect(self._draw)
@@ -106,7 +107,7 @@ def setup_callbacks(self) -> None:
106107

107108
def update_layers(self, event: napari.utils.events.Event) -> None:
108109
"""
109-
Update the layers attribute with currently selected layers and re-draw.
110+
Update the ``layers`` attribute with currently selected layers and re-draw.
110111
"""
111112
self.layers = list(self.viewer.layers.selection)
112113
self._on_update_layers()
@@ -149,7 +150,7 @@ def add_single_axes(self) -> None:
149150

150151
@staticmethod
151152
def apply_napari_colorscheme(ax: Axes) -> None:
152-
"""Apply napari-compatible colorscheme to an axes object."""
153+
"""Apply napari-compatible colorscheme to an Axes."""
153154
# changing color of axes background to transparent
154155
ax.set_facecolor("none")
155156

src/napari_matplotlib/scatter.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from .base import NapariMPLWidget
88
from .util import Interval
99

10-
__all__ = ["ScatterWidget", "FeaturesScatterWidget"]
10+
__all__ = ["ScatterBaseWidget", "ScatterWidget", "FeaturesScatterWidget"]
1111

1212

1313
class ScatterBaseWidget(NapariMPLWidget):
@@ -69,7 +69,7 @@ def _get_data(self) -> Tuple[npt.NDArray[Any], npt.NDArray[Any], str, str]:
6969

7070
class ScatterWidget(ScatterBaseWidget):
7171
"""
72-
Widget to display scatter plot of two similarly shaped image layers.
72+
Scatter data in two similarly shaped layers.
7373
7474
If there are more than 500 data points, a 2D histogram is displayed instead
7575
of a scatter plot, to avoid too many scatter points.
@@ -137,7 +137,7 @@ def __init__(
137137
@property
138138
def x_axis_key(self) -> Union[str, None]:
139139
"""
140-
Key to access x axis data from the FeaturesTable.
140+
Key for the x-axis data.
141141
"""
142142
if self._selectors["x"].count() == 0:
143143
return None
@@ -152,7 +152,7 @@ def x_axis_key(self, key: str) -> None:
152152
@property
153153
def y_axis_key(self) -> Union[str, None]:
154154
"""
155-
Key to access y axis data from the FeaturesTable.
155+
Key for the y-axis data.
156156
"""
157157
if self._selectors["y"].count() == 0:
158158
return None

src/napari_matplotlib/slice.py

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def __init__(
5454
self.update_layers(None)
5555

5656
@property
57-
def layer(self) -> napari.layers.Layer:
57+
def _layer(self) -> napari.layers.Layer:
5858
"""
5959
Layer being plotted.
6060
"""
@@ -77,28 +77,19 @@ def current_dim_index(self) -> int:
7777
return _dims[::-1].index(self.current_dim)
7878

7979
@property
80-
def selector_values(self) -> Dict[str, int]:
80+
def _selector_values(self) -> Dict[str, int]:
8181
"""
8282
Values of the slice selectors.
8383
"""
8484
return {d: self.slice_selectors[d].value() for d in _dims_sel}
8585

86-
def update_slice_selectors(self) -> None:
87-
"""
88-
Update range and enabled status of the slice selectors, and the value
89-
of the z slice selector.
90-
"""
91-
# Update min/max
92-
for i, dim in enumerate(_dims_sel):
93-
self.slice_selectors[dim].setRange(0, self.layer.data.shape[i])
94-
95-
def get_xy(self) -> Tuple[npt.NDArray[Any], npt.NDArray[Any]]:
86+
def _get_xy(self) -> Tuple[npt.NDArray[Any], npt.NDArray[Any]]:
9687
"""
9788
Get data for plotting.
9889
"""
99-
x = np.arange(self.layer.data.shape[self.current_dim_index])
90+
x = np.arange(self._layer.data.shape[self.current_dim_index])
10091

101-
vals = self.selector_values
92+
vals = self._selector_values
10293
vals.update({"z": self.current_z})
10394

10495
slices = []
@@ -113,7 +104,7 @@ def get_xy(self) -> Tuple[npt.NDArray[Any], npt.NDArray[Any]]:
113104

114105
# Reverse since z is the first axis in napari
115106
slices = slices[::-1]
116-
y = self.layer.data[tuple(slices)].ravel()
107+
y = self._layer.data[tuple(slices)].ravel()
117108

118109
return x, y
119110

@@ -127,8 +118,8 @@ def draw(self) -> None:
127118
"""
128119
Clear axes and draw a 1D plot.
129120
"""
130-
x, y = self.get_xy()
121+
x, y = self._get_xy()
131122

132123
self.axes.plot(x, y)
133124
self.axes.set_xlabel(self.current_dim)
134-
self.axes.set_title(self.layer.name)
125+
self.axes.set_title(self._layer.name)

src/napari_matplotlib/util.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ def __init__(self, lower_bound: Optional[int], upper_bound: Optional[int]):
2828
self.lower = lower_bound
2929
self.upper = upper_bound
3030

31+
def __repr__(self) -> str:
32+
"""
33+
Get string representation.
34+
"""
35+
return f"Interval({self.lower}, {self.upper})"
36+
3137
def __contains__(self, val: int) -> bool:
3238
"""
3339
Return True if val is in the current interval.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy