Skip to content

Commit

Permalink
Test suite for Tektronix DPO4104 and bug fixes (#253)
Browse files Browse the repository at this point in the history
* Test suite for Tektronix DPO4104 and bug fixes

Full coverage test suite for Tektronix DPO4104 added. Trying to make
use of hypothesis where it makes sense and leave it away where it
doesn't.

Bug fixes for `tekdpo4104.py`:
- Instead of the new value to set, the documentation was passed on
  in the `_parent_property` routine. This routine is only used once,
  however, a usage scenario is written but has likely never been
  tested before. The test that does what this property is supposed to
  do passes now with the fix.
- Reading ASCII data from a data source used `map` and then directly
  transferred to an `ndarray`. This was fine in python 2, not anymore
  though. Fixed on line 114.
- Reading binary data is tested now. The test however failed since the
  next command issued left only a termination character. The binary data
  is read using `binblockread` from `Instruments`. This will leave the
  last termination character behind. Inserted an additional reading
  statement to read one character to get rid of this character. Checked
  with the manual to ensure consistency. Manual states that this
  termination character should be there after the binary data block,
  thus, the bug fix makes sense.

* Switched hypothesis random sampling over enum to pytest parametrize
  • Loading branch information
trappitsch committed Sep 2, 2020
1 parent cce7b72 commit d5c1ad5
Show file tree
Hide file tree
Showing 2 changed files with 507 additions and 3 deletions.
7 changes: 4 additions & 3 deletions instruments/tektronix/tekdpo4104.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def getter(self): # pylint: disable=missing-docstring
def setter(self, newval):
with self:
# pylint: disable=protected-access
setattr(self._tek, prop_name, doc)
setattr(self._tek, prop_name, newval)

return property(getter, setter, doc=doc)

Expand Down Expand Up @@ -111,8 +111,7 @@ def read_waveform(self, bin_format=True):
sleep(0.02) # Work around issue with 2.48 firmware.
raw = self._tek.query("CURVE?")
raw = raw.split(",") # Break up comma delimited string
raw = map(float, raw) # Convert each list element to int
raw = np.array(raw) # Convert into numpy array
raw = np.array(raw, dtype=np.float) # Convert to numpy array
else:
# Set encoding to signed, big-endian
self._tek.sendcmd("DAT:ENC RIB")
Expand All @@ -121,6 +120,8 @@ def read_waveform(self, bin_format=True):
self._tek.sendcmd("CURVE?")
# Read in the binary block, data width of 2 bytes.
raw = self._tek.binblockread(data_width)
# Read the new line character that is sent
self._tek._file.read_raw(1) # pylint: disable=protected-access

yoffs = self._tek.y_offset # Retrieve Y offset
ymult = self._tek.query("WFMP:YMU?") # Retrieve Y multiplier
Expand Down
Loading

0 comments on commit d5c1ad5

Please sign in to comment.