Skip to content

Commit

Permalink
Build docs and travis.
Browse files Browse the repository at this point in the history
  • Loading branch information
T-Nicholls committed Apr 18, 2019
1 parent 610bfe9 commit c46a8a2
Show file tree
Hide file tree
Showing 22 changed files with 121 additions and 70 deletions.
7 changes: 7 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Read the Docs configuration file, see
# https://docs.readthedocs.io/en/stable/config-file/v2.html for details.
version: 2
sphinx:
configuration: docs/conf.py
conda:
environment: docs/conda_env.yml
23 changes: 23 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
sudo: false
language: python
python:
- "2.7"
- "3.5"
- "3.6"

install:
- pip install virtualenv
- python -m virtualenv venv
- source venv/bin/activate
- pip install -r requirements.txt
- pip install git+https://github.com/dls-controls/pytac.git
- pip install -e "git+https://github.com/atcollab/at.git#egg=at-python&subdirectory=pyat"

script:
- python -m pytest test --cov-report term-missing --cov=atip
- flake8 --ignore=E501,W504
- cd docs
- sphinx-build -b html -ETW . _build/html

after_success:
- coveralls
3 changes: 0 additions & 3 deletions Makefile

This file was deleted.

5 changes: 1 addition & 4 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@ pytest-cov = "*"
coveralls = "*"
mock = "*"
flake8 = "*"
pytest-lazy-fixture = "*"
Sphinx = "*"
sphinx_rtd_theme = "*"

[packages]
numpy = ">=1.10"
scipy = ">=0.16"
pytest = ">=2.9"
numpy = "*"
cothread = "*"
13 changes: 10 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
.. image:: https://travis-ci.org/T-Nicholls/atip.svg?branch=master
:target: https://travis-ci.org/T-Nicholls/atip
.. image:: https://coveralls.io/repos/github/T-Nicholls/atip/badge.svg?branch=master
:target: https://coveralls.io/github/T-Nicholls/atip?branch=master
.. image:: https://readthedocs.org/projects/atip/badge/?version=latest
:target: https://atip.readthedocs.io/en/latest/?badge=latest

==============================================
ATIP - Accelerator Toolbox Interface for Pytac
==============================================
Expand All @@ -7,6 +14,9 @@ ATIP is intended to integrate a simulator, using the python implementation of
`Pytac <https://github.com/dls-controls/pytac>`_ so that it can be addressed
in the same manner as the live machine.

For further information on any of ATIP's functions or classes please read the
documentation `here <https://atip.readthedocs.io/en/latest/>`_.

Installation:
-------------

Expand Down Expand Up @@ -130,6 +140,3 @@ given an excess of superfulous data.

A number of functions that perform tasks that are frequent or long-winded are
included in ``ease.py`` to make life easier for the user.

For further information on any of ATIP's functions or classes please read the
documentation `here <https://atip.readthedocs.io/en/latest/>`_.
4 changes: 2 additions & 2 deletions atip/ease.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ def start(self):
self.start_time = t.time()

def stop(self):
if self.start_time is 0:
if self.start_time == 0:
raise Exception("You need to start the timer first, moron.")
else:
final_time = (t.time() - self.start_time)
self.start_time = 0
return final_time

