Skip to content

Commit 5e59b9d

Browse files
authored
Merge pull request #3 from lightwave-lab/development
v1.0.3
2 parents 3f53df9 + 8074e94 commit 5e59b9d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+956
-1884
lines changed

.readthedocs.yml

Lines changed: 0 additions & 8 deletions
This file was deleted.

.travis.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
language: python
2+
python:
3+
- '3.6'
4+
install:
5+
- pip install -U virtualenv pip
6+
- python --version
7+
script:
8+
- DOCKER=1 make test-unit-all
9+
- make test-lint-errors
10+
- if [ "$TRAVIS_BRANCH" = "master" ]; then make test-lint; fi
11+
deploy:
12+
provider: pypi
13+
user: thomaslima
14+
password:
15+
secure: FbL4S5mRqyZeKt1ZHoEyE53kgkaKBdVfztxbEYfTfhNgaQg94BUmd/x5IWBCORIqF7s0ywkkP+kK9LRFrA5Ymu50hbwAAODnIEEax5xcYE825c0cagXQdKsMG/MGVDGOxlcO+1DQN6zZnfcOVX6fGqm9pEBN2s4Ej0YfabrqdeebvVb53pyCXS43veGXQ8jyMr48eHdig3rksnWb5uKBUrfW1g8wxdCntym4vJRxrdA4zZIuG1osfkxd1sX5rUXcnPNc+6czXwSFsVoRgrr5RvUFYGDGGjuCQ4UVeRe3/V2pSN543FaG6HWP0xpJYGw2dcsML8ykIOIX1oRf2bO2dD485KJHdmkHpgafiB7fnDqwiw0uah/PJkdLtd1tWk4/y0txsEQJhK1qZdHRf5wSfGAIK2XvQPuQXL/MZ8BUIojYd0Ay+JwnkvB57bubGotmvwjWmdDbMMrSWI1B+6UgjHjPN7rQU8qMgV10/IyH51fCvd+2uMQX6D3I7CXS5o8ELy9OsboSxzPxNOxitmq/oGoMKAlg3nhqvYCNZXoxHip+aamqUtccYKaYZuv5ma+WIhAAJt6h5IJ1J3d5wBz6dILXzUYhw3IoXzrGdEG5TSdjrDdmmgxjKrCybxGkbTTLFS69pKa6XGwB9D0qhxKEdJmaFrGojm0zDFOsQwcHse8=
16+
on:
17+
tags: true
18+
branch: master

CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
11
# CHANGELOG
2+
3+
1.0.3:
4+
- added documentation for lightlab command line tool
5+
- added a driver for HP 8157A Optical Variable attenuator
6+
- added travis-ci integration

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ test-nb: testbuild
6969
( \
7070
source venv/bin/activate; \
7171
py.test $(TESTARGS) $(TESTARGSNB) notebooks/Tests; \
72+
rsync -rau notebooks/Tests/*.ipynb docs/ipynbs/Tests
7273
)
7374

7475
test-unit-all: testbuild
@@ -143,7 +144,6 @@ venvinfo/docreqs~: $(REINSTALL_DEPS) notebooks/Tests doc-requirements.txt
143144
@touch venvinfo/docreqs~
144145

145146
docs: docbuild
146-
rsync -rau notebooks/Tests/*.ipynb docs/ipynbs/Tests
147147
source venv/bin/activate; $(MAKE) -C docs $(DOCTYPE_DEFAULT)
148148

149149
docs-ci: docbuild
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
Contributing to ``lightlab``
2+
============================
3+
We follow this `Git branching workflow <http://nvie.com/posts/a-successful-git-branching-model/>`_. Feature branches should base off of development; when they are done, they must pass tests and test-nb's; finally they are merged to development.
4+
5+
Testing ``lightlab``
6+
--------------------
7+
First off, your change should not break existing code. You can run automated tests like this::
8+
9+
make test-unit
10+
make test-nb
11+
12+
The test-nb target runs the **notebooks** in notebooks/Tests. This is a cool feature because it allows you to go in with jupyter and see what's happening if it fails. We recommend using the `nbval <https://github.com/computationalmodelling/nbval>`_ approach. It checks for no-exceptions, not accuracy of results. If you want to check for accuracy of results, do something like::
13+
14+
x = 1 + 1
15+
assert x == 2
16+
17+
in the cell.
18+
19+
**Make tests for your features!** It helps a lot. Again, **Never put hardware accessing methods in a unittest**.
20+
21+
To run just one test, use a command like::
22+
23+
$ source venv/bin/activate
24+
$ py.test --nbval-lax notebooks/Tests/TestBook.ipynb
25+
26+
Documenting
27+
-----------
28+
Documenting as you go is helpful for other developers and code reviewers. So useful that we made a whole :doc:`tutorial <docYourCode>` on it. We use auto-API so that docstrings in code make it into the official documentation.
29+
30+
For non-hardware features, a good strategy is to use tests that are both functional and documentation by example. In cases where visualization is helpful, use notebook-based, which can be linked from this documentation or in-library docstrings :ref:`like this </ipynbs/Tests/TestPeakAssistant.ipynb>`. Otherwise, you can make `pytest <https://docs.pytest.org/en/latest/>`_ unittests in the tests directory, which can be linked like this: :py:mod:`~tests.test_virtualization`.
31+
32+
For new hardware drivers, as a general rule, document its basic behavior in ``lightlab/notebooks/BasicHardwareTests``. Make sure to save with outputs. Finally, link it in the docstring like this::
33+
34+
class Tektronix_DPO4034_Oscope(VISAInstrumentDriver, TekScopeAbstract):
35+
''' Slow DPO scope. See abstract driver for description
36+
37+
`Manual <http://websrv.mece.ualberta.ca/electrowiki/images/8/8b/MSO4054_Programmer_Manual.pdf>`__
38+
39+
Usage: :any:`/ipynbs/Hardware/Oscilloscope.ipynb`
40+
41+
'''
42+
instrument_category = Oscilloscope
43+
...
44+
45+
Linting
46+
-------
47+
As of now, we don't require strict `PEP-8 <https://www.python.org/dev/peps/pep-0008/>`_ compliance, but we might in the future. However, we try to follow as many of their guidelines as possible:
48+
49+
.. figure:: images/sublimelinter_example_bad.png
50+
:alt: bad pep8 example
51+
52+
Example of valid python code that violates some of the PEP8 guidelines.
53+
54+
.. figure:: images/sublimelinter_example_good.png
55+
:alt: good pep8 example
56+
57+
Fixing the PEP8 violations of the previous figure.
58+
59+
Sometimes the linter is wrong. You can tell it to ignore lines by adding comment flags like the following example:
60+
61+
.. code:: python
62+
63+
x = [x for x in sketchy_iterable] # pylint: disable=not-an-iterable
64+
from badPractice import * # noqa
65+
66+
``# noqa`` is going to ignore pyflakes linting, whereas ``# pylint`` configures `pylint` behavior.
67+
68+
If you use Sublime editor
69+
-------------------------
70+
Everyone has their favorite editor. We like `Sublime Text <https://www.sublimetext.com>`_. If you use Sublime, `here <https://github.com/SublimeLinter/SublimeLinter-flake8>`_ is a good linter. It visually shows what is going on while you code, saving lots of headaches
71+
72+
Sublime also helps you organize your files, autocomplete, and manage whitespace. This is :doc:`sublime-lightlab`. Put it in the ``lightlab/`` directory and call it something like ``sublime-lightlab.sublime-project``.
73+
74+
By the way, you can make a command-line Sublime by doing this in Terminal (for MacOS)::
75+
76+
ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
77+
78+
Adding a new package
79+
--------------------
80+
Two ways to do this. The preferred method is to add it to the package requirements in ``setup.py``. The other way is in the venv. In that case, make sure you freeze the new package to the requirements file::
81+
82+
$ source venv/bin/activate
83+
$ pip install <package>
84+
$ make pip-freeze
85+
$ git commit -m "added package <package> to venv"
86+
87+
.. warning::
88+
89+
If your code imports an external package, the sphinx documentation will try to load it and fail. The solution is to mock it. Lets say your source file wants to import::
90+
91+
import scipy.optimize as opt
92+
93+
For this to pass and build the docs, you have to go into the ``docs/sphinx/conf.py`` file. Then add that package to the list of mocks like so::
94+
95+
MOCK_MODULES = [<other stuff>, 'scipy.optimize']

docs/_static/developers/developer.rst

Lines changed: 0 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -240,101 +240,6 @@ It's not really necessary in this example where there is just a notebook. If you
240240

241241
Unittests are designed to be run in an automated way in a repeatable setting. Firstly, the real world is not repeatable. Secondly, an automated run could do something unintended and damaging to the currently connected devices.
242242

243-
Contributing to ``lightlab``
244-
------------------------------
245-
We follow this `Git branching workflow <http://nvie.com/posts/a-successful-git-branching-model/>`_. Feature branches should base off of development; when they are done, they must pass tests and test-nb's; finally they are merged to development.
246-
247-
Testing ``lightlab``
248-
^^^^^^^^^^^^^^^^^^^^
249-
First off, your change should not break existing code. You can run automated tests like this::
250-
251-
make test-unit
252-
make test-nb
253-
254-
The test-nb target runs the **notebooks** in notebooks/Tests. This is a cool feature because it allows you to go in with jupyter and see what's happening if it fails. We recommend using the `nbval <https://github.com/computationalmodelling/nbval>`_ approach. It checks for no-exceptions, not accuracy of results. If you want to check for accuracy of results, do something like::
255-
256-
x = 1 + 1
257-
assert x == 2
258-
259-
in the cell.
260-
261-
**Make tests for your features!** It helps a lot. Again, **Never put hardware accessing methods in a unittest**.
262-
263-
To run just one test, use a command like::
264-
265-
$ source venv/bin/activate
266-
$ py.test --nbval-lax notebooks/Tests/TestBook.ipynb
267-
268-
Documenting
269-
^^^^^^^^^^^^^^
270-
Documenting as you go is helpful for other developers and code reviewers. So useful that we made a whole :doc:`tutorial <docYourCode>` on it. We use auto-API so that docstrings in code make it into the official documentation.
271-
272-
For non-hardware features, a good strategy is to use tests that are both functional and documentation by example. In cases where visualization is helpful, use notebook-based, which can be linked from this documentation or in-library docstrings :ref:`like this </ipynbs/Tests/TestPeakAssistant.ipynb>`. Otherwise, you can make `pytest <https://docs.pytest.org/en/latest/>`_ unittests in the tests directory, which can be linked like this: :py:mod:`~tests.test_virtualization`.
273-
274-
For new hardware drivers, as a general rule, document its basic behavior in ``lightlab/notebooks/BasicHardwareTests``. Make sure to save with outputs. Finally, link it in the docstring like this::
275-
276-
class Tektronix_DPO4034_Oscope(VISAInstrumentDriver, TekScopeAbstract):
277-
''' Slow DPO scope. See abstract driver for description
278-
279-
`Manual <http://websrv.mece.ualberta.ca/electrowiki/images/8/8b/MSO4054_Programmer_Manual.pdf>`__
280-
281-
Usage: :any:`/ipynbs/Hardware/Oscilloscope.ipynb`
282-
283-
'''
284-
instrument_category = Oscilloscope
285-
...
286-
287-
Linting
288-
^^^^^^^
289-
As of now, we don't require strict `PEP-8 <https://www.python.org/dev/peps/pep-0008/>`_ compliance, but we might in the future. However, we try to follow as many of their guidelines as possible:
290-
291-
.. figure:: images/sublimelinter_example_bad.png
292-
:alt: bad pep8 example
293-
294-
Example of valid python code that violates some of the PEP8 guidelines.
295-
296-
.. figure:: images/sublimelinter_example_good.png
297-
:alt: good pep8 example
298-
299-
Fixing the PEP8 violations of the previous figure.
300-
301-
Sometimes the linter is wrong. You can tell it to ignore lines by adding comment flags like the following example:
302-
303-
.. code:: python
304-
305-
x = [x for x in sketchy_iterable] # pylint: disable=not-an-iterable
306-
from badPractice import * # noqa
307-
308-
``# noqa`` is going to ignore pyflakes linting, whereas ``# pylint`` configures `pylint` behavior.
309-
310-
If you use Sublime editor
311-
^^^^^^^^^^^^^^^^^^^^^^^^^
312-
Everyone has their favorite editor. We like `Sublime Text <https://www.sublimetext.com>`_. If you use Sublime, `here <https://github.com/SublimeLinter/SublimeLinter-flake8>`_ is a good linter. It visually shows what is going on while you code, saving lots of headaches
313-
314-
Sublime also helps you organize your files, autocomplete, and manage whitespace. This is :doc:`sublime-lightlab`. Put it in the ``lightlab/`` directory and call it something like ``sublime-lightlab.sublime-project``.
315-
316-
By the way, you can make a command-line Sublime by doing this in Terminal (for MacOS)::
317-
318-
ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
319-
320-
Adding a new package
321-
^^^^^^^^^^^^^^^^^^^^^
322-
Two ways to do this. The preferred method is to add it to the package requirements in ``setup.py``. The other way is in the venv. In that case, make sure you freeze the new package to the requirements file::
323-
324-
$ source venv/bin/activate
325-
$ pip install <package>
326-
$ make pip-freeze
327-
$ git commit -m "added package <package> to venv"
328-
329-
.. warning::
330-
331-
If your code imports an external package, the sphinx documentation will try to load it and fail. The solution is to mock it. Lets say your source file wants to import::
332-
333-
import scipy.optimize as opt
334-
335-
For this to pass and build the docs, you have to go into the ``docs/sphinx/conf.py`` file. Then add that package to the list of mocks like so::
336-
337-
MOCK_MODULES = [<other stuff>, 'scipy.optimize']
338243

339244
* :ref:`genindex`
340245
* :ref:`modindex`

docs/_static/developers/index.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
Developer guide
1+
Making your changes to lightlab
22
================================================
33

4+
The following texts should help you in the process or making changes to lightlab itself. If you are looking for a way to include your own instrument driver, you will find instructions in :ref:`creating_drivers`. After you are done, please consider submitting a pull request via github! :) We the community will be glad to provide feedback.
5+
46
.. toctree::
57
:maxdepth: 2
68

79
developer
10+
contributing
811
docYourCode
912
labState
1013

docs/_static/gettingStarted/engineersGuide.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# An engineer’s guide to modern lab control
22

3+
Author: *Thomas Ferreira de Lima* ([email protected])
4+
35
## Introduction
46

57
Over the years, software engineering has evolved into a very prominent field that penetrates all industrial sectors. Its core principles and philosophy was to make life easier for consumers to achieve their goals. That was when Apple and Microsoft were created. Then, as the field evolved, it has become important to make software engineering as inclusive as possible to new “developers”, and to make collaboration as seamless as possible. This is the age of the apps. Now, software programming is becoming considered as fundamental as math and science, and are starting to enter school curricula.
@@ -57,7 +59,7 @@ git commit -m “finished simulation”
5759
git push
5860
```
5961

60-
![How git push works.](https://wac-cdn.atlassian.com/dam/jcr:f148974e-7d4d-4c0e-bd31-8ac5467d1e6a/04.svg?cdnVersion=ie)
62+
![How git push works. From Atlassian.](images/atlassian_push.png)
6163

6264
The other main property of Git is that it can automatically “merge” a number of edits together in one step. Its algorithm is very powerful, works flawlessly when it can, and falls back to human intervention in case of “conflicts”. When two collaborators create local commits, their history tree forks into two parallel versions that need to be conciliated. If one pushes first, the other’s push will fail and abort, because its local repository does not agree with the most recent state of the remote repository. So the proper procedure is to sync the local with the remote by “pulling” changes from remote:
6365

Binary file not shown.
Loading

docs/_static/gettingStarted/index.rst

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
.. _getting-started:
22

3-
Getting Started
3+
Getting Started to Python, Jupyter, git
44
================================================
55

6+
.. todo::
7+
Include more tutorial pages and useful links for intriductory python.
8+
69
.. toctree::
7-
:maxdepth: 2
10+
:maxdepth: 3
811

912
engineersGuide
10-
user
11-
sysadmin
12-
13-
* :ref:`genindex`
14-
* :ref:`modindex`
15-
* :ref:`search`

0 commit comments

Comments
 (0)