Skip to content

Commit 59bc88a

Browse files
committed
Update arrays documentation
1 parent 1ee9ca3 commit 59bc88a

File tree

12 files changed

+189
-75
lines changed

12 files changed

+189
-75
lines changed

docs/modules/arrays.rst

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,38 @@
1-
ARRAYS
1+
Arrays configuration
22
********
33

44
.. automodule:: pyaml.arrays.array
55
:members:
6+
:exclude-members: model_config
7+
8+
.. automodule:: pyaml.arrays.element
9+
:members:
10+
:exclude-members: model_config, ConfigModel
11+
12+
.. automodule:: pyaml.arrays.bpm
13+
:members:
14+
:exclude-members: model_config, ConfigModel
615

716
.. automodule:: pyaml.arrays.magnet
817
:members:
18+
:exclude-members: model_config, ConfigModel
19+
20+
.. automodule:: pyaml.arrays.cfm_magnet
21+
:members:
22+
:exclude-members: model_config, ConfigModel
23+
24+
25+
Arrays usage
26+
********
27+
28+
.. automodule:: pyaml.arrays.element_array
29+
:members:
30+
31+
.. automodule:: pyaml.arrays.bpm_array
32+
:members:
933

1034
.. automodule:: pyaml.arrays.magnet_array
1135
:members:
36+
37+
.. automodule:: pyaml.arrays.cfm_magnet_array
38+
:members:

docs/modules/configuration.rst

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,3 @@ Configuration
2121

2222
.. automodule:: pyaml.configuration.csvmatrix
2323
:members:
24-
25-
.. automodule:: pyaml.configuration.models
26-
:members:
27-
28-
.. automodule:: pyaml.configuration.config_exception
29-
:members:

docs/modules/tuning_tools.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
Tuning tools
22
***************
33

4-
.. automodule:: pyaml.tuning_tools.LOCO.loco
4+
.. automodule:: pyaml.tuning_tools.tune
55
:members:
66

7-
.. automodule:: pyaml.tuning_tools.SOFB.sofb
7+
.. automodule:: pyaml.tuning_tools.tune.loco
88
:members:
99

10-
.. automodule:: pyaml.tuning_tools.TUNE.tune
10+
.. automodule:: pyaml.tuning_tools.SOFB.sofb
1111
:members:

