Skip to content

Commit dc56ca7

Browse files
authored
Merge pull request #31 from T-Nicholls/BBA_changes
BBA Changes
2 parents d1df35f + d82837d commit dc56ca7

33 files changed

+8330
-2492
lines changed

.github/workflows/code.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
strategy:
1111
fail-fast: false
1212
matrix:
13-
python: ["3.7", "3.8"]
13+
python: ["3.8", "3.9"]
1414

1515
steps:
1616
- name: Checkout Source

INSTALL.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ATIP Installation
44

55
This guide is for Linux and is based on the current structures of AT and Pytac,
66
if you find a mistake anywhere in ATIP please raise an issue on ATIP's GitHub
7-
page, `here. <https://github.com/dls-controls/atip>`_
7+
page, `here. <https://github.com/DiamondLightSource/atip>`_
88

99
Initial Setup and Installation
1010
------------------------------
@@ -18,7 +18,7 @@ Initial Setup and Installation
1818
1. Clone ATIP::
1919

2020
$ cd <source-directory>
21-
$ git clone https://github.com/dls-controls/atip.git
21+
$ git clone https://github.com/DiamondLightSource/atip.git
2222

2323
2. Create a pipenv and install the dependencies::
2424

Pipfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ mock = "*"
1313
flake8 = "<4.0"
1414
sphinx = "*"
1515
sphinx_rtd_theme = "*"
16-
black = "==21.5b2"
16+
black = "==22.3.0"
1717

1818
[packages]
1919
# All production requirements from setup.cfg.

Pipfile.lock

Lines changed: 167 additions & 343 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
.. image:: https://travis-ci.org/dls-controls/atip.svg?branch=master
2-
:target: https://travis-ci.org/dls-controls/atip
3-
.. image:: https://coveralls.io/repos/github/dls-controls/atip/badge.svg?branch=master
4-
:target: https://coveralls.io/github/dls-controls/atip?branch=master
1+
.. image:: https://travis-ci.org/DiamondLightSource/atip.svg?branch=master
2+
:target: https://travis-ci.org/DiamondLightSource/atip
3+
.. image:: https://coveralls.io/repos/github/DiamondLightSource/atip/badge.svg?branch=master
4+
:target: https://coveralls.io/github/DiamondLightSource/atip?branch=master
55
.. image:: https://readthedocs.org/projects/atip/badge/?version=latest
66
:target: https://atip.readthedocs.io/en/latest/?badge=latest
77
.. image:: https://badge.fury.io/py/atip.svg
@@ -11,7 +11,7 @@
1111
ATIP - Accelerator Toolbox Interface for Pytac
1212
==============================================
1313

14-
ATIP is an addition to `Pytac <https://github.com/dls-controls/pytac>`_,
14+
ATIP is an addition to `Pytac <https://github.com/DiamondLightSource/pytac>`_,
1515
a framework for controlling particle accelerators. ATIP adds a simulator to
1616
Pytac, which can be used and addressed in the same way as a real accelerator.
1717

@@ -108,7 +108,7 @@ that AT element is returned.
108108
The ``ATSimulator`` object has a queue of pending changes. When a set request
109109
is received by an element, the element puts the changes onto the queue of the
110110
``ATSimulator``. Inside the ``ATSimulator`` a
111-
`Cothread <https://github.com/dls-controls/cothread>`_ thread checks the
111+
`Cothread <https://github.com/DiamondLightSource/cothread>`_ thread checks the
112112
length of the queue. When it sees changes on the queue, the thread
113113
recalculates the physics data of the lattice to ensure that it is up to date.
114114
This means that the emittance and linear optics data held by ``ATSimulator``

