Skip to content

Commit b84f15a

Browse files
committed
Use single-backticks when appropriate
1 parent bc8b1dd commit b84f15a

File tree

2 files changed

+47
-30
lines changed

2 files changed

+47
-30
lines changed

doc/source/api_reference/graphicsItems/imageitem.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ translation, scaling or rotations effects that persist for all later image data,
3737
user can also directly define and assign such a transform, as shown in the example
3838
below.
3939

40+
.. _ImageItem_performance:
41+
4042
Performance
4143
-----------
4244

pyqtgraph/graphicsItems/ImageItem.py

Lines changed: 45 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import pathlib
23
import warnings
34
from collections.abc import Callable
45

@@ -21,7 +22,18 @@
2122

2223

2324
class ImageItem(GraphicsObject):
24-
"""
25+
"""Graphics object used to display image data.
26+
27+
ImageItem can render images with 1, 3 or 4 channels, use lookup tables to apply
28+
false colors to images, and users can either set levels limits, or rely on
29+
the auto-sampling.
30+
31+
Performance can vary wildly based on the attributes of the inputs provided, see
32+
:ref:`performance <ImageItem_performance>` for guidance if performance is an
33+
important factor.
34+
35+
There is optional `numba` and `cupy` support.
36+
2537
**Bases:** :class:`pyqtgraph.GraphicsObject`
2638
2739
Signals
@@ -93,23 +105,24 @@ def setCompositionMode(self, mode: QtGui.QPainter.CompositionMode):
93105
Composition of the item, often used when overlaying items. Common
94106
options include:
95107
96-
* ``QPainter.CompositionMode.CompositionMode_SourceOver``
108+
* `QPainter.CompositionMode.CompositionMode_SourceOver`
97109
Image replaces the background if it is opaque. Otherwise, it uses the
98110
alpha channel to blend the image with the background, default
99-
* ``QPainter.CompositionMode.CompositionMode_Overlay`` Image color is
111+
* `QPainter.CompositionMode.CompositionMode_Overlay` Image color is
100112
mixed with the background color to reflect the lightness or darkness of
101113
the background
102-
* ``QPainter.CompositionMode.CompositionMode_Plus`` Both the alpha and
114+
* `QPainter.CompositionMode.CompositionMode_Plus` Both the alpha and
103115
color of the image and background pixels are added together.
104-
* ``QPainter.CompositionMode.CompositionMode_Plus`` The output is the
116+
* `QPainter.CompositionMode.CompositionMode_Plus` The output is the
105117
image color multiplied by the background.
106118
107119
See :class:`QPainter.CompositionMode <QPainter.CompositionMode>` in the Qt
108120
documentation for more options and details
109121
110122
See Also
111123
--------
112-
:class:`QPainter.CompositionMode <QPainter.CompositionMode>`
124+
:class:`QPainter.CompositionMode <QPainter.CompositionMode>` : Details all the
125+
possible composition mode options accepted.
113126
"""
114127
self.paintMode = mode
115128
self.update()
@@ -181,7 +194,7 @@ def setLevels(self, levels: npt.ArrayLike | None, update: bool=True):
181194
def getLevels(self) -> numpy.ndarray | None:
182195
"""
183196
Returns the array representing the current level settings. See
184-
:func:`setLevels`. When ``autoLevels`` is active, the format is
197+
:func:`setLevels`. When `autoLevels` is active, the format is
185198
``[blackLevel, whiteLevel]``.
186199
"""
187200
return self.levels
@@ -199,8 +212,7 @@ def setColorMap(self, colorMap: colormap.ColorMap | str):
199212
Raises
200213
------
201214
TypeError
202-
Raised when ``colorMap`` is not of type ``str`` or
203-
:class:`~pyqtgraph.ColorMap`
215+
Raised when `colorMap` is not of type `str` or :class:`~pyqtgraph.ColorMap`
204216
"""
205217
if isinstance(colorMap, colormap.ColorMap):
206218
self._colorMap = colorMap
@@ -220,7 +232,7 @@ def getColorMap(self) -> colormap.ColorMap | None:
220232
return self._colorMap
221233

