Skip to content

Commit

Permalink
Merge pull request #296 from hassec/test_more_py_versions
Browse files Browse the repository at this point in the history
feat(ci): Run tests for more python versions
  • Loading branch information
smithsp authored Mar 8, 2024
2 parents 506477f + c5e5903 commit 110ba8b
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 22 deletions.
30 changes: 26 additions & 4 deletions .github/workflows/regression.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,25 @@ jobs:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10', '3.11']
# 3.12 does not yet work because numpy removed numpy.distutils that pygacode relies on

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: '3.6'
python-version: ${{ matrix.python-version }}
cache: 'pip'


- name: Extra dependencies required for 3.7
if: ${{matrix.python-version == '3.7'}}
run: |
sudo apt-get update
sudo apt-get install libhdf5-dev libnetcdf-dev
- name: Install numpy
run: |
Expand All @@ -32,7 +43,18 @@ jobs:
run: |
python3 -m pip install -r requirements.txt
- name: Install OMAS
# numpy is a build time dependency of pygacode
# but before pygacode 1.0 it did not specify its build dependencies correctly
# and pygacode requires python >= 3.8,
# so for 3.7 we need to build without build isolation and manually install numpy
- name: Install OMAS (Py 3.7)
if: ${{matrix.python-version == '3.7'}}
run: |
python3 -m pip install wheel
python3 -m pip install --no-build-isolation .[machine]
- name: Install OMAS (normal)
if: ${{matrix.python-version != '3.7'}}
run: |
python3 -m pip install .[machine]
Expand Down
2 changes: 1 addition & 1 deletion omas/omas_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ def get2d(contour_quantity):
z = scipy.ndimage.zoom(z, sf)
value_2d = scipy.ndimage.zoom(value_2d, sf)

cs = ax.contour(r, z, value_2d, levels, **kw)
cs = ax.contour(r, z, value_2d, levels=levels, **kw)

if label_contours or ((label_contours is None) and (contour_quantity == 'q')):
ax.clabel(cs)
Expand Down
2 changes: 2 additions & 0 deletions omas/tests/failed_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
failed_OMFIT = False
except ImportError as _excp:
failed_OMFIT = _excp
except AttributeError as _excp:
failed_OMFIT = "omfit_classes, from xarray import * bug "

try:
import MDSplus
Expand Down
6 changes: 6 additions & 0 deletions omas/tests/test_omas_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ def test_uncertain(self):

@unittest.skipIf(failed_OMFIT, str(failed_OMFIT))
def test_plot_g_s_2_ip(self):
# on 3.7 this test raises:
# ValueError: Number of rows must be a positive integer, not 7.0
# It seems like this is caused by a bug in omfit_classes where a float
# instead of int is passed to plot
if sys.version_info.minor==7:
raise unittest.SkipTest("Avoid Py 3.7 omfit_classes bug.")
from omas.examples import plot_g_s_2_ip

def test_plot_saveload_scaling(self):
Expand Down
31 changes: 16 additions & 15 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@
#
# usage: pip install -r requirements.txt

numpy>=1.16.1 # required
uncertainties # required
pint # required
netCDF4 # required
boto3 # required
matplotlib # required
scipy # required
h5py # required
pymongo # required
dnspython # required
xmltodict # required
xarray # required
setuptools>=41.2 # required
tqdm # required
Cython # required
numpy>=1.16.1 # required
uncertainties # required
pint # required
netCDF4 # required
boto3 # required
matplotlib # required
scipy # required
h5py # required
pymongo # required
dnspython # required
xmltodict # required
xarray # required
setuptools>=41.2 # required
tqdm # required
Cython # required
importlib_metadata <5;python_version=='3.7' # required

# omfit_classes # machine
# pexpect # machine
Expand Down
6 changes: 4 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import sys
import glob
import subprocess

Expand All @@ -19,6 +18,9 @@
'setuptools>=41.2',
'tqdm',
'Cython',
# latest xarray version that works with 3.7 doesn't work
# with importlib_metadata >5 since they deprecated the `get()` method on Entrypoints
"importlib_metadata <5;python_version=='3.7'"
]

extras_require = {
Expand All @@ -44,7 +46,7 @@
f.write('# Do not edit this file by hand, operate on setup.py instead\n#\n')
f.write('# usage: pip install -r requirements.txt\n\n')
for item in install_requires:
f.write(item.ljust(25) + '# required\n')
f.write(item.ljust(50) + ' # required\n')
for requirement in extras_require:
f.write('\n')
for item in extras_require[requirement]:
Expand Down

0 comments on commit 110ba8b

Please sign in to comment.