Skip to content

Commit 5740b1a

Browse files
Merge pull request #854 from klauer/doc_cleanup
DOC: fix miscellaneous docstring issues
2 parents 7945c24 + b031f8f commit 5740b1a

11 files changed

+127
-59
lines changed

docs/source/data_plugins/calc_plugin.rst

+11-5
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,23 @@ General Calc Plugin channel syntax::
1414

1515
calc://my_variable_name?expr_var_name=channel://address&expr_var_name_two=channel://address&expr=math expression
1616

17-
.. note:: Once a calc channel is created, multiple widgets can be connected to the same channel by providing the name of the variable, like so:
18-
::
17+
.. note::
18+
19+
Once a calc channel is created, multiple widgets can be connected to the
20+
same channel by providing the name of the variable, like so:
21+
22+
::
1923

2024
calc://my_variable_name
2125

22-
.. note:: The calc functions uses url formatting. Where the name attribute is separated by the ? symbol and all other attributes are separated by the & symbol.
23-
::
26+
.. note::
2427

25-
-------------
28+
The calc functions uses url formatting. Where the name attribute is
29+
separated by the ? symbol and all other attributes are separated by the &
30+
symbol.
2631

2732

33+
-------------------
2834
Required Attributes
2935
-------------------
3036

docs/source/data_plugins/local_plugin.rst

+11-15
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Local Plugin
33
========================
44

5-
PyDM uses Data Plugins as sources of information to be displayed at the widgets.
5+
PyDM uses Data Plugins as sources of information to be displayed at the widgets.
66
Local Data Plugin allows users to create and use local variables.
77

88
The Local Data Plugin stores the data that is sent by the widgets through a channel, and broadcasts it to all the listeners connected to this particular local variable channel.
@@ -39,7 +39,7 @@ Attributes Description Format Example
3939
=========== ================================================== ========================
4040
**loc** protocol name for Local Data Plugin `loc://`
4141
**name** | the identifier for a local variable `my_ndarray_var`
42-
| user's choice
42+
| user's choice
4343
**type** | data-type for this variable `type=array`
4444
| refer to :ref:`Variable Types<Variable Types>`
4545
| for more info of acceptable type
@@ -49,7 +49,7 @@ Attributes Description Format Example
4949

5050
Here is a simple example of a channel address format with the required attributes:
5151
::
52-
52+
5353
loc://my_np.array?type=array&init=[1,2,3,4]
5454

5555

@@ -58,20 +58,20 @@ Here is a simple example of a channel address format with the required attribute
5858

5959
-------------
6060

61-
.. _Extra Attributes:
61+
.. _Local Plugin Extra Attributes:
6262

6363
Extra Attributes
6464
----------------
6565

6666
Along with the :ref:`required attributes<Required Attributes>`, the Local Data Plugin can also accept some optional attributes to configure the Local Variables with.
67-
The optional attributes are described in the :ref:`extra attributes<extra attributes table>` table below:
67+
The optional attributes are described in the :ref:`extra attributes<extra attributes table>` table below:
6868

6969

7070

71-
.. _extra attributes table:
71+
.. _extra attributes table:
7272

7373
The table below explains the optional attributes that can go in the *extras*:
74-
74+
7575

7676
=============== =================================== ============ =================================
7777
Attributes Description Type Format Example
@@ -87,7 +87,7 @@ Attributes Description Type Format Example
8787

8888
Here is a simple example of a channel address format with some optional attributes:
8989
::
90-
90+
9191
loc://my.float?type=float&init=1&precision=3&unit=V
9292

9393
-------------
@@ -130,7 +130,7 @@ Attributes Description Type Format Example
130130
**order** memory layout of the array string | `order=K` (*default*)
131131
| others {'A', 'C', 'F'}
132132
**subok** | if *True* then sub-classes bool `subok=false` (*default*)
133-
| will be passed-through
133+
| will be passed-through
134134
**ndmin** minimum number of dimensions int `ndmin=0` (*default*)
135135
=============== =================================== ============= =============================
136136

@@ -155,11 +155,11 @@ The picture below represents a simple example using the Local Data Plugin, where
155155

156156
Right below the Waveform Curve Editor widget, there are two other widgets connected to the 'x' and 'y' local variable respectively::
157157

158-
158+
159159
X-values: loc://x
160160
Y-values: loc://y
161161

162-
Data can be updated in the two X and Y-values widgets and the Waveform Curve Editor will receive the new data and change the curve accordingly, like seen in the picture below:
162+
Data can be updated in the two X and Y-values widgets and the Waveform Curve Editor will receive the new data and change the curve accordingly, like seen in the picture below:
163163

164164

165165

@@ -176,7 +176,3 @@ Miscellaneous
176176
-------------
177177

178178
* If precision is not set through the "extras", and it is set to receive the precision from the PV (Process Variable), the Local Data Plugin will match the precision from the values inserted by the users in the widgets.
179-
180-
181-
182-

