Skip to content

Commit 60b1d6b

Browse files
authored
fixes python version 3.12 (#250)
* fixes #249 * fixes upper boundary for the python version and makes all dependencies open to new versions * fixes github action for testing and configuring poetry * add setuptools as dependencies as this mitigates the missing distutils package in python 3.12 * restricts Jinja2 version to non-vulnarable one * change minimal python version to 3.9 * fixes doctest outputs to be compliant to improved xarray output * small fix to README.rst * make codecov working again
1 parent d8b4647 commit 60b1d6b

File tree

7 files changed

+67
-87
lines changed

7 files changed

+67
-87
lines changed

.github/workflows/draft-pdf.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
name: Paper Draft
1212
steps:
1313
- name: Checkout
14-
uses: actions/checkout@v3
14+
uses: actions/checkout@v4
1515
- name: Build draft PDF
1616
uses: openjournals/openjournals-draft-action@master
1717
with:

.github/workflows/python-publish.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build and upload releases
1+
name: Build and upload releases (sdist only)
22

33
on:
44
release:
@@ -10,21 +10,21 @@ jobs:
1010
strategy:
1111
matrix:
1212
os: [ubuntu-latest]
13-
python-version: ['3.11']
13+
python-version: ['3.12']
1414
# os: [ubuntu-latest, macOS-latest, windows-latest]
1515
# python-version: ['3.8', '3.9', '3.10', '3.11']
16-
poetry-version: [1.6]
16+
poetry-version: ['1.8']
1717
fail-fast: false
1818
runs-on: ${{ matrix.os }}
1919

2020
steps:
21-
- uses: actions/checkout@v3
21+
- uses: actions/checkout@v4
2222
- name: Set up Python ${{ matrix.python-version }}
23-
uses: actions/setup-python@v4
23+
uses: actions/setup-python@v5
2424
with:
2525
python-version: ${{ matrix.python-version }}
2626
- name: Run image
27-
uses: abatilo/actions-poetry@v2.1.3
27+
uses: abatilo/actions-poetry@v2
2828
with:
2929
poetry-version: ${{ matrix.poetry-version }}
3030
- name: Install package

.github/workflows/python-test-publish.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@ jobs:
1111
strategy:
1212
matrix:
1313
os: [ubuntu-latest, macOS-latest, windows-latest]
14-
python-version: ['3.8', '3.9', '3.10', '3.11']
15-
poetry-version: [1.2]
14+
python-version: ['3.9', '3.10', '3.11', '3.12']
15+
poetry-version: ['1.8']
1616
fail-fast: false
1717
runs-on: ${{ matrix.os }}
1818

1919
steps:
20-
- uses: actions/checkout@v3
20+
- uses: actions/checkout@v4
2121
- name: Set up Python ${{ matrix.python-version }}
22-
uses: actions/setup-python@v4
22+
uses: actions/setup-python@v5
2323
with:
2424
python-version: ${{ matrix.python-version }}
2525
- name: Run image
26-
uses: abatilo/actions-poetry@v2.1.3
26+
uses: abatilo/actions-poetry@v2
2727
with:
2828
poetry-version: ${{ matrix.poetry-version }}
2929
- name: Configure test PyPI

.github/workflows/python-test.yml

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,46 +14,27 @@ jobs:
1414
strategy:
1515
matrix:
1616
os: [ubuntu-latest, macOS-latest, windows-latest]
17-
python-version: ['3.8', '3.11']
18-
poetry-version: [1.1.13]
17+
python-version: ['3.9', '3.12']
18+
poetry-version: ["1.8"]
1919
fail-fast: false
2020
runs-on: ${{ matrix.os }}
2121
steps:
22-
- uses: actions/checkout@v3
22+
- uses: actions/checkout@v4
2323

2424
- name: Set up Python ${{ matrix.python-version }}
25-
uses: actions/setup-python@v4
25+
uses: actions/setup-python@v5
2626
with:
2727
python-version: ${{ matrix.python-version }}
2828

29-
- name: Get full Python version
30-
id: full-python-version
31-
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
29+
- name: Display Python version
30+
run: python -c "import sys; print('-'.join(str(v) for v in sys.version_info))"
3231

3332
- name: Setup poetry
34-
uses: abatilo/actions-poetry@v2.1.3
33+
uses: abatilo/actions-poetry@v2
3534
with:
3635
poetry-version: ${{ matrix.poetry-version }}
3736

38-
- name: Update PATH
39-
if: ${{ runner.os != 'Windows' }}
40-
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
41-
42-
- name: Update Path for Windows
43-
if: ${{ runner.os == 'Windows' }}
44-
run: echo "$APPDATA\Python\Scripts" >> $GITHUB_PATH
45-
46-
- name: Configure poetry
47-
run: poetry config virtualenvs.in-project true
48-
49-
- name: Set up cache
50-
uses: actions/cache@v3
51-
id: cache
52-
with:
53-
path: .venv
54-
key: venv-cache-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
55-
56-
- name: Install dependencies
37+
- name: Install dependencies and pyndl
5738
run: poetry install
5839

5940
- name: Run linux tests
@@ -62,11 +43,11 @@ jobs:
6243

6344
- name: Run tests on other distributions (skip linux-only tests)
6445
if: ${{ runner.os != 'Linux' }}
65-
run: poetry run pytest --no-linux
46+
run: poetry run pytest --no-linux --cov=pyndl --cov-report=xml --disable-pytest-warnings
6647

6748
- name: Upload coverage to Codecov
68-
uses: codecov/codecov-action@v2
49+
uses: codecov/codecov-action@v4
6950
with:
70-
file: ./coverage.xml
7151
flags: unittests
52+
token: ${{ secrets.CODECOV_TOKEN }}
7253
env_vars: OS,PYTHON

README.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ Pyndl - Naive Discriminative Learning in Python
88
.. image:: https://codecov.io/gh/quantling/pyndl/branch/main/graph/badge.svg?token=2GWUXRA9PD
99
:target: https://codecov.io/gh/quantling/pyndl
1010

11-
.. image:: https://img.shields.io/lgtm/grade/python/g/quantling/pyndl.svg?logo=lgtm&logoWidth=18
12-
:target: https://lgtm.com/projects/g/quantling/pyndl/context:python
13-
1411
.. image:: https://img.shields.io/pypi/pyversions/pyndl.svg
1512
:target: https://pypi.python.org/pypi/pyndl/
1613

docs/source/examples.rst

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ Let's start:
126126
>>> weights = ndl.ndl(events='docs/data/lexample.tab.gz', alpha=0.1,
127127
... betas=(0.1, 0.1), method='threading')
128128
>>> weights # doctest: +ELLIPSIS
129-
<xarray.DataArray (outcomes: 8, cues: 15)>
129+
<xarray.DataArray (outcomes: 8, cues: 15)>...
130130
...
131131
132132
``weights`` is an ``xarray.DataArray`` of dimension ``len(outcomes)``,
@@ -139,21 +139,21 @@ methods
139139
.. code-block:: python
140140
141141
>>> weights[1, 5] # doctest: +ELLIPSIS
142-
<xarray.DataArray ()>
142+
<xarray.DataArray ()>...
143143
...
144144
>>> weights.loc[{'outcomes': 'plural', 'cues': 's#'}] # doctest: +ELLIPSIS
145-
<xarray.DataArray ()>
145+
<xarray.DataArray ()>...
146146
array(0.076988...)
147147
Coordinates:
148-
outcomes <U6 'plural'
149-
cues <U2 's#'
148+
outcomes <U6 ... 'plural'
149+
cues <U2 ... 's#'
150150
...
151151
>>> weights.loc['plural'].loc['s#'] # doctest: +ELLIPSIS
152-
<xarray.DataArray ()>
152+
<xarray.DataArray ()>...
153153
array(0.076988...)
154154
Coordinates:
155-
outcomes <U6 'plural'
156-
cues <U2 's#'
155+
outcomes <U6 ... 'plural'
156+
cues <U2 ... 's#'
157157
...
158158
159159
return the weight of the cue 's#' (the unigram 's' being the word-final) for
@@ -168,13 +168,13 @@ weight matrix by specifying the ``weight`` argument:
168168
>>> weights2 = ndl.ndl(events='docs/data/lexample.tab.gz', alpha=0.1,
169169
... betas=(0.1, 0.1), method='threading', weights=weights)
170170
>>> weights2 # doctest: +ELLIPSIS
171-
<xarray.DataArray (outcomes: 8, cues: 15)>
171+
<xarray.DataArray (outcomes: 8, cues: 15)>...
172172
array([[ 0.24...
173173
...
174174
...]])
175175
Coordinates:
176-
* outcomes (outcomes) <U6 'hand' 'plural'...
177-
* cues (cues) <U2 '#h' 'ha' 'an' 'nd'...
176+
* outcomes (outcomes) <U6 ... 'hand' 'plural'...
177+
* cues (cues) <U2 ... '#h' 'ha' 'an' 'nd'...
178178
Attributes:...
179179
date:...
180180
event_path:...
@@ -235,7 +235,7 @@ If you prefer to get a ``xarray.DataArray`` returned you can set the flag ``make
235235
... alphas=alphas_cues, betas=(0.1, 0.1),
236236
... make_data_array=True)
237237
>>> weights # doctest: +ELLIPSIS
238-
<xarray.DataArray (outcomes: 8, cues: 15)>
238+
<xarray.DataArray (outcomes: 8, cues: 15)>...
239239
...
240240
241241
@@ -449,27 +449,27 @@ gets apparent.
449449
... 'cue_vector_dimensions': ['dim1', 'dim2', 'dim3']}]
450450
>>> weights_ndl = weights_ndl.loc[{'outcomes': ['A', 'B', 'C', 'D'], 'cues': ['a', 'b', 'c']}]
451451
>>> print(weights_wh) # doctest: +ELLIPSIS
452-
<xarray.DataArray (outcome_vector_dimensions: 4, cue_vector_dimensions: 3)>
452+
<xarray.DataArray (outcome_vector_dimensions: 4, cue_vector_dimensions: 3)>...
453453
array([[0.06706..., 0. , 0. ],
454454
[0. , 0.03940..., 0. ],
455455
[0.0094... , 0. , 0.03940...],
456456
[0.01 , 0. , 0. ]])
457457
Coordinates:
458-
* outcome_vector_dimensions (outcome_vector_dimensions) <U4 'dim1' ... 'dim4'
459-
* cue_vector_dimensions (cue_vector_dimensions) <U4 'dim1' 'dim2' 'dim3'
460-
outcomes <U1 'A'
461-
cues <U1 'a'
458+
* outcome_vector_dimensions (outcome_vector_dimensions) <U4 ... 'dim1' ...
459+
* cue_vector_dimensions (cue_vector_dimensions) <U4 ... 'dim1' ...
460+
outcomes <U1 ... 'A'
461+
cues <U1 ... 'a'
462462
Attributes: (12/15)
463463
...
464464
>>> print(weights_ndl) # doctest: +ELLIPSIS
465-
<xarray.DataArray (outcomes: 4, cues: 3)>
465+
<xarray.DataArray (outcomes: 4, cues: 3)>...
466466
array([[0.06706..., 0. , 0. ],
467467
[0. , 0.03940..., 0. ],
468468
[0.0094... , 0. , 0.03940...],
469469
[0.01 , 0. , 0. ]])
470470
Coordinates:
471-
* outcomes (outcomes) <U1 'A' 'B' 'C' 'D'
472-
* cues (cues) <U1 'a' 'b' 'c'
471+
* outcomes (outcomes) <U1 ... 'A' 'B' 'C' 'D'
472+
* cues (cues) <U1 ... 'a' 'b' 'c'
473473
Attributes: (12/17)
474474
...
475475