222234
def setLookupTable(self, lut: npt.ArrayLike | Callable, update: bool=True):
223-
"""Sets lookup table ``lut`` to use for false color display of a monochrome
235+
"""Sets lookup table `lut` to use for false color display of a monochrome
224236
image. See :func:`makeARGB <pyqtgraph.functions.makeARGB>` for more
225237
information on how this is used.
226238
@@ -230,7 +242,7 @@ def setLookupTable(self, lut: npt.ArrayLike | Callable, update: bool=True):
230242
Parameters
231243
----------
232244
lut : array_like or callable
233-
``lut`` can be a callable that accepts the current image as an argument and
245+
`lut` can be a callable that accepts the current image as an argument and
234246
returns the lookup table to use.
235247
update : bool, optional
236248
Update the intermediate image, by default True.
@@ -269,9 +281,9 @@ def setAutoDownsample(self, active: bool=True):
269281
active : bool, optional
270282
If `active` is `True`, the image is automatically downsampled to match the
271283
screen resolution. This improves performance for large images and reduces
272-
aliasing. If ``autoDownsample`` is not specified, then ImageItem will
284+
aliasing. If `autoDownsample` is not specified, then ImageItem will
273285
choose whether to downsample the image based on its size. ``False``
274-
disables automatic downsampling. by default True
286+
disables automatic downsampling. by default ``True``
275287
"""
276288
self.autoDownsample = active
277289
self._renderRequired = True
@@ -355,7 +367,7 @@ def setOpts(self, update: bool=True, **kargs):
355367

356368
def setRect(self, *args):
357369
"""Sets translation and scaling of this ImageItem to display the current image
358-
within the rectangle given as ``rect`` (:class:`QRect` or :class:`QRectF`), or
370+
within the rectangle given as `rect` (:class:`QRect` or :class:`QRectF`), or
359371
described by parameters `x, y, w, h`, defining starting position, width and
360372
height.
361373
@@ -372,7 +384,7 @@ def setRect(self, *args):
372384
373385
See Also
374386
--------
375-
:class:`QRectF`
387+
:class:`QRectF` : See constructor methods for allowable ``*args``
376388
"""
377389
if not args:
378390
# reset scaling and rotation when called without argument
@@ -439,8 +451,8 @@ def setImage(
439451
search subsamples the images and may miss individual bright or dark points
440452
in the data set. If `False`, the search will be omitted.
441453
442-
The default is `False` if a ``levels`` keyword argument is given, and
443-
`True` otherwise.
454+
The default is ``False`` if a `levels` keyword argument is given, and
455+
``True`` otherwise.
444456
levelSamples : int, default 65536
445457
When determining minimum and maximum values, ImageItem only inspects a
446458
subset of pixels no larger than this number. Setting this larger than the
@@ -457,7 +469,7 @@ def setImage(
457469
imageitem.setImage(imagedata.T)
458470
459471
or the interpretation of the data can be changed locally through the
460-
``axisOrder`` keyword or by changing the `imageAxisOrder`
472+
`axisOrder` keyword or by changing the `imageAxisOrder`
461473
:ref:`global configuration option <apiref_config>`
462474
463475
For more information on how the image is processed before displaying, see
@@ -740,20 +752,20 @@ def paint(self, p, *args):
740752
p.setPen(self.border)
741753
p.drawRect(self.boundingRect())
742754

743-
def save(self, fileName: str, *args):
755+
def save(self, fileName: str | pathlib.Path, *args):
744756
"""Saves this image to file. Note that this saves the visible image
745757
(after scale/color changes), not the original data.
746758
747759
Parameters
748760
----------
749-
fileName : str
761+
fileName : str or pathlib.Path
750762
path to save the image to
751763
*args : tuple
752764
arguments that are passed to :meth:`QImage.save <QImage.save>`
753765
754766
See Also
755767
--------
756-
:meth:`QImage.save <QImage.save>`
768+
:meth:`QImage.save <QImage.save>` : ``*args`` is relayed to this method
757769
"""
758770

759771
if self._renderRequired:
@@ -775,15 +787,15 @@ def getHistogram(
775787
Parameters
776788
----------
777789
bins : int or str, optional
778-
The ``bins`` argument and any extra keyword arguments are passed to
790+
The `bins` argument and any extra keyword arguments are passed to
779791
:func:`numpy.histogram()`. If ``bins == 'auto'``, a bin number is
780792
automatically chosen based on the image characteristics, by default
781-
``'auto'``
793+
`'auto'`
782794
step : str or int, optional
783-
The ``step`` argument causes pixels to be skipped when computing the
795+
The `step` argument causes pixels to be skipped when computing the
784796
histogram to save time. If `step` is 'auto', then a step is chosen such
785797
that the analyzed data has dimensions approximating `targetImageSize`
786-
for each axis, by default ``'auto'``
798+
for each axis, by default `'auto'`
787799
perChannel : bool, optional
788800
If ``True``, then a histogram is computed for each channel,
789801
and the output is a list of the results, by default ``False``
@@ -803,7 +815,7 @@ def getHistogram(
803815
804816
See Also
805817
--------
806-
numpy.histogram
818+
numpy.histogram : describes return format in greater detail
807819
"""
808820

809821
if 'targetHistogramSize' in kwds:
@@ -873,12 +885,15 @@ def setPxMode(self, b: bool):
873885
If ``True``, the item will not inherit any scale or rotation transformations from its
874886
parent items, but its position will be transformed as usual.
875887
876-
Read the description of ``ItemIgnoresTransformations`` member of the
877-
:class:`QGraphicsItem.GraphicsItemFlag` enum in the Qt documentation
888+
Parameters
889+
----------
890+
b : bool
891+
Enable pixel model, thus ignoring transformations
878892
879893
See Also
880894
--------
881-
:class:`QGraphicsItem.GraphicsItemFlag`
895+
:class:`QGraphicsItem.GraphicsItemFlag` : Read the description of
896+
`ItemIgnoresTransformations` for more information
882897
883898
"""
884899
self.setFlag(
@@ -976,7 +991,7 @@ def hoverEvent(self, ev):
976991
if self.drawKernel is not None and ev.acceptDrags(
977992
QtCore.Qt.MouseButton.LeftButton
978993
):
979-
# we don't use the click, but we also don't want anyone else to use it
994+
# we don't use the click, but we also don't want anyone else to use it
980995
ev.acceptClicks(QtCore.Qt.MouseButton.LeftButton)
981996
ev.acceptClicks(QtCore.Qt.MouseButton.RightButton)
982997
elif self.removable:

0 commit comments

Comments
 (0)