Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,12 @@ nosetests.xml

#pycharm generated
.idea

# VS Code IDE internals
.vscode/

# nosetests metadata
.noseids

# Hypothesis files
.hypothesis/
17 changes: 14 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,29 @@ sudo: false
language: python
python:
- "2.7"
- "3.3"
- "3.4"
- "3.5"
- "3.6"
install:
- "pip install -r requirements.txt"
- "pip install -r dev-requirements.txt"
- pip install python-coveralls
- pip install coverage
before_script:
# We use before_script to report version and path information in a way
# that can be easily hidden by Travis' log folding. Moreover, a nonzero
# exit code from this block kills the entire job, meaning that if we can't
# even sensibly get version information, we correctly abort.
- which python
- python --version
- which nosetests
- nosetests --version
- which pylint
- pylint --version
script:
- nosetests --with-coverage -w instruments
- pylint --py3k instruments/
- pylint instruments/
- pylint --py3k instruments
- pylint --disable=I instruments
after_success:
- coveralls
deploy:
Expand Down
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
InstrumentKit
=============

.. image:: https://img.shields.io/travis/Galvant/InstrumentKit.svg?maxAge=2592000
.. image:: https://img.shields.io/travis/Galvant/InstrumentKit/master.svg?maxAge=2592000
:target: https://travis-ci.org/Galvant/InstrumentKit
:alt: Travis-CI build status

Expand Down Expand Up @@ -111,7 +111,7 @@ send, one can use the following functions to do so:
Python Version Compatibility
----------------------------

At this time, Python 2.7, 3.3, 3.4, and 3.5 are supported. Should you encounter
At this time, Python 2.7, 3.4, 3.5, and 3.6 are supported. Should you encounter
any problems with this library that occur in one version or another, please
do not hesitate to let us know.

Expand All @@ -134,7 +134,7 @@ To run the tests against all supported version of Python, you will need to
have the binary for each installed, as well as any requirements needed to
install ``numpy`` under each Python version. On Debian/Ubuntu systems this means
you will need to install the ``python-dev`` package for each version of Python
supported (``python2.7-dev``, ``python3.3-dev``, etc).
supported (``python2.7-dev``, ``python3.4-dev``, etc).

With the required system packages installed, all tests can be run with ``tox``:

Expand Down
3 changes: 2 additions & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mock
nose
pylint==1.6.5
hypothesis
pylint==1.7.1
12 changes: 12 additions & 0 deletions doc/source/devguide/util_fns.rst
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,15 @@ String Property
.. autofunction:: string_property


Named Structures
================

The :class:`~instruments.named_struct.NamedStruct` class can be used to represent
C-style structures for serializing and deserializing data.

.. autoclass:: instruments.named_struct.NamedStruct

.. autoclass:: instruments.named_struct.Field

.. autoclass:: instruments.named_struct.Padding

6 changes: 3 additions & 3 deletions doc/source/intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ $ pip install -r requirements.txt
- `enum34`_
- `future`_
- `python-vxi11`_
- `PyUSB`_
- `PyUSB`_ (version 1.0a or higher, required for raw USB support)
- `python-usbtmc`_
- `PyYAML`_
- `ruamel.yaml`_ (required for configuration file support)

Optional Dependencies
~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -46,7 +46,7 @@ Optional Dependencies
.. _quantities: http://pythonhosted.org/quantities/
.. _enum34: https://pypi.python.org/pypi/enum34
.. _future: https://pypi.python.org/pypi/future
.. _PyYAML: https://bitbucket.org/xi/pyyaml
.. _ruamel.yaml: http://yaml.readthedocs.io
.. _PyUSB: http://sourceforge.net/apps/trac/pyusb/
.. _PyVISA: http://pyvisa.sourceforge.net/
.. _python-usbtmc: https://pypi.python.org/pypi/python-usbtmc
Expand Down
4 changes: 2 additions & 2 deletions instruments/abstract_instruments/comm/file_communicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ def address(self):
"""
if hasattr(self._filelike, 'name'):
return self._filelike.name
else:
return None

return None

@address.setter
def address(self, newval):
Expand Down
7 changes: 3 additions & 4 deletions instruments/abstract_instruments/comm/gi_gpib_communicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(self, filelike, gpib_address):
if self._version <= 4:
self._eos = 10
else:
self._eos = "\n" # pylint: disable=redefined-variable-type
self._eos = "\n"

# PROPERTIES #

Expand Down Expand Up @@ -117,8 +117,8 @@ def terminator(self):
"""
if not self._eoi:
return self._terminator
else:
return 'eoi'

return 'eoi'

@terminator.setter
def terminator(self, newval):
Expand Down Expand Up @@ -203,7 +203,6 @@ def eos(self):

@eos.setter
def eos(self, newval):
# pylint: disable=redefined-variable-type
if self._version <= 4:
if isinstance(newval, (str, bytes)):
newval = ord(newval)
Expand Down
8 changes: 4 additions & 4 deletions instruments/abstract_instruments/comm/usbtmc_communicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def __init__(self, *args, **kwargs):
def address(self):
if hasattr(self._filelike, "name"):
return id(self._filelike) # TODO: replace with something more useful.
else:
return None

return None

@property
def terminator(self):
Expand All @@ -54,7 +54,7 @@ def terminator(self):