atip/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""ATIP: Accelerator Toolbox Interface for Pytac.
22
See README.rst & INSTALL.rst for more information.
33
"""
4-
from . import simulator, load_sim, sim_data_sources, utils
4+
from . import load_sim, sim_data_sources, simulator, utils
55

6-
__all__ = ["simulator", "load_sim", "sim_data_sources", "utils"]
6+
__all__ = ["load_sim", "sim_data_sources", "simulator", "utils"]

atip/load_sim.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
import at
33
import pytac
44
from pytac.exceptions import FieldException
5-
from pytac.load_csv import DEFAULT_UC
5+
from pytac.units import NullUnitConv
66

7-
from atip.simulator import ATSimulator
87
from atip.sim_data_sources import ATElementDataSource, ATLatticeDataSource
9-
8+
from atip.simulator import ATSimulator
109

1110
# List of all the element fields that can be currently simulated.
1211
SIMULATED_FIELDS = {"a1", "b0", "b1", "b2", "x", "y", "f", "x_kick", "y_kick"}
@@ -55,7 +54,7 @@ def load(pytac_lattice, at_lattice, callback=None, disable_emittance=False):
5554
if len(at_lattice) != len(pytac_lattice):
5655
raise ValueError(
5756
"Incompatible AT and Pytac lattices, length mismatch "
58-
"(AT:{0} Pytac:{1}).".format(len(at_lattice), len(pytac_lattice))
57+
f"(AT:{len(at_lattice)} Pytac:{len(pytac_lattice)})."
5958
)
6059
# Initialise an instance of the ATSimulator Object.
6160
atsim = ATSimulator(at_lattice, callback, disable_emittance)
@@ -75,5 +74,5 @@ def load(pytac_lattice, at_lattice, callback=None, disable_emittance=False):
7574
try:
7675
pytac_lattice.get_unitconv(field)
7776
except FieldException:
78-
pytac_lattice.set_unitconv(field, DEFAULT_UC)
77+
pytac_lattice.set_unitconv(field, NullUnitConv())
7978
return pytac_lattice

atip/sim_data_sources.py

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import at
66
import pytac
7-
from pytac.exceptions import FieldException, HandleException, ControlSystemException
7+
from pytac.exceptions import ControlSystemException, FieldException, HandleException
88

99

1010
class ATElementDataSource(pytac.data_source.DataSource):
@@ -87,9 +87,7 @@ def __init__(self, at_element, index, atsim, fields=None):
8787
# We assume that every set field has a corresponding get field.
8888
supported_fields = set(self._get_field_funcs.keys())
8989
if not all(f in supported_fields for f in fields):
90-
raise FieldException(
91-
"Unsupported field(s) {0}.".format(fields - supported_fields)
92-
)
90+
raise FieldException(f"Unsupported field(s) {fields - supported_fields}.")
9391
else:
9492
self._fields = list(fields)
9593

@@ -117,11 +115,10 @@ def add_field(self, field):
117115
"""
118116
if field in self._fields:
119117
raise FieldException(
120-
"Field {0} already present on element data "
121-
"source {1}.".format(field, self)
118+
f"Field {field} already present on element data source {self}."
122119
)
123120
elif field not in self._get_field_funcs.keys():
124-
raise FieldException("Unsupported field {0}.".format(field))
121+
raise FieldException(f"Unsupported field {field}.")
125122
else:
126123
self._fields.append(field)
127124

@@ -151,7 +148,7 @@ def get_value(self, field, handle=None, throw=True):
151148
# complete before a value is returned; if the wait times out then raise
152149
# an error message or log a warning according to the value of throw.
153150
if not self._atsim.wait_for_calculations():
154-
error_msg = "Check for completion of outstanding " "calculations timed out."
151+
error_msg = "Check for completion of outstanding calculations timed out."
155152
if throw:
156153
raise ControlSystemException(error_msg)
157154
else:
@@ -160,9 +157,7 @@ def get_value(self, field, handle=None, throw=True):
160157
if field in self._fields:
161158
return self._get_field_funcs[field]()
162159
else:
163-
raise FieldException(
164-
"No field {0} on AT element {1}.".format(field, self._at_element)
165-
)
160+
raise FieldException(f"No field {field} on AT element {self._at_element}.")
166161

167162
def set_value(self, field, value, throw=None):
168163
"""Set the value for a field. The field and value go onto the queue of
@@ -182,17 +177,13 @@ def set_value(self, field, value, throw=None):
182177
"""
183178
if field in self._fields:
184179
if field in self._set_field_funcs.keys():
185-
self._atsim.up_to_date.Reset()
186180
self._atsim.queue_set(self._make_change, field, value)
187181
else:
188182
raise HandleException(
189-
"Field {0} cannot be set on element data"
190-
" source {1}.".format(field, self)
183+
f"Field {field} cannot be set on element data source {self}."
191184
)
192185
else:
193-
raise FieldException(
194-
"No field {0} on AT element {1}.".format(field, self._at_element)
195-
)
186+
raise FieldException(f"No field {field} on AT element {self._at_element}.")
196187

197188
def _make_change(self, field, value):
198189
"""Calls the appropriate field setting function to actually modify the
@@ -466,7 +457,7 @@ def get_value(self, field, handle=None, throw=True):
466457
return self._field_funcs[field]()
467458
else:
468459
raise FieldException(
469-
"Lattice data source {0} does not have field " "{1}".format(self, field)
460+
f"Lattice data source {self} does not have field {field}"
470461
)
471462

472463
def set_value(self, field, value, throw=None):
@@ -486,5 +477,5 @@ def set_value(self, field, value, throw=None):
486477
currently supported.
487478
"""
488479
raise HandleException(
489-
"Field {0} cannot be set on lattice data source " "{1}.".format(field, self)
480+
f"Field {field} cannot be set on lattice data source {self}."
490481
)

0 commit comments

Comments
 (0)