docs/source/stylesheets.rst

+7-8
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,14 @@ To help users extend this feature, PyDM offers two main configurations that can
1818
be used:
1919

2020
- **PYDM_STYLESHEET**
21-
Path to the QSS files defining the global stylesheets for the PyDM application.
22-
When used, it will override the default look. If using multiple files they
23-
must be separated by the path separator.
24-
E.g.: ``/path_to/my_style_1.qss:/path_to/other/my_other_style.qss``
25-
21+
Path to the QSS files defining the global stylesheets for the PyDM
22+
application. When used, it will override the default look. If using multiple
23+
files they must be separated by the path separator.
24+
For example: ``/path_to/my_style_1.qss:/path_to/other/my_other_style.qss``
2625
- **PYDM_STYLESHEET_INCLUDE_DEFAULT**
27-
Whether or not to include the PyDM Default stylesheet along with customized
28-
files. Note that the PyDM default stylesheet will have lower precedence compared
29-
to files specified at ``PYDM_STYLESHEET``
26+
Whether or not to include the PyDM Default stylesheet along with customized
27+
files. Note that the PyDM default stylesheet will have lower precedence
28+
compared to files specified at ``PYDM_STYLESHEET``.
3029

3130
Processing Order of Style Sheets
3231
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

docs/source/widgets/archiver_timeplot.rst

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
#######################
1+
#####################################
22
Archiver Appliance Enabled Time Plots
3-
#######################
3+
#####################################
44

55
Time plots can be augmented with the ability to automatically request archived data from an instance
66
of the EPICS archiver appliance if such an instance is available to the user.
77

88
In order to use this functionality, the environment variable PYDM_ARCHIVER_URL must be set to point to
99
the archiver appliance instance. For example:
10+
1011
::
1112
export PYDM_ARCHIVER_URL=http://lcls-archapp.slac.stanford.edu
1213

docs/source/widgets/curve_editor.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ And for the axes tab:
7474
``setAxes`` and ``setCurves`` property to configure the plot properly.
7575

7676
Bar Graphs
77-
++++
77+
++++++++++
78+
7879
By selecting "Bar" from the style drop-down as described above, a curve can be plotted as a bar
7980
graph for waveform and time plots. This style of plot will have four additional options that may be set:
8081

docs/source/widgets/index.rst

+8
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,11 @@ Drawing Widgets
6161
:maxdepth: 1
6262

6363
drawing.rst
64+
65+
Utilities
66+
---------
67+
68+
.. toctree::
69+
:maxdepth: 1
70+
71+
utilities.rst

docs/source/widgets/utilities.rst

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
########################
2+
Display Format Utilities
3+
########################
4+
5+
.. currentmodule:: pydm.widgets.display_format
6+
7+
.. autoclass:: DisplayFormat
8+
:members:
9+
10+
.. autofunction:: parse_value_for_display

pydm/utilities/__init__.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,14 @@ def find_file(fname, base_path=None, mode=None, extra_path=None):
177177
"""
178178
Look for files at the search paths common to PyDM.
179179
180-
Search Order
181-
------------
182-
- base_path
183-
- Qt Designer Path
184-
- Current Dir
185-
- Dirs in extra_path
186-
- Dirs in PYDM_DISPLAYS_PATH
180+
The search order is as follows:
181+
182+
* The ``base_path`` argument
183+
* Qt Designer Path - the path for the current form as reported by the
184+
designer
185+
* The current working directory
186+
* Directories listed in ``extra_path``
187+
* Directories listed in the environment variable ``PYDM_DISPLAYS_PATH``
187188
188189
Parameters
189190
----------

pydm/widgets/archiver_time_plot.py

+11-8
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,17 @@ def receiveArchiveData(self, data: np.ndarray) -> None:
116116
self.archive_data_received_signal.emit()
117117

118118
def insert_archive_data(self, data: np.ndarray) -> None:
119-
""" Inserts data directly into the archive buffer. An example use case would be
120-
zooming into optimized mean-value data and replacing it with the raw data
121-
122-
Parameters
123-
----------
124-
data : np.ndarray
125-
A numpy array of shape (2, length_of_data). Index 0 contains timestamps and index 1 contains
126-
the data observations.
119+
"""
120+
Inserts data directly into the archive buffer.
121+
122+
An example use case would be zooming into optimized mean-value data and
123+
replacing it with the raw data.
124+
125+
Parameters
126+
----------
127+
data : np.ndarray
128+
A numpy array of shape (2, length_of_data). Index 0 contains
129+
timestamps and index 1 contains the data observations.
127130
"""
128131
archive_data_length = len(data[0])
129132
min_x = data[0][0]

pydm/widgets/baseplot.py

+19-11
Original file line numberDiff line numberDiff line change
@@ -615,17 +615,21 @@ def eventFilter(self, obj, event):
615615

