Skip to content

Commit

Permalink
Merge 31b3cd0 into 760deb3
Browse files Browse the repository at this point in the history
  • Loading branch information
scasagrande committed Oct 15, 2020
2 parents 760deb3 + 31b3cd0 commit 61983f1
Show file tree
Hide file tree
Showing 133 changed files with 847 additions and 880 deletions.
2 changes: 1 addition & 1 deletion doc/examples/ex_hp3456.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import logging
import time
import instruments as ik
import instruments.units as u
from instruments.units import ureg as u

dmm = ik.hp.HP3456a.open_gpibusb('/dev/ttyUSB0', 22)
logging.basicConfig(level=logging.DEBUG)
Expand Down
2 changes: 1 addition & 1 deletion doc/examples/ex_maui.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"\n",
"# import the instrument kit\n",
"import instruments as ik\n",
"import instruments.units as u\n",
"from instruments.units import ureg as u\n",
"\n",
"# imports for specific functions in this script\n",
"import matplotlib.pyplot as plt\n",
Expand Down
2 changes: 1 addition & 1 deletion doc/examples/ex_tekdpo70000.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
"_.rescale('GHz')"
"_.to('GHz')"
],
"language": "python",
"metadata": {},
Expand Down
2 changes: 1 addition & 1 deletion doc/examples/ex_topticatopmode.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""

import instruments as ik
import instruments.units as u
from instruments.units import ureg as u
from platform import system
if system() == 'Windows':
tm = ik.toptica.TopMode.open_serial('COM17', 115200)
Expand Down
2 changes: 1 addition & 1 deletion doc/examples/minghe/ex_minghe_mhs5200.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/python
from instruments.minghe import MHS5200
import instruments.units as u
from instruments.units import ureg as u

mhs = MHS5200.open_serial(vid=6790, pid=29987, baud=57600)
print(mhs.serial_number)
Expand Down
2 changes: 1 addition & 1 deletion doc/examples/qubitekk/ex_qubitekk_mc1.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from time import sleep

from instruments.qubitekk import MC1
import instruments.units as u
from instruments.units import ureg as u


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion doc/examples/srs_DG645.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"collapsed": false,
"input": [
"from instruments.srs import SRSDG645\n",
"import instruments.units as u"
"from instruments.units import ureg as u"
],
"language": "python",
"metadata": {},
Expand Down
2 changes: 1 addition & 1 deletion doc/examples/srs_DG645.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# <codecell>

from instruments.srs import SRSDG645
import instruments.units as u
from instruments.units import ureg as u

# <markdowncell>

Expand Down
9 changes: 1 addition & 8 deletions doc/source/apiref/other.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,4 @@ Units
-----

Units are identified to the Phase Matrix FSW-0020 using the
`~quantities.Quantity` class implemented by the `quantities` package. To support
the FSW-0020, we provide several additional unit quantities, listed here.

.. autodata:: mHz

.. autodata:: dBm

.. autodata:: cBm
`~pint.Quantity` class implemented by the `pint` package.
2 changes: 1 addition & 1 deletion doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@
'http://docs.python.org/': None,
'numpy': ('http://docs.scipy.org/doc/numpy', None),
'serial': ('http://pyserial.sourceforge.net/', None),
'quantities': ('http://pythonhosted.org/quantities/', None),
'pint': ('https://pint.readthedocs.io/en/stable/', None),
}

autodoc_member_order = 'groupwise'
2 changes: 1 addition & 1 deletion doc/source/devguide/code_style.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Data Types
Numeric Data
------------

When appropriate, use :class:`quantities.Quantity` objects to track units.
When appropriate, use :class:`pint.Quantity` objects to track units.
If this is not possible or appropriate, use a bare `float` for scalars
and `np.ndarray` for array-valued data.

Expand Down
10 changes: 5 additions & 5 deletions doc/source/devguide/util_fns.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ These properties, when implemented in your class, might look like this::
voltage = unitful_property(
"VOLT",
u.volt,
valid_range=(0*quantities.volt, 10*quantities.volt)
valid_range=(0*u.volt, 10*u.volt)
doc="""
Gets/sets the output voltage.

:units: As specified, or assumed to be :math:`\\text{V}` otherwise.
:type: `float` or `~quantities.Quantity`
:type: `float` or `~pint.Quantity`
"""
)

Expand Down Expand Up @@ -136,11 +136,11 @@ the `~instruments.thorlabs.TC200` class::
doc="""
Gets the actual temperature of the sensor

:units: As specified (if a `~quantities.quantity.Quantity`) or assumed
:units: As specified (if a `~pint.Quantity`) or assumed
to be of units degrees C.
:type: `~quantities.quantity.Quantity` or `int`
:type: `~pint.Quantity` or `int`
:return: the temperature (in degrees C)
:rtype: `~quantities.quantity.Quantity`
:rtype: `~pint.Quantity`
"""
)

Expand Down
4 changes: 2 additions & 2 deletions doc/source/intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ $ pip install -r requirements.txt

- NumPy
- `PySerial`_
- `quantities`_
- `pint`_
- `python-vxi11`_
- `PyUSB`_ (version 1.0a or higher, required for raw USB support)
- `python-usbtmc`_
Expand All @@ -40,7 +40,7 @@ Optional Dependencies
~~~~~~~~~~~~~~~~~~~~~

.. _PySerial: http://pyserial.sourceforge.net/
.. _quantities: http://pythonhosted.org/quantities/
.. _pint: https://pint.readthedocs.io/en/stable/
.. _ruamel.yaml: http://yaml.readthedocs.io
.. _PyUSB: http://sourceforge.net/apps/trac/pyusb/
.. _PyVISA: http://pyvisa.sourceforge.net/
Expand Down
5 changes: 4 additions & 1 deletion instruments/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

