Skip to content

Commit c107575

Browse files
committed
Fix some sphinx code docs references
Changes the names of various types so that Sphinx can add the correct link to the relevant docs. Such as changing the type callable to typing.Callable. There are many more to fix, but lots of them are due to missing docs to link to for pytac and pyAT
1 parent ec6f9df commit c107575

File tree

7 files changed

+55
-45
lines changed

7 files changed

+55
-45
lines changed

src/atip/load_sim.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def load_from_filepath(
2121
pytac_lattice (pytac.lattice.Lattice): An instance of a Pytac lattice.
2222
at_lattice_filepath (str): The path to a .mat file from which the
2323
Accelerator Toolbox lattice can be loaded.
24-
callback (callable): To be called after completion of each round of
24+
callback (typing.Callable): To be called after completion of each round of
2525
physics calculations.
2626
disable_emittance (bool): Whether the emittance should be calculated.
2727
@@ -44,7 +44,7 @@ def load(pytac_lattice, at_lattice, callback=None, disable_emittance=False):
4444
pytac_lattice (pytac.lattice.Lattice): An instance of a Pytac lattice.
4545
at_lattice (at.lattice_object.Lattice): An instance of an Accelerator
4646
Toolbox lattice object.
47-
callback (callable): To be called after completion of each round of
47+
callback (typing.Callable): To be called after completion of each round of
4848
physics calculations.
4949
disable_emittance (bool): Whether the emittance should be calculated.
5050

src/atip/sim_data_sources.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def __init__(self, at_element, index, atsim, fields=None):
5252
data source is attached to.
5353
index (int): The element's index in the ring, starting from 1.
5454
atsim (ATSimulator): An instance of an ATSimulator object.
55-
fields (list, optional): The fields found on this element.
55+
fields (list, typing.Optional): The fields found on this element.
5656
5757
Raises:
5858
ValueError: if an unsupported field is passed, i.e. a field not in
@@ -111,7 +111,7 @@ def add_field(self, field):
111111
this data_source.
112112
113113
Raises:
114-
FieldException: if the specified field is already present or if it
114+
pytac.FieldException: if the specified field is already present or if it
115115
is not supported.
116116
"""
117117
if field in self._fields:
@@ -128,10 +128,10 @@ def get_value(self, field, handle=None, throw=True):
128128
129129
Args:
130130
field (str): The requested field.
131-
handle (str, optional): Handle is not needed and is only here to
131+
handle (str, typing.Optional): Handle is not needed and is only here to
132132
conform with the structure of the
133133
DataSource base class.
134-
throw (bool, optional): If the check for completion of outstanding
134+
throw (bool, typing.Optional): If the check for completion of outstanding
135135
calculations times out, then:
136136
if True, raise a ControlSystemException;
137137
if False, log a warning and return the
@@ -141,8 +141,8 @@ def get_value(self, field, handle=None, throw=True):
141141
float: The value of the specified field on this data source.
142142
143143
Raises:
144-
FieldException: if the specified field does not exist.
145-
ControlSystemException: if the calculation completion check fails,
144+
pytac.FieldException: if the specified field does not exist.
145+
pytac.ControlSystemException: if the calculation completion check fails,
146146
and throw is True.
147147
"""
148148
# Wait for any outstanding calculations to conclude, to ensure they are
@@ -168,13 +168,13 @@ def set_value(self, field, value, throw=None):
168168
Args:
169169
field (str): The requested field.
170170
value (float): The value to be set.
171-
throw (bool, optional): Throw is not needed and is only here to
171+
throw (bool, typing.Optional): Throw is not needed and is only here to
172172
conform with the structure of the
173173
DataSource base class.
174174
175175
Raises:
176-
HandleException: if the specified field cannot be set to.
177-
FieldException: if the specified field does not exist.
176+
pytac.HandleException: if the specified field cannot be set to.
177+
pytac.FieldException: if the specified field does not exist.
178178
"""
179179
if field in self._fields:
180180
if field in self._set_field_funcs.keys():
@@ -418,10 +418,10 @@ def get_value(self, field, handle=None, throw=True):
418418
419419
Args:
420420
field (str): The requested field.
421-
handle (str, optional): Handle is not needed and is only here to
421+
handle (str, typing.Optional): Handle is not needed and is only here to
422422
conform with the structure of the
423423
DataSource base class.
424-
throw (bool, optional): If the check for completion of outstanding
424+
throw (bool, typing.Optional): If the check for completion of outstanding
425425
calculations times out, then:
426426
if True, raise a ControlSystemException;
427427
if False, log a warning and return the
@@ -431,8 +431,8 @@ def get_value(self, field, handle=None, throw=True):
431431
float: The value of the specified field on this data source.
432432
433433
Raises:
434-
FieldException: if the specified field does not exist.
435-
ControlSystemException: if the calculation completion check fails,
434+
pytac.FieldException: if the specified field does not exist.
435+
pytac.ControlSystemException: if the calculation completion check fails,
436436
and throw is True.
437437
"""
438438
# Wait for any outstanding calculations to conclude, to ensure they are
@@ -469,12 +469,12 @@ def set_value(self, field, value, throw=None):
469469
Args:
470470
field (str): The requested field.
471471
value (float): The value to be set.
472-
throw (bool, optional): Throw is not needed and is only here to
472+
throw (bool, typing.Optional): Throw is not needed and is only here to
473473
conform with the structure of the
474474
DataSource base class.
475475
476476
Raises:
477-
HandleException: as setting values to Pytac lattice fields is not
477+
pytac.HandleException: as setting values to Pytac lattice fields is not
478478
currently supported.
479479
"""
480480
raise HandleException(

src/atip/simulator.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def __init__(self, at_lattice, callback=None, disable_emittance=False):
107107
Args:
108108
at_lattice (at.lattice_object.Lattice): An instance of an AT
109109
lattice object.
110-
callback (callable): Optional, if passed it is called on completion
110+
callback (typing.Callable): Optional, if passed it is called on completion
111111
of each round of physics calculations.
112112
disable_emittance (bool): Whether or not to perform the beam
113113
envelope based emittance calculations.
@@ -142,7 +142,7 @@ def queue_set(self, func, field, value):
142142
"""Add a change to the queue, to be applied when the queue is emptied.
143143
144144
Args:
145-
func (callable): The function to be called to apply the change.
145+
func (typing.Callable): The function to be called to apply the change.
146146
field (str): The field to be changed.
147147
value (float): The value to be set.
148148
"""
@@ -178,7 +178,7 @@ def _recalculate_phys_data(self, callback):
178178
thread to warnings.
179179
180180
Args:
181-
callback (callable): to be called after each round of calculations,
181+
callback (typing.Callable): to be called after each round of calculations,
182182
indicating that they have concluded.
183183
184184
Warns:
@@ -254,7 +254,7 @@ def wait_for_calculations(self, timeout=10):
254254
changes to the AT lattice, i.e. the physics data is fully up to date.
255255
256256
Args:
257-
timeout (float, optional): The number of seconds to wait for.
257+
timeout (float, typing.Optional): The number of seconds to wait for.
258258
259259
Returns:
260260
bool: False if the timeout elapsed before the calculations
@@ -342,7 +342,7 @@ def get_tune(self, field=None):
342342
float: The x or y tune for the AT lattice.
343343
344344
Raises:
345-
FieldException: if the specified field is not valid for tune.
345+
pytac.FieldException: if the specified field is not valid for tune.
346346
"""
347347
tunes = self._lattice_data.tunes
348348
if field is None:
@@ -365,7 +365,7 @@ def get_chromaticity(self, field=None):
365365
float: The x or y chromaticity for the AT lattice.
366366
367367
Raises:
368-
FieldException: if the specified field is not valid for
368+
pytac.FieldException: if the specified field is not valid for
369369
chromaticity.
370370
"""
371371
chrom = self._lattice_data.chrom
@@ -392,7 +392,7 @@ def get_orbit(self, field=None):
392392
array of floats the length of the AT lattice.
393393
394394
Raises:
395-
FieldException: if the specified field is not valid for orbit.
395+
pytac.FieldException: if the specified field is not valid for orbit.
396396
"""
397397
closed_orbit = self._lattice_data.twiss["closed_orbit"]
398398
if field is None:
@@ -421,7 +421,7 @@ def get_dispersion(self, field=None):
421421
AT lattice as an array of floats the length of the AT lattice.
422422
423423
Raises:
424-
FieldException: if the specified field is not valid for dispersion.
424+
pytac.FieldException: if the specified field is not valid for dispersion.
425425
"""
426426
dispersion = self._lattice_data.twiss["dispersion"]
427427
if field is None:
@@ -485,7 +485,7 @@ def get_emittance(self, field=None):
485485
float: The x or y emittance for the AT lattice.
486486
487487
Raises:
488-
FieldException: if the specified field is not valid for emittance.
488+
pytac.FieldException: if the specified field is not valid for emittance.
489489
"""
490490
if not self._disable_emittance:
491491
if field is None:

src/atip/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def loader(mode="I04", callback=None, disable_emittance=False):
3838
3939
Args:
4040
mode (str): The lattice operation mode.
41-
callback (callable): Callable to be called after completion of each
41+
callback (typing.Callable): Callable to be called after completion of each
4242
round of physics calculations in ATSimulator.
4343
disable_emittance (bool): Whether the emittance should be calculated.
4444
@@ -67,7 +67,7 @@ def preload_at(at_lat):
6767
the elements.
6868
6969
returns:
70-
obj: The elems object with the elements loaded onto it by type.
70+
obj (class): The elems object with the elements loaded onto it by type.
7171
"""
7272

7373
class elems:
@@ -114,7 +114,7 @@ def preload(pytac_lat):
114114
to get the elements.
115115
116116
returns:
117-
obj: The elems object with the elements loaded onto it by family.
117+
obj(class): The elems object with the elements loaded onto it by family.
118118
"""
119119

120120
class elems:

src/virtac/atip_server.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,17 @@ def __init__(
6666
):
6767
"""
6868
Args:
69-
ring_mode (string): The ring mode to create the lattice in.
70-
limits_csv (string): The filepath to the .csv file from which to
69+
ring_mode (str): The ring mode to create the lattice in.
70+
limits_csv (str): The filepath to the .csv file from which to
7171
load the pv limits, for more information
7272
see create_csv.py.
73-
feedback_csv (string): The filepath to the .csv file from which to
73+
feedback_csv (str): The filepath to the .csv file from which to
7474
load the feedback records, for more
7575
information see create_csv.py.
76-
mirror_csv (string): The filepath to the .csv file from which to
76+
mirror_csv (str): The filepath to the .csv file from which to
7777
load the mirror records, for more information
7878
see create_csv.py.
79-
tune_csv (string): The filepath to the .csv file from which to
79+
tune_csv (str): The filepath to the .csv file from which to
8080
load the tune feedback records, for more
8181
information see create_csv.py.
8282
disable_emittance (bool): Whether the emittance should be disabled.
@@ -149,7 +149,7 @@ def _create_records(self, limits_csv, disable_emittance):
149149
need to be created for them.
150150
151151
Args:
152-
limits_csv (string): The filepath to the .csv file from which to
152+
limits_csv (str): The filepath to the .csv file from which to
153153
load the pv limits.
154154
disable_emittance (bool): Whether the emittance related PVs should be
155155
created or not.
@@ -297,7 +297,7 @@ def _create_feedback_records(self, feedback_csv, disable_emittance):
297297
cases are also created.
298298
299299
Args:
300-
feedback_csv (string): The filepath to the .csv file to load the
300+
feedback_csv (str): The filepath to the .csv file to load the
301301
records in accordance with.
302302
disable_emittance (bool): Whether the emittance related PVs should be
303303
created or not.
@@ -374,7 +374,7 @@ def _create_mirror_records(self, mirror_csv):
374374
passed, see create_csv.py for more information.
375375
376376
Args:
377-
mirror_csv (string): The filepath to the .csv file to load the
377+
mirror_csv (str): The filepath to the .csv file to load the
378378
records in accordance with.
379379
"""
380380
csv_reader = csv.DictReader(open(mirror_csv))
@@ -537,7 +537,7 @@ def set_feedback_record(self, index, field, value):
537537
Args:
538538
index (int): The index of the element on which to set the value;
539539
starting from 1, 0 is used to set on the lattice.
540-
field (string): The field to set the value to.
540+
field (str): The field to set the value to.
541541
value (number): The value to be set.
542542
543543
Raises:

src/virtac/create_csv.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,17 @@ def generate_pv_limits(lattice):
9999

100100
def generate_mirrored_pvs(lattice):
101101
"""Structure of data:
102-
output type: The type of output record to create, only 'aIn', 'longIn',
102+
103+
output type:
104+
The type of output record to create, only 'aIn', 'longIn',
103105
'Waveform' types are currently supported; if '' then output to an
104106
existing in record already created in ATIPServer, 'caput' is also a
105107
special case it creates a mask for cothread.catools.caput calling
106108
set(value) on this mask will call caput with the output PV and the
107109
passed value.
108-
mirror type: The type of mirroring to apply:
110+
111+
mirror type (The type of mirroring to apply):
112+
109113
- basic: set the value of the input record to the output record.
110114
- summate: sum the values of the input records and set the result to
111115
the output record.
@@ -114,12 +118,18 @@ def generate_mirrored_pvs(lattice):
114118
of the input record and set the result to the output record. N.B.
115119
the only transformation type currently supported is 'inverse'.
116120
- refresh: monitor the in PV and on a change call refresh_record on
117-
the output PV.
118-
in: The PV(s) to be monitored, on change mirror is updated, if multiple
121+
the output PV.
122+
123+
in:
124+
The PV(s) to be monitored, on change mirror is updated, if multiple
119125
then the PVs should be separated by a comma and one space.
120-
out: The single PV to output to, if a 'record type' is spcified then a new
126+
127+
out:
128+
The single PV to output to, if a 'record type' is spcified then a new
121129
record will be created and so must not exist already.
122-
value: The inital value of the output record.
130+
131+
value:
132+
The inital value of the output record.
123133
"""
124134
data = [("output type", "mirror type", "in", "out", "value")]
125135
# Tune PV aliases.

src/virtac/mirror_objects.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class transform:
6464
def __init__(self, transformation, output_record):
6565
"""
6666
Args:
67-
transformation (callable): The transformation to be applied.
67+
transformation (typing.Callable): The transformation to be applied.
6868
output_record (pythonSoftIoc.RecordWrapper): The record to set the
6969
transformed value to.
7070
"""

0 commit comments

Comments
 (0)