616616
def addCurve(self, plot_data_item, curve_color=None, y_axis_name=None):
617617
"""
618-
Adds a curve to this plot. If the y axis parameters are specified, either link this curve to an existing
619-
axis if that axis is already part of this plot, or create a new one and link the curve to it.
618+
Adds a curve to this plot.
619+
620+
If the y axis parameters are specified, either link this curve to an
621+
existing axis if that axis is already part of this plot, or create a
622+
new one and link the curve to it.
623+
620624
Parameters
621625
----------
622626
plot_data_item: BasePlotCurveItem
623627
The curve to add to this plot
624628
curve_color: QColor, optional
625629
The color to draw the curve and axis label in
626630
y_axis_name: str, optional
627-
The name of the axis to link the curve with. If this is the first time seeing this name,
628-
then a new axis will be created for it.
631+
The name of the axis to link the curve with. If this is the first
632+
time seeing this name, then a new axis will be created for it.
629633
"""
630634

631635
if curve_color is None:
@@ -657,7 +661,9 @@ def addAxis(self, plot_data_item: BasePlotCurveItem, name: str, orientation: str
657661
label: Optional[str] = None, min_range: Optional[float] = -1.0,
658662
max_range: Optional[float] = 1.0, enable_auto_range: Optional[bool] = True):
659663
"""
660-
Create an AxisItem with the input name and orientation, and add it to this plot.
664+
Create an AxisItem with the input name and orientation, and add it to
665+
this plot.
666+
661667
Parameters
662668
----------
663669
plot_data_item: BasePlotCurveItem
@@ -673,8 +679,9 @@ def addAxis(self, plot_data_item: BasePlotCurveItem, name: str, orientation: str
673679
max_range: float
674680
The maximum range to display on the axis
675681
enable_auto_range: bool
676-
Whether or not to use autorange for this axis. Min and max range will not be respected
677-
when data goes out of range if this is set to True
682+
Whether or not to use autorange for this axis. Min and max range
683+
will not be respected when data goes out of range if this is set to
684+
True.
678685
679686
Raises
680687
------
@@ -841,10 +848,10 @@ def getShowRightAxis(self):
841848
"""
842849
Provide whether the right y-axis is being shown.
843850
844-
Returns : bool
851+
Returns
845852
-------
846-
True if the graph shows the right y-axis. False if not.
847-
853+
bool
854+
True if the graph shows the right y-axis. False if not.
848855
"""
849856
return self._show_right_axis
850857

@@ -933,8 +940,9 @@ def getShowLegend(self):
933940
"""
934941
Check if the legend is being shown.
935942
936-
Returns : bool
943+
Returns
937944
-------
945+
bool
938946
True if the legend is displayed on the graph; False if not.
939947
"""
940948
return self._show_legend

pydm/widgets/display_format.py

+37-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import math
22
import numpy as np
3+
from typing import Any
34

45
import logging
56
import warnings
@@ -8,15 +9,49 @@
89

910

1011
class DisplayFormat(object):
12+
"""Display format for showing data in a PyDM widget."""
13+
#: The default display format.
1114
Default = 0
15+
#: Show the data as a string.
1216
String = 1
17+
#: Show numerical values as floating point (base 10, decimal) values.
1318
Decimal = 2
19+
#: Show numerical values in scientific / exponential notation.
1420
Exponential = 3
21+
#: Show numerical values in base 16 (hexadecimal) notation.
1522
Hex = 4
23+
#: Show numerical values in base 2 (binary) notation.
1624
Binary = 5
1725

1826

19-
def parse_value_for_display(value, precision, display_format_type=DisplayFormat.Default, string_encoding="utf_8", widget=None):
27+
def parse_value_for_display(
28+
value: Any,
29+
precision: int,
30+
display_format_type: int = DisplayFormat.Default,
31+
string_encoding: str = "utf_8",
32+
widget=None,
33+
):
34+
"""
35+
Format a value to show it in a widget, based on the display format type.
36+
37+
Parameters
38+
----------
39+
value : Any
40+
The value to convert to a string.
41+
precision : int
42+
Precision of floating point values to use.
43+
display_format_type : int, optional
44+
Display format type to use.
45+
string_encoding : str, optional
46+
Encoding to use for strings.
47+
widget : QtWidgets.QWidget, optional
48+
Widget to get a name from for conversion errors.
49+
50+
Returns
51+
-------
52+
str
53+
Formatted version of ``value``.
54+
"""
2055
if value is None:
2156
return ""
2257
try:
@@ -37,7 +72,7 @@ def parse_value_for_display(value, precision, display_format_type=DisplayFormat.
3772
if zeros.size > 0:
3873
value = value[:zeros[0]]
3974
r = value.tobytes().decode(string_encoding)
40-
except:
75+
except Exception:
4176
logger.error("Could not decode {0} using {1} at widget named '{2}'.".format(
4277
value, string_encoding, widget_name))
4378
return value

0 commit comments

Comments
 (0)