Skip to content
Merged
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ To run the tests::

$ python -m pytest

To see a coverage report, check pep8 and pyflakes::
To see a coverage report, check pytest-cov::
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about:

To see a coverage report and style violations, you can use pytest-cov, pep8 and pyflakes:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought that we use flake8 instead of pep8 and pyflakes.
So perhaps:

To see a coverage report, check pytest-cov:
 $ python -m pytest --cov-report term-missing --cov=pytac

To see style violations, use flake8:
 $ flake8

Or we could use this plugin:

To see a coverage report and style violations, you can use pytest-cov and flake8:
 $ python -m pytest --cov-report term-missing --cov=pytac --flake8


$ python -m pytest --cov=pytac --pep8 --flakes
$ python -m pytest --cov-report term-missing --cov=pytac

To build the documentation::

Expand Down
2 changes: 1 addition & 1 deletion docs/developers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Developers
==========

The installation and initialisation steps are slightly different if you want to work on pytac.
N.B. This guide uses pipenv but a normal venv will also work.
N.B. This guide uses pipenv but a virtualenv will also work.


Installation
Expand Down
10 changes: 5 additions & 5 deletions docs/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ Print BPM PV names along with s position
...
>>> lattice.get_family_s('BPM')
[4.38,
8.806500000000002,
11.374000000000002,
...
8.806500000000002,
11.374000000000002,
...

Get the value of the 'b1' field of the quad elements
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -90,6 +90,6 @@ Get the value of the 'b1' field of the quad elements

>>> lattice.get_values('QUAD', 'b1', pytac.RB)
[71.32496643066406,
129.35191345214844,
98.25287628173828,
129.35191345214844,
98.25287628173828,
...
24 changes: 16 additions & 8 deletions docs/pytac.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,22 @@ API Documentation
:undoc-members:
:show-inheritance:

pytac.cs module
pytac.cothread_cs module
---------------

.. automodule:: pytac.cs
:members:
:undoc-members:
:show-inheritance:

pytac.data_source module
-------------------

.. automodule:: pytac.data_source
:members:
:undoc-members:
:show-inheritance:

pytac.device module
-------------------

Expand All @@ -30,26 +38,26 @@ pytac.element module
:undoc-members:
:show-inheritance:

pytac.lattice module
pytac.exceptions module
--------------------

.. automodule:: pytac.lattice
.. automodule:: pytac.exceptions
:members:
:undoc-members:
:show-inheritance:

pytac.load_csv module
---------------------
pytac.lattice module
--------------------

.. automodule:: pytac.load_csv
.. automodule:: pytac.lattice
:members:
:undoc-members:
:show-inheritance:

pytac.model module
pytac.load_csv module
---------------------

.. automodule:: pytac.model
.. automodule:: pytac.load_csv
:members:
:undoc-members:
:show-inheritance:
Expand Down
7 changes: 4 additions & 3 deletions pytac/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
DEFAULT = 'default'


from . import data_source, element, exceptions, lattice, load_csv, units, utils # noqa: E402
from . import (data_source, device, element, exceptions, lattice, load_csv,
units, utils) # noqa: E402
"""Error 402 is suppressed as we cannot import these modules at the top of the
file as the strings above must be set first or the imports will fail.
"""
__all__ = ["data_source", "element", "exceptions", "lattice", "load_csv",
"units", "utils"]
__all__ = ["data_source", "device", "element", "exceptions", "lattice",
"load_csv", "units", "utils"]
23 changes: 12 additions & 11 deletions pytac/cothread_cs.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ def get_single(self, pv, throw=True):
Args:
pv (string): The process variable given as a string. It can be a
readback or a setpoint PV.
throw (bool): if True, ControlSystemException will be raised on
failure
throw (bool): On failure, if True raise ControlSystemException, if
False None will be returned for any PV that fails
and log a warning.

Returns:
object: the current value of the given PV.
Expand All @@ -48,9 +49,9 @@ def get_multiple(self, pvs, throw=True):

Args:
pvs (sequence): PVs to get values of.
throw (bool): if True, ControlSystemException will be raised on
failure. If False, None will be returned for any PV
for which the get fails.
throw (bool): On failure, if True raise ControlSystemException, if
False None will be returned for any PV that fails
and log a warning.

Returns:
sequence: the current values of the PVs.
Expand Down Expand Up @@ -81,8 +82,8 @@ def set_single(self, pv, value, throw=True):
Args:
pv (string): PV to set the value of.
value (object): The value to set the PV to.
throw (bool): if True, ControlSystemException will be raised on
failure
throw (bool): On failure, if True raise ControlSystemException, if
False log a warning.

Returns:
bool: True for success, False for failure
Expand All @@ -107,10 +108,10 @@ def set_multiple(self, pvs, values, throw=True):
Args:
pvs (sequence): PVs to set the values of.
values (sequence): values to set to the PVs.
throw (bool): if True, ControlSystemException will be raised on
failure. If False, a list of True and False values
will be returned corresponding to successes and
failures.
throw (bool): On failure, if True raise ControlSystemException, if
False return a list of True and False values
corresponding to successes and failures and log a
warning.

Returns:
list(bool): True for success, False for failure
Expand Down
32 changes: 18 additions & 14 deletions pytac/cs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@
class ControlSystem(object):
"""Abstract base class representing a control system.

A specialised implementation of this class would be used to communicate over
channel access with the hardware in the ring.
A specialised implementation of this class would be used to communicate
over channel access with the hardware in the ring.

**Methods:**
"""
def get_single(self, pv, throw=True):
def get_single(self, pv, throw):
"""Get the value of a given PV.

Args:
pv (string): PV to get the value of.
readback or a setpoint PV.
throw (bool): if True, ControlSystemException will be raised on
failure
throw (bool): On failure, if True raise ControlSystemException, if
False None will be returned for any PV that fails
and log a warning.

Returns:
object: the current value of the given PV.
Expand All @@ -26,13 +27,14 @@ def get_single(self, pv, throw=True):
"""
raise NotImplementedError()

def get_multiple(self, pvs, throw=True):
def get_multiple(self, pvs, throw):
"""Get the value for given PVs.

Args:
pvs (sequence): PVs to get values of.
throw (bool): if True, ControlSystemException will be raised on
failure
throw (bool): On failure, if True raise ControlSystemException, if
False None will be returned for any PV that fails
and log a warning.

Returns:
list(object): the current values of the PVs.
Expand All @@ -42,28 +44,30 @@ def get_multiple(self, pvs, throw=True):
"""
raise NotImplementedError()

def set_single(self, pv, value):
def set_single(self, pv, value, throw):
"""Set the value of a given PV.

Args:
pv (string): The PV to set the value of.
value (object): The value to set the PV to.
throw (bool): if True, ControlSystemException will be raised on
failure
throw (bool): On failure, if True raise ControlSystemException, if
False log a warning.

Raises:
ControlSystemException: if it cannot connect to the specified PV.
"""
raise NotImplementedError()

def set_multiple(self, pvs, values):
def set_multiple(self, pvs, values, throw):
"""Set the values for given PVs.

Args:
pvs (sequence): PVs to set the values of.
values (sequence): values to set no the PVs.
throw (bool): if True, ControlSystemException will be raised on
failure
throw (bool): On failure, if True raise ControlSystemException, if
False return a list of True and False values
corresponding to successes and failures and log a
warning.

Raises:
ValueError: if the PVs or values are not passed in as sequences
Expand Down
2 changes: 1 addition & 1 deletion pytac/data/DIAD/unitconv.csv
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ el_id,field,uc_type,uc_id,phys_units,eng_units
189,db0,null,0,m^-1,A
136,db0,null,0,m^-1,A
164,db0,null,0,m^-1,A
1490,f,null,0,Hz,Hz
1492,f,null,0,Hz,Hz
5,b1,pchip,1,m^-2,A
404,b1,pchip,1,m^-2,A
425,b1,pchip,1,m^-2,A
Expand Down
Loading