pyproject.toml

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "pyndl"
3-
version = "1.2.2"
3+
version = "1.2.3"
44
description = "Naive discriminative learning implements learning and classification models based on the Rescorla-Wagner equations."
55

66
license = "MIT"
@@ -28,29 +28,31 @@ classifiers = ['Development Status :: 5 - Production/Stable',
2828
'Topic :: Scientific/Engineering :: Information Analysis',]
2929

3030
[tool.poetry.dependencies]
31-
python = ">=3.8,<3.12" # Compatible python versions must be declared here
32-
numpy = "^1.23.1"
33-
scipy = "^1.9.0"
34-
pandas = "^1.4.3"
35-
xarray = "^2022.6.0"
36-
netCDF4 = "^1.6.0"
37-
Cython = "^3.0.0"
31+
python = ">=3.9,<3.13" # Compatible python versions must be declared here
32+
numpy = ">=1.24.1"
33+
scipy = ">=1.13.0"
34+
pandas = ">=1.4.3"
35+
xarray = ">=2022.6.0"
36+
netCDF4 = ">=1.6.0"
37+
Cython = ">=3.0.0"
38+
toml = ">=0.10.2"
39+
setuptools = ">=69.2.0"
3840

3941
[tool.poetry.dev-dependencies]
40-
pytest = "^7.0"
41-
pytest-cov = "^2.4"
42-
pydocstyle = "^6.1.1"
43-
flake8 = "^4.0.1"
44-
sphinx = "^1.4"
45-
sphinx_rtd_theme = "^1.0.0"
46-
notebook = "^6.4.10"
47-
seaborn = "^0.12.1"
48-
numpydoc = "^1.2"
49-
sphinx-copybutton = "^0.5.1"
50-
pylint = "^2.0.0"
51-
nbsphinx = "^0.8.8"
52-
vulture = "^2.3"
53-
Jinja2 = "<3.1.0"
42+
pytest = ">=7.0"
43+
pytest-cov = ">=2.4"
44+
pydocstyle = ">=6.1.1"
45+
flake8 = ">=4.0.1"
46+
sphinx = ">=1.4"
47+
sphinx_rtd_theme = ">=1.0.0"
48+
notebook = ">=6.4.10"
49+
seaborn = ">=0.12.1"
50+
numpydoc = ">=1.2"
51+
sphinx-copybutton = ">=0.5.1"
52+
pylint = ">=2.0.0"
53+
nbsphinx = ">=0.8.8"
54+
vulture = ">=2.3"
55+
Jinja2 = ">=3.1.3"
5456

5557
[tool.pytest.ini_options]
5658
addopts = '--doctest-glob "*.rst"'

0 commit comments

Comments
 (0)