:type: `str`
"""
return self._filelike.term_char
return chr(self._filelike.term_char)

@terminator.setter
def terminator(self, newval):
Expand All @@ -78,7 +78,7 @@ def timeout(self):

@timeout.setter
def timeout(self, newval):
newval = assume_units(newval, pq.second).rescale(pq.ms).magnitude
newval = assume_units(newval, pq.second).rescale(pq.s).magnitude
self._filelike.timeout = newval

# FILE-LIKE METHODS #
Expand Down
2 changes: 1 addition & 1 deletion instruments/abstract_instruments/comm/visa_communicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def write_raw(self, msg):
:param bytes msg: Bytes to be sent to the instrument over the VISA
connection.
"""
self._conn.write(msg)
self._conn.write_raw(msg)

def seek(self, offset): # pylint: disable=unused-argument,no-self-use
return NotImplemented
Expand Down
5 changes: 2 additions & 3 deletions instruments/abstract_instruments/function_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ def amplitude(self):

if units == self.VoltageMode.dBm:
return pq.Quantity(mag, u.dBm)
else:
return pq.Quantity(mag, pq.V), units

return pq.Quantity(mag, pq.V), units

@amplitude.setter
def amplitude(self, newval):
Expand All @@ -168,7 +168,6 @@ def amplitude(self, newval):
# OK, we have volts. Now, do we have a tuple? If not, assume Vpp.
if not isinstance(newval, tuple):
mag = newval
# pylint: disable=redefined-variable-type
units = self.VoltageMode.peak_to_peak
else:
mag, units = newval
Expand Down
6 changes: 5 additions & 1 deletion instruments/abstract_instruments/instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,8 @@ def binblockread(self, data_width, fmt=None):
# CLASS METHODS #

URI_SCHEMES = ["serial", "tcpip", "gpib+usb",
"gpib+serial", "visa", "file", "usbtmc", "vxi11"]
"gpib+serial", "visa", "file", "usbtmc", "vxi11",
"test"]

@classmethod
def open_from_uri(cls, uri):
Expand All @@ -330,6 +331,7 @@ def open_from_uri(cls, uri):
gpib+serial:///dev/ttyACM0/15 # Currently non-functional.
visa://USB::0x0699::0x0401::C0000001::0::INSTR
usbtmc://USB::0x0699::0x0401::C0000001::0::INSTR
test://

For the ``serial`` URI scheme, baud rates may be explicitly specified
using the query parameter ``baud=``, as in the example
Expand Down Expand Up @@ -415,6 +417,8 @@ def open_from_uri(cls, uri):
# vxi11://192.168.1.104
# vxi11://TCPIP::192.168.1.105::gpib,5::INSTR
return cls.open_vxi11(parsed_uri.netloc, **kwargs)
elif parsed_uri.scheme == "test":
return cls.open_test(**kwargs)
else:
raise NotImplementedError("Invalid scheme or not yet "
"implemented.")
Expand Down
6 changes: 4 additions & 2 deletions instruments/abstract_instruments/oscilloscope.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ def __exit__(self, type, value, traceback):
def __eq__(self, other):
if not isinstance(other, type(self)):
return NotImplemented
else:
return other.name == self.name

return other.name == self.name

__hash__ = None

# PROPERTIES #

Expand Down
15 changes: 6 additions & 9 deletions instruments/agilent/agilent33220a.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ class Agilent33220a(SCPIFunctionGenerator):

"""

def __init__(self, filelike):
super(Agilent33220a, self).__init__(filelike)

# ENUMS #

class Function(Enum):
Expand Down Expand Up @@ -90,7 +87,7 @@ def frequency(self, newval):
super(Agilent33220a, self).frequency = newval

function = enum_property(
name="FUNC",
command="FUNC",
enum=Function,
doc="""
Gets/sets the output function of the function generator
Expand All @@ -101,7 +98,7 @@ def frequency(self, newval):
)

duty_cycle = int_property(
name="FUNC:SQU:DCYC",
command="FUNC:SQU:DCYC",
doc="""
Gets/sets the duty cycle of a square wave.

Expand All @@ -114,7 +111,7 @@ def frequency(self, newval):
)

ramp_symmetry = int_property(
name="FUNC:RAMP:SYMM",
command="FUNC:RAMP:SYMM",
doc="""
Gets/sets the ramp symmetry for ramp waves.

Expand All @@ -127,7 +124,7 @@ def frequency(self, newval):
)

output = bool_property(
name="OUTP",
command="OUTP",
inst_true="ON",
inst_false="OFF",
doc="""
Expand All @@ -141,7 +138,7 @@ def frequency(self, newval):
)

output_sync = bool_property(
name="OUTP:SYNC",
command="OUTP:SYNC",
inst_true="ON",
inst_false="OFF",
doc="""
Expand All @@ -152,7 +149,7 @@ def frequency(self, newval):
)

output_polarity = enum_property(
name="OUTP:POL",
command="OUTP:POL",
enum=OutputPolarity,
doc="""
Gets/sets the polarity of the waveform relative to the offset voltage.
Expand Down
3 changes: 0 additions & 3 deletions instruments/agilent/agilent34410a.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ class Agilent34410a(SCPIMultimeter): # pylint: disable=abstract-method
.. _Keysight website: http://www.keysight.com/
"""

def __init__(self, filelike):
super(Agilent34410a, self).__init__(filelike)

# PROPERTIES #

@property
Expand Down
Loading