def time(self):
if self.start_time is 0:
if self.start_time == 0:
raise Exception("You need to start the timer first, moron.")
else:
return (t.time() - self.start_time)
Expand Down
2 changes: 1 addition & 1 deletion atip/load_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def load(pytac_lattice, at_ring, callback=None):
if live_fields[x] in SIMULATED_FIELDS:
sim_fields.append(live_fields[x])
# Set the simulator data source on each element.
e.set_data_source(ATElementDataSource(at_lattice[e.index-1], e.index,
e.set_data_source(ATElementDataSource(at_lattice[e.index - 1], e.index,
atsim, sim_fields), pytac.SIM)
# Give any lattice fields not on the live machine a unit conversion object.
for field in pytac_lattice.get_fields()[pytac.SIM]:
Expand Down
14 changes: 7 additions & 7 deletions atip/sim_data_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,14 @@ def _KickAngle(self, cell, value):
if isinstance(self._at_element, at.elements.Sextupole):
length = self._at_element.Length
if value is None:
if cell is 0:
if cell == 0:
return -(self._at_element.PolynomB[0] * length)
elif cell is 1:
elif cell == 1:
return (self._at_element.PolynomA[0] * length)
else:
if cell is 0:
if cell == 0:
self._at_element.PolynomB[0] = -(value / length)
elif cell is 1:
elif cell == 1:
self._at_element.PolynomA[0] = (value / length)
else:
if value is None:
Expand Down Expand Up @@ -239,7 +239,7 @@ def _Orbit(self, cell, value):
return float(self._atsim.get_orbit(cell)[self._index - 1])
else:
# This shouldn't be possible
field = 'x' if cell is 0 else 'y'
field = 'x' if cell == 0 else 'y'
raise HandleException("Field {0} cannot be set on element data "
"source {1}.".format(field, self))

Expand Down Expand Up @@ -334,7 +334,7 @@ def get_fields(self):
Returns:
list: A list of all the fields that are present on this element.
"""
return self._field_funcs.keys()
return list(self._field_funcs.keys())

def get_value(self, field, handle=None, throw=None):
"""Get the value for a field on the Pytac lattice.
Expand All @@ -354,7 +354,7 @@ def get_value(self, field, handle=None, throw=None):
Raises:
FieldException: if the specified field does not exist.
"""
if field in self._field_funcs.keys():
if field in list(self._field_funcs.keys()):
return self._field_funcs[field]()
else:
raise FieldException("Lattice data source {0} does not have field "
Expand Down
14 changes: 11 additions & 3 deletions docs/atip.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,18 @@ atip.load_sim module
:undoc-members:
:show-inheritance:

atip.sim_data_source module
---------------------------
atip.sim_data_sources module
----------------------------

.. automodule:: atip.sim_data_source
.. automodule:: atip.sim_data_sources
:members:
:undoc-members:
:show-inheritance:

atip.at_interface module
------------------------

.. automodule:: atip.at_interface
:members:
:undoc-members:
:show-inheritance:
10 changes: 10 additions & 0 deletions docs/conda_env.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: atip
dependencies:
- python=3.6
- numpy>=1.10
- scipy>=0.16
- pip:
- cothread
- git+https://github.com/dls-controls/pytac.git
- --extra-index-url=https://test.pypi.org/simple/
- at-python
5 changes: 1 addition & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,11 @@
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
sys.path.append(os.path.join(os.path.dirname(__file__), '../../pytac'))
sys.path.append(os.path.join(os.path.dirname(__file__), '../../at/pyat'))


# -- Project information -----------------------------------------------------

project = u'ATIP'
copyright = u'2018, Tobyn Nicholls'
copyright = u'2019, Tobyn Nicholls'
author = u'Tobyn Nicholls'

# The short X.Y version
Expand Down
2 changes: 2 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ ATIP is intended to integrate a simulator, using the python implementation of
`Pytac <https://github.com/dls-controls/pytac>`_ so that it can be addressed
in the same manner as the live machine.

It is hosted on GitHub `here. <https://github.com/T-Nicholls/atip>`_

Contents:
=========

Expand Down
2 changes: 0 additions & 2 deletions ioc/atip_ioc_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
require('epicsdbbuilder==1.0')
require('numpy>=1.10')
require('scipy>=0.16')
# require('pytac')
# require('at-python')


here = os.path.realpath('.')
Expand Down
8 changes: 4 additions & 4 deletions ioc/atip_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def update_pvs(self):
"""
for rb_record in self._rb_only_records:
index, field = self._in_records[rb_record]
if index is 0:
if index == 0:
rb_record.set(self.lattice.get_value(field, units=pytac.ENG,
data_source=pytac.SIM))
else:
Expand Down Expand Up @@ -105,7 +105,7 @@ def _create_records(self, limits_csv):
LOPR=lower, HOPR=upper,
initial_value=value)
set_pv = element.get_pv_name('b0', pytac.SP)
def on_update(value, name=set_pv):
def on_update(value, name=set_pv): # noqa E306
self._on_update(name, value)
upper, lower = limits_dict.get(set_pv, (None, None))
builder.SetDeviceName(set_pv.split(':', 1)[0])
Expand Down Expand Up @@ -182,7 +182,7 @@ def _create_feedback_records(self, feedback_csv):
N_BPM = len(self.lattice.get_elements('BPM'))
builder.SetDeviceName("SR-DI-EBPM-01")
bpm_enabled_record = builder.Waveform("ENABLED", NELM=N_BPM,
initial_value=[0]*N_BPM)
initial_value=[0] * N_BPM)
self._feedback_records[(0, "bpm_enabled")] = bpm_enabled_record
print("Finished creating all {0} records.".format(self.total_records))

Expand Down Expand Up @@ -222,7 +222,7 @@ def set_feedback_record(self, index, field, value):
try:
self._feedback_records[(index, field)].set(value)
except KeyError:
if index is 0:
if index == 0:
raise FieldException("Lattice {0} does not have field {1}."
.format(self.lattice, field))
else:
Expand Down
20 changes: 10 additions & 10 deletions ioc/create_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ def generate_feedback_pvs():
all_elements = atip.utils.preload(lattice)
# Only keep the elements from the families that we are concerned with.
elements = list(set(
all_elements.hstrs
+ all_elements.vstrs
+ all_elements.bpms)
all_elements.hstrs +
all_elements.vstrs +
all_elements.bpms)
)

# Also get families for tune feedback
tune_quad_elements = set(
all_elements.q1ds
+ all_elements.q2ds
+ all_elements.q3ds
+ all_elements.q3bs
+ all_elements.q2bs
+ all_elements.q1bs
all_elements.q1ds +
all_elements.q2ds +
all_elements.q3ds +
all_elements.q3bs +
all_elements.q2bs +
all_elements.q1bs
)
elements.extend(list(tune_quad_elements))
elements.extend(tune_quad_elements)

# Sort the elements by index, in ascending order.
elements.sort(key=lambda x: x.index)
Expand Down
4 changes: 1 addition & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ numpy>=1.10
scipy>=0.16
pytest>=2.9
pytest-cov
pytest-lazy-fixture
coveralls
mock
flake8
sphinx
sphinx-rtd-theme
cothread
#pytac
#at-python
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ description-file = README.rst
[coverage:run]
omit =
atip/ease.py
atip/utils.py
*/junk/*
*/venv*

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@
'License :: OSI Approved :: Apache Software License',

'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
],

keywords='accelerator physics',
Expand Down
4 changes: 2 additions & 2 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import at
import mock
import numpy
import pytac
import pytest
from pytac import load_csv, cs

import atip

Expand Down Expand Up @@ -39,7 +39,7 @@ def at_lattice():

@pytest.fixture(scope='session')
def pytac_lattice():
return pytac.load_csv.load('DIAD')
return load_csv.load('DIAD', cs.ControlSystem())


@pytest.fixture(scope='session')
Expand Down

0 comments on commit c46a8a2

Please sign in to comment.