# IMPORTS ####################################################################

__all__ = ["units"]


from . import abstract_instruments
from .abstract_instruments import Instrument
Expand Down Expand Up @@ -33,7 +35,8 @@
from . import toptica
from . import yokogawa

from . import units
from .units import ureg as units

from .config import load_instruments

# VERSION METADATA ###########################################################
Expand Down
12 changes: 6 additions & 6 deletions instruments/abstract_instruments/comm/gpib_communicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import io
import time

import instruments.units as u
from instruments.units import ureg as u

from instruments.abstract_instruments.comm import AbstractCommunicator
from instruments.util_fns import assume_units
Expand Down Expand Up @@ -98,7 +98,7 @@ def timeout(self):
Gets/sets the timeeout of both the GPIB bus and the connection
channel between the PC and the GPIB adapter.
:type: `~quantities.Quantity`
:type: `~pint.Quantity`
:units: As specified, or assumed to be of units ``seconds``
"""
return self._timeout
Expand All @@ -107,13 +107,13 @@ def timeout(self):
def timeout(self, newval):
newval = assume_units(newval, u.second)
if self._model == GPIBCommunicator.Model.gi and self._version <= 4:
newval = newval.rescale(u.second)
newval = newval.to(u.second)
self._file.sendcmd('+t:{}'.format(int(newval.magnitude)))
else:
newval = newval.rescale(u.millisecond)
newval = newval.to(u.millisecond)
self._file.sendcmd("++read_tmo_ms {}".format(int(newval.magnitude)))
self._file.timeout = newval.rescale(u.second)
self._timeout = newval.rescale(u.second)
self._file.timeout = newval.to(u.second)
self._timeout = newval.to(u.second)

@property
def terminator(self):
Expand Down
6 changes: 3 additions & 3 deletions instruments/abstract_instruments/comm/serial_communicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import io
import serial

import instruments.units as u
from instruments.units import ureg as u

from instruments.abstract_instruments.comm import AbstractCommunicator
from instruments.util_fns import assume_units
Expand Down Expand Up @@ -80,14 +80,14 @@ def timeout(self):
"""
Gets/sets the communication timeout of the serial comm channel.
:type: `~quantities.Quantity`
:type: `~pint.Quantity`
:units: As specified or assumed to be of units ``seconds``
"""
return self._conn.timeout * u.second

@timeout.setter
def timeout(self, newval):
newval = assume_units(newval, u.second).rescale(u.second).magnitude
newval = assume_units(newval, u.second).to(u.second).magnitude
self._conn.timeout = newval

# FILE-LIKE METHODS #
Expand Down
6 changes: 3 additions & 3 deletions instruments/abstract_instruments/comm/socket_communicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import io
import socket

import instruments.units as u
from instruments.units import ureg as u

from instruments.abstract_instruments.comm import AbstractCommunicator
from instruments.util_fns import assume_units
Expand Down Expand Up @@ -70,14 +70,14 @@ def timeout(self):
"""
Gets/sets the connection timeout of the socket comm channel.
:type: `~quantities.Quantity`
:type: `~pint.Quantity`
:units: As specified or assumed to be of units ``seconds``
"""
return self._conn.gettimeout() * u.second

@timeout.setter
def timeout(self, newval):
newval = assume_units(newval, u.second).rescale(u.second).magnitude
newval = assume_units(newval, u.second).to(u.second).magnitude
self._conn.settimeout(newval)

# FILE-LIKE METHODS #
Expand Down
6 changes: 3 additions & 3 deletions instruments/abstract_instruments/comm/usbtmc_communicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from instruments.abstract_instruments.comm import AbstractCommunicator
from instruments.util_fns import assume_units
import instruments.units as u
from instruments.units import ureg as u

# CLASSES #####################################################################

Expand Down Expand Up @@ -67,14 +67,14 @@ def timeout(self):
"""
Gets/sets the communication timeout of the usbtmc comm channel.
:type: `~quantities.Quantity`
:type: `~pint.Quantity`
:units: As specified or assumed to be of units ``seconds``
"""
return self._filelike.timeout * u.second

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

# FILE-LIKE METHODS #
Expand Down
4 changes: 2 additions & 2 deletions instruments/abstract_instruments/comm/visa_communicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from instruments.abstract_instruments.comm import AbstractCommunicator
from instruments.util_fns import assume_units
import instruments.units as u
from instruments.units import ureg as u

# CLASSES #####################################################################

Expand Down Expand Up @@ -86,7 +86,7 @@ def timeout(self):

@timeout.setter
def timeout(self, newval):
newval = assume_units(newval, u.second).rescale(u.second).magnitude
newval = assume_units(newval, u.second).to(u.second).magnitude
self._conn.timeout = newval

# FILE-LIKE METHODS #
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def timeout(self):
"""
Gets/sets the communication timeout of the vxi11 comm channel.
:type: `~quantities.Quantity`
:type: `~pint.Quantity`
:units: As specified or assumed to be of units ``seconds``
"""
return self._inst.timeout
Expand Down
2 changes: 1 addition & 1 deletion instruments/abstract_instruments/electrometer.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def unit(self):
Gets/sets the measurement mode for the electrometer. This is an
abstract method.
:type: `~quantities.UnitQuantity`
:type: `~pint.Unit`
"""

@property
Expand Down
Loading

0 comments on commit 61983f1

Please sign in to comment.