Skip to content

Commit

Permalink
Bump pytest 7.2.0, hypothesis 6.56.0 (#374)
Browse files Browse the repository at this point in the history
* Bump pytest 7.1.3, hypothesis 6.56.0

* Drop testing on Py36

* Fix hypothesis precision errors (#380)

* Fix hypothesis precision errors

* Fix error calculation

* Remove erroneous comment

* Re-write blu.py::_format_eight

* Fix imports

* Adjust limits

* Remove Py36 support in docs

* Fix remaining blu tests

* Increase precision of test data in Keithley580::test_measure

* PR feedback

Co-authored-by: Gracecr <cgrace.chris@gmail.com>
Co-authored-by: Steven Casagrande <steven.casagrande@ibm.com>
  • Loading branch information
3 people committed Nov 1, 2022
1 parent bbed79c commit d648a34
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 23 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ jobs:
strategy:
matrix:
include:
- python-version: 3.6
TOXENV: "py36"
- python-version: 3.7
TOXENV: "py37"
- python-version: 3.8
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ send, one can use the following functions to do so:
Python Version Compatibility
----------------------------

At this time, Python 3.6, 3.7, 3.8, 3.9, and 3.10 are supported. Should you encounter
At this time, Python 3.7, 3.8, 3.9, and 3.10 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 Down
5 changes: 2 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ classifiers =
Development Status :: 4 - Beta
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Expand Down Expand Up @@ -43,12 +42,12 @@ install_requires =
numpy = numpy
dev =
coverage
hypothesis~=5.49.0
hypothesis~=6.56.0
mock
pytest-cov
pytest-mock
pytest-xdist
pytest~=6.2.5
pytest~=7.2.0
pyvisa-sim
six

Expand Down
15 changes: 7 additions & 8 deletions src/instruments/gentec_eo/blu.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,11 +643,10 @@ def _format_eight(value):
:return: Value formatted to 8 characters
:rtype: str
"""
if len(str(value)) > 8:
if value < 0:
value = f"{value:.2g}".zfill(8) # make space for -
else:
value = f"{value:.3g}".zfill(8)
else:
value = str(value).zfill(8)
return value
if abs(value) < 1e-99:
return "0".zfill(8)

for p in range(8, 1, -1):
val = f"{value:.{p}g}".zfill(8)
if len(val) == 8:
return val
16 changes: 10 additions & 6 deletions tests/test_gentec_eo/test_blu.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@

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

from hypothesis import given, strategies as st
from hypothesis import given
from hypothesis import strategies as st
import pytest

import instruments as ik
from tests import expected_protocol
from instruments.units import ureg as u
from tests import expected_protocol

# TESTS ######################################################################

Expand Down Expand Up @@ -285,7 +286,7 @@ def test_blu_user_offset_watts():
"""Get / set user offset in watts."""
with expected_protocol(
ik.gentec_eo.Blu,
["*GMD", "*GUO", "*OFF000042.0"], # get power mode
["*GMD", "*GUO", "*OFF00000042"], # get power mode
["Mode: 0", "User Offset : 1.500e-3", "ACK"], # power mode watts
sep="\r\n",
) as blu:
Expand All @@ -297,7 +298,7 @@ def test_blu_user_offset_joules():
"""Get / set user offset in joules."""
with expected_protocol(
ik.gentec_eo.Blu,
["*GMD", "*GUO", "*OFF000042.0"], # get power mode
["*GMD", "*GUO", "*OFF00000042"], # get power mode
["Mode: 2", "User Offset : 1.500e-3", "ACK"], # power mode joules
sep="\r\n",
) as blu:
Expand All @@ -309,7 +310,7 @@ def test_blu_user_offset_unitless():
"""Set user offset unitless."""
with expected_protocol(
ik.gentec_eo.Blu,
["*OFF000042.0"],
["*OFF00000042"],
["ACK"],
sep="\r\n",
) as blu:
Expand Down Expand Up @@ -467,5 +468,8 @@ def test_format_eight_length_values(value):
and that it is correct to 1% with given number.
"""
value_read = ik.gentec_eo.blu._format_eight(value)
assert value == pytest.approx(float(value_read), abs(value) / 100.0)
if value > 0:
assert value == pytest.approx(float(value_read), rel=0.01)
else:
assert value == pytest.approx(float(value_read), rel=0.05)
assert len(value_read) == 8
4 changes: 2 additions & 2 deletions tests/test_keithley/test_keithley580.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ def test_parse_status_word_invalid_prefix(init):
def test_measure(init, create_measurement, resistance):
"""Perform a resistance measurement."""
# cap resistance at max of 11 character with given max_value
resistance_byte = bytes(f"{resistance:.3f}", "utf-8")
resistance_byte = bytes(f"{resistance:.6f}", "utf-8")
measurement = create_measurement(resistance=resistance_byte)
with expected_protocol(
ik.keithley.Keithley580,
Expand All @@ -603,7 +603,7 @@ def test_measure(init, create_measurement, resistance):
sep="\n",
) as inst:
read_value = inst.measure()
assert read_value.magnitude == pytest.approx(resistance, rel=1e-5)
assert read_value.magnitude == pytest.approx(resistance, rel=1e-3)
assert read_value.units == u.ohm


Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py{36,37,38,39,310},py{36,37,38,39,310}-numpy,pylint
envlist = py{37,38,39,310},py{37,38,39,310}-numpy,pylint
isolated_build = true

[testenv]
Expand Down

0 comments on commit d648a34

Please sign in to comment.