pyaml/arrays/array.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Magnet array configuration
2+
Array configuration
33
"""
44

55
from pydantic import BaseModel, ConfigDict
@@ -10,17 +10,26 @@
1010

1111

1212
class ArrayConfigModel(BaseModel):
13+
"""
14+
Base class for array confirguration
15+
16+
Parameters:
17+
-----------
18+
name: str
19+
Family name
20+
elements: list[str]
21+
List of pyaml element names
22+
"""
23+
1324
model_config = ConfigDict(arbitrary_types_allowed=True, extra="forbid")
1425

1526
name: str
16-
"""Family name"""
1727
elements: list[str]
18-
"""List of pyaml element names"""
1928

2029

2130
class ArrayConfig(object):
2231
"""
23-
Class that implements configuration for access to arrays (families)
32+
Base class that implements configuration for access to arrays (families)
2433
"""
2534

2635
def __init__(self, cfg: ArrayConfigModel):

pyaml/arrays/bpm.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,20 @@ class ConfigModel(ArrayConfigModel): ...
99

1010

1111
class BPM(ArrayConfig):
12+
"""
13+
BPM array confirguration
14+
15+
Example
16+
-------
17+
18+
A BPM array configuration can also be created by code using the following example::
19+
20+
from pyaml.arrays.bpm import BPM,ConfigModel as BPMArrayConfigModel
21+
bpmArray = BPM(
22+
BPMArrayConfigModel(name="MyBPMs", elements=["bpm1","bpm2"])
23+
)
24+
"""
25+
1226
def __init__(self, cfg: ArrayConfigModel):
1327
super().__init__(cfg)
1428

pyaml/arrays/bpm_array.py

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,23 +54,30 @@ def set_aggregator(self, agg: DeviceAccessList):
5454
class BPMArray(ElementArray):
5555
"""
5656
Class that implements access to a BPM array
57+
58+
Parameters
59+
----------
60+
arrayName : str
61+
Array name
62+
bpms: list[BPM]
63+
BPM list, all elements must be attached to the same instance of
64+
either a Simulator or a ControlSystem.
65+
use_aggregator : bool
66+
Use aggregator to increase performance by using paralell
67+
access to underlying devices.
68+
69+
Example
70+
-------
71+
72+
An array can be retrieved from the configuration as in the following example::
73+
74+
sr = Accelerator.load("acc.yaml")
75+
bpms = sr.design.get_bpms("BPMs")
76+
77+
5778
"""
5879

5980
def __init__(self, arrayName: str, bpms: list[BPM], use_aggregator=True):
60-
"""
61-
Construct a BPM array
62-
63-
Parameters
64-
----------
65-
arrayName : str
66-
Array name
67-
bpms: list[BPM]
68-
BPM list, all elements must be attached to the same instance of
69-
either a Simulator or a ControlSystem.
70-
use_aggregator : bool
71-
Use aggregator to increase performance by using paralell
72-
access to underlying devices.
73-
"""
7481
super().__init__(arrayName, bpms, use_aggregator)
7582

7683
self.__hvpos = RWBPMPosition(arrayName, bpms)
@@ -86,20 +93,20 @@ def __init__(self, arrayName: str, bpms: list[BPM], use_aggregator=True):
8693
@property
8794
def positions(self) -> RWBPMPosition:
8895
"""
89-
Give access to bpm posttions of each bpm of this array
96+
Returns position of each bpm of this array
9097
"""
9198
return self.__hvpos
9299

93100
@property
94101
def h(self) -> RWBPMSinglePosition:
95102
"""
96-
Give access to bpm H posttions of each bpm of this array
103+
Returns horizontal position of each bpm of this array
97104
"""
98105
return self.__hpos
99106

100107
@property
101108
def v(self) -> RWBPMSinglePosition:
102109
"""
103-
Give access to bpm V posttions of each bpm of this array
110+
Returns vertical position of each bpm of this array
104111
"""
105112
return self.__vpos

pyaml/arrays/cfm_magnet.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,22 @@ class ConfigModel(ArrayConfigModel): ...
99

1010

1111
class CombinedFunctionMagnet(ArrayConfig):
12+
"""
13+
Combined function magnet array confirguration
14+
15+
Example
16+
-------
17+
18+
A magnet array configuration can also be created by code using
19+
the following example::
20+
21+
from pyaml.arrays.cfm_magnet import CombinedFunctionMagnet
22+
from pyaml.arrays.cfm_magnet import ConfigModel as CFMagnetConfigModel
23+
magArray = CombinedFunctionMagnet(
24+
CFMagnetConfigModel(name="myCFM", elements=["mag1","mag2"])
25+
)
26+
"""
27+
1228
def __init__(self, cfg: ArrayConfigModel):
1329
super().__init__(cfg)
1430

pyaml/arrays/cfm_magnet_array.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,18 @@ def unit(self) -> list[str]:
8080

8181
class CombinedFunctionMagnetArray(ElementArray):
8282
"""
83-
Class that implements access to a magnet array
83+
Class that implements access to a combined function magnet array
84+
85+
Parameters
86+
----------
87+
arrayName : str
88+
Array name
89+
magnets: list[Magnet]
90+
Magnet list, all elements must be attached to the same instance of
91+
either a Simulator or a ControlSystem.
92+
use_aggregator : bool
93+
Use aggregator to increase performance by using paralell
94+
access to underlying devices.
8495
"""
8596

8697
def __init__(
@@ -89,20 +100,6 @@ def __init__(
89100
magnets: list[CombinedFunctionMagnet],
90101
use_aggregator=False,
91102
):
92-
"""
93-
Construct a magnet array
94-
95-
Parameters
96-
----------
97-
arrayName : str
98-
Array name
99-
magnets: list[Magnet]
100-
Magnet list, all elements must be attached to the same instance of
101-
either a Simulator or a ControlSystem.
102-
use_aggregator : bool
103-
Use aggregator to increase performance by using paralell
104-
access to underlying devices.
105-
"""
106103
super().__init__(arrayName, magnets, use_aggregator)
107104

108105
self.__rwstrengths = RWMagnetStrengths(arrayName, magnets)

pyaml/arrays/element.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,23 @@ class ConfigModel(ArrayConfigModel): ...
99

1010

1111
class Element(ArrayConfig):
12+
"""
13+
Element array confirguration
14+
15+
Example
16+
-------
17+
18+
An element array configuration can also be created by code using
19+
the following example::
20+
21+
from pyaml.arrays.element import Element,ConfigModel as ElementArrayConfigModel
22+
elemArray = Element(
23+
ElementArrayConfigModel(name="MyArray", elements=["elt1","elt2"])
24+
)
25+
26+
27+
"""
28+
1229
def __init__(self, cfg: ArrayConfigModel):
1330
super().__init__(cfg)
1431

pyaml/arrays/element_array.py

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,30 @@
1010

1111
class ElementArray(list[Element]):
1212
"""
13-
Class that implements access to a element array
13+
Class that implements access to an element array
14+
15+
Parameters
16+
----------
17+
arrayName : str
18+
Array name
19+
elements: list[Element]
20+
Element list, all elements must be attached to the same instance of
21+
either a Simulator or a ControlSystem.
22+
use_aggregator : bool
23+
Use aggregator to increase performance by using paralell
24+
access to underlying devices.
25+
26+
Example
27+
-------
28+
29+
An array can be retrieved from the configuration as in the following example::
30+
31+
sr = Accelerator.load("acc.yaml")
32+
elts = sr.design.get_elemens("QuadForTune")
33+
1434
"""
1535

1636
def __init__(self, arrayName: str, elements: list[Element], use_aggregator=True):
17-
"""
18-
Construct an element array
19-
20-
Parameters
21-
----------
22-
arrayName : str
23-
Array name
24-
elements: list[Element]
25-
Element list, all elements must be attached to the same instance of
26-
either a Simulator or a ControlSystem.
27-
use_aggregator : bool
28-
Use aggregator to increase performance by using paralell
29-
access to underlying devices.
30-
"""
3137
super().__init__(i for i in elements)
3238
self.__name = arrayName
3339
if len(elements) > 0:
@@ -47,9 +53,15 @@ def get_peer(self):
4753
return self.__peer
4854

4955
def get_name(self) -> str:
56+
"""
57+
Returns the array name
58+
"""
5059
return self.__name
5160

5261
def names(self) -> list[str]:
62+
"""
63+
Returns the element names
64+
"""
5365
return [e.get_name() for e in self]
5466

5567
def __create_array(self, arrName: str, eltType: type, elements: list):

0 commit comments

Comments
 (0)