Skip to content

Commit 2d53ef6

Browse files
Merge pull request #703 from sadielbartholomew/drop-python-3.7
Testing and CI tidying including adding Python 3.12 job
2 parents 1668e0b + 1047712 commit 2d53ef6

File tree

6 files changed

+44
-7
lines changed

6 files changed

+44
-7
lines changed

.github/workflows/run-test-suite.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ jobs:
2424
matrix:
2525
# Skip older ubuntu-16.04 & macos-10.15 to save usage resource
2626
os: [ubuntu-latest, macos-latest]
27-
python-version: [3.8, 3.9]
27+
# Note: keep versions quoted as strings else 3.10 taken as 3.1, etc.
28+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
2829

2930
# Run on new and old(er) versions of the distros we support (Linux, Mac OS)
3031
runs-on: ${{ matrix.os }}
@@ -59,7 +60,7 @@ jobs:
5960
uses: conda-incubator/setup-miniconda@v2
6061
with:
6162
auto-update-conda: true
62-
miniconda-version: 'latest'
63+
miniconda-version: "latest"
6364
activate-environment: cf-latest
6465
python-version: ${{ matrix.python-version }}
6566
channels: ncas, conda-forge
@@ -146,7 +147,7 @@ jobs:
146147
# passing at least for that job, avoiding useless coverage reports.
147148
uses: codecov/codecov-action@v3
148149
if: |
149-
matrix.os == 'ubuntu-latest' && matrix.python-version == 3.8
150+
matrix.os == "ubuntu-latest" && matrix.python-version == "3.9"
150151
with:
151152
file: |
152153
${{ github.workspace }}/main/cf/test/cf_coverage_reports/coverage.xml

.github/workflows/test-source-dist.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
strategy:
1919
matrix:
2020
os: [ubuntu-latest, macos-latest]
21-
python-version: [3.8]
21+
python-version: ["3.8"]
2222
runs-on: ${{ matrix.os }}
2323

2424
# The sequence of tasks that will be executed as part of this job:
@@ -52,7 +52,7 @@ jobs:
5252
uses: conda-incubator/setup-miniconda@v2
5353
with:
5454
auto-update-conda: true
55-
miniconda-version: 'latest'
55+
miniconda-version: "latest"
5656
activate-environment: cf-latest
5757
python-version: ${{ matrix.python-version }}
5858
channels: ncas, conda-forge

cf/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
)
9090

9191
x = ", ".join(_requires)
92-
_error0 = f"cf v{ __version__} requires the modules {x}. "
92+
_error0 = f"cf v{__version__} requires the modules {x}. "
9393

9494
try:
9595
import cfdm

cf/read_write/read.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@ def read(
990990
if info:
991991
logger.info(
992992
f"{org_len} input field{_plural(org_len)} aggregated into "
993-
f"{n} field{ _plural(n)}"
993+
f"{n} field{_plural(n)}"
994994
) # pragma: no cover
995995

996996
# ----------------------------------------------------------------

cf/test/test_Field.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
try:
1515
from scipy.ndimage import convolve1d
1616

17+
# In some cases we don't need SciPy directly, since it is required by code
18+
# here which uses 'convolve1d' under-the-hood. Without it installed, get:
19+
#
20+
# NameError: name 'convolve1d' is not defined. Did you
21+
# mean: 'cf_convolve1d'?
22+
1723
SCIPY_AVAILABLE = True
1824
# not 'except ImportError' as that can hide nested errors, catch anything:
1925
except Exception:
@@ -2330,6 +2336,9 @@ def test_Field_percentile(self):
23302336
# TODO: add loop to check get same shape and close enough data
23312337
# for every possible axis combo (see also test_Data_percentile).
23322338

2339+
@unittest.skipIf(
2340+
not SCIPY_AVAILABLE, "scipy must be installed for this test."
2341+
)
23332342
def test_Field_grad_xy(self):
23342343
f = cf.example_field(0)
23352344

@@ -2415,6 +2424,9 @@ def test_Field_grad_xy(self):
24152424
y.dimension_coordinate("X").standard_name, "longitude"
24162425
)
24172426

2427+
@unittest.skipIf(
2428+
not SCIPY_AVAILABLE, "scipy must be installed for this test."
2429+
)
24182430
def test_Field_laplacian_xy(self):
24192431
f = cf.example_field(0)
24202432

cf/test/test_Maths.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,30 @@
22
import faulthandler
33
import unittest
44

5+
6+
SCIPY_AVAILABLE = False
7+
try:
8+
# We don't need SciPy directly in this test, it is only required by code
9+
# here which uses 'convolve1d' under-the-hood. Without it installed, get:
10+
#
11+
# NameError: name 'convolve1d' is not defined. Did you
12+
# mean: 'cf_convolve1d'?
13+
import scipy
14+
15+
SCIPY_AVAILABLE = True
16+
# not 'except ImportError' as that can hide nested errors, catch anything:
17+
except Exception:
18+
pass # test with this dependency will then be skipped by unittest
19+
520
faulthandler.enable() # to debug seg faults and timeouts
621

722
import cf
823

924

1025
class MathTest(unittest.TestCase):
26+
@unittest.skipIf(
27+
not SCIPY_AVAILABLE, "scipy must be installed for this test."
28+
)
1129
def test_curl_xy(self):
1230
f = cf.example_field(0)
1331

@@ -97,6 +115,9 @@ def test_curl_xy(self):
97115
c.dimension_coordinate("X").standard_name, "longitude"
98116
)
99117

118+
@unittest.skipIf(
119+
not SCIPY_AVAILABLE, "scipy must be installed for this test."
120+
)
100121
def test_div_xy(self):
101122
f = cf.example_field(0)
102123

@@ -185,6 +206,9 @@ def test_div_xy(self):
185206
d.dimension_coordinate("X").standard_name, "longitude"
186207
)
187208

209+
@unittest.skipIf(
210+
not SCIPY_AVAILABLE, "scipy must be installed for this test."
211+
)
188212
def test_differential_operators(self):
189213
f = cf.example_field(0)
190214

0 commit comments

Comments
 (0)